From 8d08feac18bc8c7a54ec84527108bfe3dd22d895 Mon Sep 17 00:00:00 2001 From: momo Date: Thu, 16 Jul 2015 12:40:36 -0400 Subject: [PATCH 1/2] adding confirm message before closing case --- .../autopsy/casemodule/CaseCloseAction.java | 23 +++++-------------- .../autopsy/coreutils/MessageNotifyUtil.java | 22 ++++++++++++++++-- 2 files changed, 26 insertions(+), 19 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/CaseCloseAction.java b/Core/src/org/sleuthkit/autopsy/casemodule/CaseCloseAction.java index 900a355bf0..29dfdeda09 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/CaseCloseAction.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/CaseCloseAction.java @@ -23,24 +23,9 @@ import java.awt.Component; import java.awt.EventQueue; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; -import java.util.logging.Level;import org.sleuthkit.autopsy.coreutils.Logger; -import javax.swing.Action; -import javax.swing.ImageIcon; -import javax.swing.JButton; -import org.openide.util.HelpCtx; -import org.openide.util.NbBundle; -import org.openide.util.actions.CallableSystemAction; -import org.openide.util.actions.Presenter; -; -import org.sleuthkit.autopsy.coreutils.Logger; -import javax.swing.Action; -import javax.swing.ImageIcon; -import javax.swing.JButton; -import org.openide.util.HelpCtx; -import org.openide.util.NbBundle; -import org.openide.util.actions.CallableSystemAction; -import org.openide.util.actions.Presenter; +import java.util.logging.Level; import org.sleuthkit.autopsy.coreutils.Logger; +import org.sleuthkit.autopsy.coreutils.MessageNotifyUtil; import javax.swing.Action; import javax.swing.ImageIcon; import javax.swing.JButton; @@ -87,6 +72,10 @@ import org.openide.util.actions.Presenter; return; Case result = Case.getCurrentCase(); + + if(!MessageNotifyUtil.Message.confirm("Are you sure you want to close current case?")) + return; + try { result.closeCase(); EventQueue.invokeLater(new Runnable() { diff --git a/Core/src/org/sleuthkit/autopsy/coreutils/MessageNotifyUtil.java b/Core/src/org/sleuthkit/autopsy/coreutils/MessageNotifyUtil.java index 498115f310..4380cdd422 100644 --- a/Core/src/org/sleuthkit/autopsy/coreutils/MessageNotifyUtil.java +++ b/Core/src/org/sleuthkit/autopsy/coreutils/MessageNotifyUtil.java @@ -53,7 +53,9 @@ public class MessageNotifyUtil { INFO(NotifyDescriptor.INFORMATION_MESSAGE, "info-icon-16.png"), //NON-NLS ERROR(NotifyDescriptor.ERROR_MESSAGE, "error-icon-16.png"), //NON-NLS - WARNING(NotifyDescriptor.WARNING_MESSAGE, "warning-icon-16.png"); //NON-NLS + WARNING(NotifyDescriptor.WARNING_MESSAGE, "warning-icon-16.png"), //NON-NLS + CONFIRM(NotifyDescriptor.YES_NO_OPTION, "warning-icon-16.png"); //NON-NLS + private final int notifyDescriptorType; private final Icon icon; @@ -110,6 +112,17 @@ public class MessageNotifyUtil { getDialogDisplayer().notify(new NotifyDescriptor.Message(message, messageType.getNotifyDescriptorType())); } + + /** + * Show an confirm dialog + * + * @param message message to show + * @return true if yes is clicked + */ + public static boolean confirm(String message) { + return getDialogDisplayer().notify(new NotifyDescriptor.Confirmation(message, + MessageType.CONFIRM.getNotifyDescriptorType())) == NotifyDescriptor.YES_OPTION; + } /** * Show an information dialog @@ -123,7 +136,7 @@ public class MessageNotifyUtil { /** * Show an error dialog * - * @param message message to shpw + * @param message message to show */ public static void error(String message) { show(message, MessageType.ERROR); @@ -137,6 +150,7 @@ public class MessageNotifyUtil { public static void warn(String message) { show(message, MessageType.WARNING); } + } /** @@ -164,6 +178,10 @@ public class MessageNotifyUtil { /** * Show message with the specified type and action listener + * @param title message title + * @param message message text + * @param type type of the message + * @param actionListener action listener */ public static void show(String title, String message, MessageType type, ActionListener actionListener) { Notification newNotification From 8d03d36615558d158893bd25e8cd959d59970322 Mon Sep 17 00:00:00 2001 From: momo Date: Thu, 16 Jul 2015 12:53:56 -0400 Subject: [PATCH 2/2] clarify comment --- Core/src/org/sleuthkit/autopsy/coreutils/MessageNotifyUtil.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Core/src/org/sleuthkit/autopsy/coreutils/MessageNotifyUtil.java b/Core/src/org/sleuthkit/autopsy/coreutils/MessageNotifyUtil.java index 4380cdd422..22d7b930e6 100644 --- a/Core/src/org/sleuthkit/autopsy/coreutils/MessageNotifyUtil.java +++ b/Core/src/org/sleuthkit/autopsy/coreutils/MessageNotifyUtil.java @@ -114,7 +114,7 @@ public class MessageNotifyUtil { } /** - * Show an confirm dialog + * Show an confirm, yes-no dialog * * @param message message to show * @return true if yes is clicked