20 package org.sleuthkit.autopsy.casemodule;
22 import java.awt.Component;
23 import java.awt.EventQueue;
24 import java.awt.event.ActionEvent;
25 import java.awt.event.ActionListener;
27 import javax.swing.Action;
28 import javax.swing.ImageIcon;
29 import javax.swing.JButton;
30 import org.openide.util.HelpCtx;
31 import org.openide.util.NbBundle;
32 import org.openide.util.actions.CallableSystemAction;
33 import org.openide.util.actions.Presenter;
36 import javax.swing.Action;
37 import javax.swing.ImageIcon;
38 import javax.swing.JButton;
39 import org.openide.util.HelpCtx;
40 import org.openide.util.NbBundle;
41 import org.openide.util.actions.CallableSystemAction;
42 import org.openide.util.actions.Presenter;
44 import javax.swing.Action;
45 import javax.swing.ImageIcon;
46 import javax.swing.JButton;
47 import org.openide.util.HelpCtx;
48 import org.openide.util.NbBundle;
49 import org.openide.util.actions.CallableSystemAction;
50 import org.openide.util.actions.Presenter;
56 final class CaseCloseAction
extends CallableSystemAction implements Presenter.Toolbar{
58 JButton toolbarButton =
new JButton();
63 public CaseCloseAction() {
64 putValue(
"iconBase",
"org/sleuthkit/autopsy/images/close-icon.png");
65 putValue(Action.NAME, NbBundle.getMessage(CaseCloseAction.class,
"CTL_CaseCloseAct"));
68 toolbarButton.addActionListener(
new ActionListener() {
71 public void actionPerformed(ActionEvent e) {
72 CaseCloseAction.this.actionPerformed(e);
76 this.setEnabled(
false);
85 public void actionPerformed(ActionEvent e) {
86 if (Case.existsCurrentCase() ==
false)
89 Case result = Case.getCurrentCase();
92 EventQueue.invokeLater(
new Runnable() {
95 StartupWindowProvider.getInstance().open();
98 }
catch (Exception ex) {
99 Logger.getLogger(CaseCloseAction.class.getName()).log(Level.WARNING,
"Error closing case.", ex);
107 public void performAction() {
116 public String getName() {
117 return NbBundle.getMessage(CaseCloseAction.class,
"CTL_CaseCloseAct");
126 public HelpCtx getHelpCtx() {
127 return HelpCtx.DEFAULT_HELP;
136 public Component getToolbarPresenter() {
137 ImageIcon icon =
new ImageIcon(getClass().getResource(
"btn_icon_close_case.png"));
138 toolbarButton.setIcon(icon);
139 toolbarButton.setText(this.getName());
140 return toolbarButton;
149 public void setEnabled(
boolean value){
150 super.setEnabled(value);
151 toolbarButton.setEnabled(value);