Merge pull request #1437 from mhmdfy/aut-1699-close-confirmation

Aut 1699 close confirmation
This commit is contained in:
Richard Cordovano 2015-07-24 13:23:51 -04:00
commit 549653872d
2 changed files with 26 additions and 19 deletions

View File

@ -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() {

View File

@ -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, yes-no 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