sdedic commented on code in PR #7649: URL: https://github.com/apache/netbeans/pull/7649#discussion_r1718451315
########## enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/NotificationUtils.java: ########## @@ -0,0 +1,45 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.netbeans.modules.cloud.oracle; + +import org.openide.DialogDisplayer; +import org.openide.NotifyDescriptor; + +/** + * + * @author Dusan Petrovic + */ +public class NotificationUtils { + + public static boolean confirmAction(String message) { + NotifyDescriptor.Confirmation msg = new NotifyDescriptor.Confirmation(message, NotifyDescriptor.YES_NO_OPTION); + Object choice = DialogDisplayer.getDefault().notify(msg); + return choice == NotifyDescriptor.YES_OPTION || choice == NotifyDescriptor.OK_OPTION; + } + + public static void showErrorMessage(String message) { + StringBuilder sb = new StringBuilder("Error\n"); + sb.append(message); + showMessage(sb.toString()); Review Comment: if the msg is intended to be presented as an error, then `new NotifyDescriptor.Message(message, NotifyDescriptor.ERROR_MESSAGE)` should be used -- will affect the presentation. ########## enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/OCINode.java: ########## @@ -111,15 +112,21 @@ public static final List<? extends Action> actionsForPath(String path, Lookup lk } public void refresh() { - if (factory != null) { - factory.refreshKeys(); - } - update(item); + RequestProcessor.getDefault().post(() -> { Review Comment: Note: the default RP (see the documentation for getDefault()) has a guard against 'too often scheduled task'. Not sure if "refresh" on a parent node (that contains children) refreshes the entire subtree one by one - that may cause the guard to trigger & print some annoying messages into the log. If the refresh only affects a single node, it's fine. ########## enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/vault/SecretNode.java: ########## @@ -18,36 +18,162 @@ */ package org.netbeans.modules.cloud.oracle.vault; -import com.oracle.bmc.keymanagement.KmsVaultClient; import com.oracle.bmc.vault.VaultsClient; +import com.oracle.bmc.vault.model.ScheduleSecretDeletionDetails; +import com.oracle.bmc.vault.model.Secret; +import com.oracle.bmc.vault.model.SecretSummary.LifecycleState; +import com.oracle.bmc.vault.requests.GetSecretRequest; import com.oracle.bmc.vault.requests.ListSecretsRequest; +import com.oracle.bmc.vault.requests.ScheduleSecretDeletionRequest; +import com.oracle.bmc.vault.responses.GetSecretResponse; +import com.oracle.bmc.vault.responses.ScheduleSecretDeletionResponse; +import java.io.IOException; +import java.text.SimpleDateFormat; +import java.time.LocalDateTime; +import java.time.ZoneId; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.List; import java.util.stream.Collectors; +import javax.swing.Action; import org.netbeans.modules.cloud.oracle.ChildrenProvider; import org.netbeans.modules.cloud.oracle.NodeProvider; -import static org.netbeans.modules.cloud.oracle.OCIManager.getDefault; +import static org.netbeans.modules.cloud.oracle.NotificationUtils.confirmAction; +import static org.netbeans.modules.cloud.oracle.NotificationUtils.showErrorMessage; +import static org.netbeans.modules.cloud.oracle.NotificationUtils.showMessage; +import org.netbeans.modules.cloud.oracle.OCIManager; import org.netbeans.modules.cloud.oracle.OCINode; import org.netbeans.modules.cloud.oracle.items.OCID; +import org.netbeans.modules.cloud.oracle.items.OCIItem; +import org.openide.actions.DeleteAction; import org.openide.nodes.Children; +import org.openide.util.NbBundle; +import org.openide.util.RequestProcessor; +import org.openide.util.actions.SystemAction; /** * * @author Jan Horvath */ [email protected]({ + "SecretNodeDesc=Valut Secret: {0}\nLifecycle State: {1}{2}", + "# {0} - [OCIItem name]", + "MSG_ConfirmDeleteAction=Are you sure that you want to schedule deletion of {0}", + "# {0} - [OCIItem name]", + "MSG_DeleteActionFailed=Failed to schedule deletion of {0}.", + "# {0} - [OCIItem name]", "# {1} - [Scheduled deletion time]", + "MSG_DeleteActionSuccess=Successfully scheduled deletion of {0} at {1}." +}) public class SecretNode extends OCINode { private static final String SECRET_ICON = "org/netbeans/modules/cloud/oracle/resources/secret.svg"; // NOI18N + private static final SimpleDateFormat DELETION_TIME_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); public SecretNode(SecretItem vault) { super(vault, Children.LEAF); setName(vault.getName()); setDisplayName(vault.getName()); setIconBaseWithExtension(SECRET_ICON); - setShortDescription(vault.getDescription()); + setShortDescription( + createShortDescription( + vault.getLifecycleState(), + vault.getDeletionTime())); + } + + private String createShortDescription(String state, Date deletionTime) { + if (deletionTime != null) { + return Bundle.SecretNodeDesc(this.getItem().getName(), state, getDeletionTimeInfo(deletionTime)); + } + return Bundle.SecretNodeDesc(this.getItem().getName(), state, ""); + } + + private String getDeletionTimeInfo(Date deletionTime) { + return "\nDeletion time: " + DELETION_TIME_FORMAT.format(deletionTime); Review Comment: This decoration ought to be in a bundle. Pls. create 2 bundle keys, one normal, the other for deleted items. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected] For further information about the NetBeans mailing lists, visit: https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
