Autopsy  4.19.3
Graphical digital forensics platform for The Sleuth Kit and other tools.
CaseCloseAction.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2011-2019 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.casemodule;
20 
21 import java.awt.Component;
22 import java.awt.Cursor;
23 import java.awt.event.ActionEvent;
24 import java.util.concurrent.ExecutionException;
25 import java.util.logging.Level;
26 import javax.swing.Action;
27 import javax.swing.ImageIcon;
28 import javax.swing.JButton;
29 import javax.swing.SwingWorker;
30 import org.openide.awt.ActionID;
31 import org.openide.awt.ActionReference;
32 import org.openide.awt.ActionReferences;
33 import org.openide.awt.ActionRegistration;
34 import org.openide.util.HelpCtx;
35 import org.openide.util.NbBundle;
36 import org.openide.util.actions.CallableSystemAction;
37 import org.openide.util.actions.Presenter;
38 import org.openide.windows.WindowManager;
42 
50 @ActionID(category = "Tools", id = "org.sleuthkit.autopsy.casemodule.CaseCloseAction")
51 @ActionRegistration(displayName = "#CTL_CaseCloseAct", lazy = false)
52 @ActionReferences(value = {
53  @ActionReference(path = "Toolbars/Case", position = 107)})
54 public final class CaseCloseAction extends CallableSystemAction implements Presenter.Toolbar {
55 
56  private static final long serialVersionUID = 1L;
57  private static final Logger logger = Logger.getLogger(CaseCloseAction.class.getName());
58  private final JButton toolbarButton = new JButton();
59 
64  public CaseCloseAction() {
65  putValue("iconBase", "org/sleuthkit/autopsy/images/close-icon.png"); //NON-NLS
66  putValue(Action.NAME, NbBundle.getMessage(CaseCloseAction.class, "CTL_CaseCloseAct")); //NON-NLS
67  toolbarButton.addActionListener(CaseCloseAction.this::actionPerformed);
68  this.setEnabled(false);
69  }
70 
76  @Override
77  public void actionPerformed(ActionEvent e) {
78  String optionsDlgTitle = NbBundle.getMessage(Case.class, "CloseCaseWhileIngesting.Warning.title");
79  String optionsDlgMessage = NbBundle.getMessage(Case.class, "CloseCaseWhileIngesting.Warning");
80  if (IngestRunningCheck.checkAndConfirmProceed(optionsDlgTitle, optionsDlgMessage)) {
81  WindowManager.getDefault().getMainWindow().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
82  new SwingWorker<Void, Void>() {
83 
84  @Override
85  protected Void doInBackground() throws Exception {
87  return null;
88  }
89 
90  @Override
91  protected void done() {
92  try {
93  get();
94  } catch (InterruptedException ex) {
95  logger.log(Level.SEVERE, "Unexpected interrupt closing the current case", ex);
96  } catch (ExecutionException ex) {
97  logger.log(Level.SEVERE, "Error closing the current case", ex);
98  MessageNotifyUtil.Message.error(Bundle.Case_closeException_couldNotCloseCase(ex.getMessage()));
99  }
100  WindowManager.getDefault().getMainWindow().setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
102  }
103  }.execute();
104  }
105  }
106 
110  @Override
111  public void performAction() {
112  actionPerformed(null);
113  }
114 
120  @Override
121  public String getName() {
122  return NbBundle.getMessage(CaseCloseAction.class, "CTL_CaseCloseAct");
123  }
124 
130  @Override
131  public HelpCtx getHelpCtx() {
132  return HelpCtx.DEFAULT_HELP;
133  }
134 
140  @Override
141  public Component getToolbarPresenter() {
142  ImageIcon icon = new ImageIcon(getClass().getResource("btn_icon_close_case.png")); //NON-NLS
143  toolbarButton.setIcon(icon);
144  toolbarButton.setText(this.getName());
145  return toolbarButton;
146  }
147 
153  @Override
154  public void setEnabled(boolean value) {
155  super.setEnabled(value);
156  toolbarButton.setEnabled(value);
157  }
158 }
static boolean checkAndConfirmProceed(String optionsDlgTitle, String optionsDlgMessage)
synchronized static Logger getLogger(String name)
Definition: Logger.java:124

Copyright © 2012-2022 Basis Technology. Generated on: Tue Jun 27 2023
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.