Autopsy  4.14.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
ExitAction.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2011-2017 Basis Technology Corp.
5  * Contact: carrier <at> sleuthkit <dot> org
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */
19 package org.sleuthkit.autopsy.actions;
20 
21 import java.awt.Cursor;
22 import java.awt.event.ActionEvent;
23 import java.awt.event.ActionListener;
24 import java.util.concurrent.ExecutionException;
25 import java.util.logging.Level;
26 import javax.swing.SwingWorker;
27 import org.openide.LifecycleManager;
28 import org.openide.awt.ActionID;
29 import org.openide.awt.ActionReference;
30 import org.openide.awt.ActionRegistration;
31 import org.openide.util.NbBundle;
32 import org.openide.windows.WindowManager;
38 
43 @ActionRegistration(displayName = "Exit", iconInMenu = true)
44 @ActionReference(path = "Menu/Case", position = 1000, separatorBefore = 999)
45 @ActionID(id = "org.sleuthkit.autopsy.casemodule.ExitAction", category = "Case")
46 final public class ExitAction implements ActionListener {
47 
48  private static final Logger logger = Logger.getLogger(ExitAction.class.getName());
49 
50  @NbBundle.Messages({
51  "ExitAction.confirmationDialog.title=Ingest is Running",
52  "ExitAction.confirmationDialog.message=Ingest is running, are you sure you want to exit?",
53  "# {0} - exception message", "ExitAction.messageBox.caseCloseExceptionMessage=Error closing case: {0}"
54  })
55  @Override
56  public void actionPerformed(ActionEvent e) {
57  if (IngestRunningCheck.checkAndConfirmProceed(Bundle.ExitAction_confirmationDialog_title(), Bundle.ExitAction_confirmationDialog_message())) {
58  WindowManager.getDefault().getMainWindow().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
59  new SwingWorker<Void, Void>() {
60 
61  @Override
62  protected Void doInBackground() throws Exception {
64  return null;
65  }
66 
67  @Override
68  protected void done() {
69  try {
70  get();
71  } catch (InterruptedException ex) {
72  logger.log(Level.SEVERE, "Unexpected interrupt closing the current case", ex);
73  } catch (ExecutionException ex) {
74  logger.log(Level.SEVERE, "Error closing the current case", ex);
75  MessageNotifyUtil.Message.error(Bundle.ExitAction_messageBox_caseCloseExceptionMessage(ex.getMessage()));
76  } finally {
77  WindowManager.getDefault().getMainWindow().setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
78  LifecycleManager.getDefault().exit();
79  }
80  }
81  }.execute();
82  }
83  }
84 }
static boolean checkAndConfirmProceed(String optionsDlgTitle, String optionsDlgMessage)
synchronized static Logger getLogger(String name)
Definition: Logger.java:124

Copyright © 2012-2020 Basis Technology. Generated on: Wed Apr 8 2020
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.