Autopsy  3.1
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-2014 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 
20 package org.sleuthkit.autopsy.casemodule;
21 
22 import java.awt.Component;
23 import java.awt.EventQueue;
24 import java.awt.event.ActionEvent;
25 import java.awt.event.ActionListener;
26 import java.util.logging.Level;import org.sleuthkit.autopsy.coreutils.Logger;
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;
34 ;
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;
51 
56  final class CaseCloseAction extends CallableSystemAction implements Presenter.Toolbar{
57 
58  JButton toolbarButton = new JButton();
59 
63  public CaseCloseAction() {
64  putValue("iconBase", "org/sleuthkit/autopsy/images/close-icon.png"); // put the icon NON-NLS
65  putValue(Action.NAME, NbBundle.getMessage(CaseCloseAction.class, "CTL_CaseCloseAct")); // put the action Name
66 
67  // set action of the toolbar button
68  toolbarButton.addActionListener(new ActionListener() {
69 
70  @Override
71  public void actionPerformed(ActionEvent e) {
72  CaseCloseAction.this.actionPerformed(e);
73  }
74  });
75 
76  this.setEnabled(false);
77  }
78 
84  @Override
85  public void actionPerformed(ActionEvent e) {
86  if (Case.existsCurrentCase() == false)
87  return;
88 
89  Case result = Case.getCurrentCase();
90  try {
91  result.closeCase();
92  EventQueue.invokeLater(new Runnable() {
93  @Override
94  public void run() {
95  StartupWindowProvider.getInstance().open();
96  }
97  });
98  } catch (Exception ex) {
99  Logger.getLogger(CaseCloseAction.class.getName()).log(Level.WARNING, "Error closing case.", ex); //NON-NLS
100  }
101  }
102 
106  @Override
107  public void performAction() {
108  }
109 
115  @Override
116  public String getName() {
117  return NbBundle.getMessage(CaseCloseAction.class, "CTL_CaseCloseAct");
118  }
119 
125  @Override
126  public HelpCtx getHelpCtx() {
127  return HelpCtx.DEFAULT_HELP;
128  }
129 
135  @Override
136  public Component getToolbarPresenter() {
137  ImageIcon icon = new ImageIcon(getClass().getResource("btn_icon_close_case.png")); //NON-NLS
138  toolbarButton.setIcon(icon);
139  toolbarButton.setText(this.getName());
140  return toolbarButton;
141  }
142 
148  @Override
149  public void setEnabled(boolean value){
150  super.setEnabled(value);
151  toolbarButton.setEnabled(value);
152  }
153 }

Copyright © 2012-2015 Basis Technology. Generated on: Mon Oct 19 2015
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.