19 package org.sleuthkit.autopsy.casemodule;
21 import java.awt.Component;
22 import java.awt.Dialog;
23 import java.awt.Dimension;
24 import java.awt.event.ActionEvent;
25 import java.awt.event.ActionListener;
26 import java.text.MessageFormat;
27 import java.util.logging.Level;
28 import javax.swing.Action;
29 import javax.swing.ImageIcon;
30 import javax.swing.JButton;
31 import javax.swing.JOptionPane;
32 import javax.swing.SwingUtilities;
33 import javax.swing.event.ChangeEvent;
34 import javax.swing.event.ChangeListener;
35 import org.openide.DialogDisplayer;
36 import org.openide.WizardDescriptor;
37 import org.openide.awt.ActionID;
38 import org.openide.awt.ActionReference;
39 import org.openide.awt.ActionReferences;
40 import org.openide.awt.ActionRegistration;
41 import org.openide.util.ChangeSupport;
42 import org.openide.util.HelpCtx;
43 import org.openide.util.NbBundle;
44 import org.openide.util.actions.CallableSystemAction;
45 import org.openide.util.actions.Presenter;
46 import org.openide.util.lookup.ServiceProvider;
60 @ActionID(category =
"Tools",
id =
"org.sleuthkit.autopsy.casemodule.AddImageAction")
61 @ActionRegistration(displayName =
"#CTL_AddImage", lazy =
false)
62 @ActionReferences(value = {
63 @ActionReference(path =
"Toolbars/Case", position = 100)})
65 public final class
AddImageAction extends CallableSystemAction implements Presenter.Toolbar {
70 static final String TIMEZONE_PROP =
"timeZone";
72 static final String DATASOURCEPATH_PROP =
"dataSrcPath";
74 static final String DATASOURCETYPE_PROP =
"dataSrcType";
76 static final String IMAGECLEANUPTASK_PROP =
"finalFileCleanup";
78 static final String IMAGEID_PROP =
"imageId";
80 static final String PROCESS_PROP =
"process";
82 static final String LOOKUPFILES_PROP =
"lookupFiles";
84 static final String NOFATORPHANS_PROP =
"nofatorphans";
87 static final Dimension SIZE =
new Dimension(875, 550);
90 private WizardDescriptor.Iterator<WizardDescriptor>
iterator;
92 private JButton toolbarButton =
new JButton();
98 putValue(Action.NAME, NbBundle.getMessage(
AddImageAction.class,
"CTL_AddImage"));
101 toolbarButton.addActionListener(
new ActionListener() {
104 public void actionPerformed(ActionEvent e) {
109 this.setEnabled(
false);
120 final String msg = NbBundle.getMessage(this.getClass(),
"AddImageAction.ingestConfig.ongoingIngest.msg");
121 if (JOptionPane.showConfirmDialog(null, msg,
122 NbBundle.getMessage(
this.getClass(),
123 "AddImageAction.ingestConfig.ongoingIngest.title"),
124 JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE) == JOptionPane.NO_OPTION) {
129 iterator =
new AddImageWizardIterator(
this);
130 wizardDescriptor =
new WizardDescriptor(iterator);
131 wizardDescriptor.setTitle(NbBundle.getMessage(
this.getClass(),
"AddImageAction.wizard.title"));
132 wizardDescriptor.putProperty(NAME, e);
133 wizardDescriptor.setTitleFormat(
new MessageFormat(
"{0}"));
135 if (dialog != null) {
136 dialog.setVisible(
false);
138 dialog = DialogDisplayer.getDefault().createDialog(wizardDescriptor);
139 Dimension d = dialog.getSize();
140 dialog.setSize(SIZE);
141 dialog.setVisible(
true);
155 wizardDescriptor.setValue(WizardDescriptor.FINISH_OPTION);
156 dialog.setVisible(
false);
160 final Runnable r =
new Runnable() {
163 actionPerformed(null);
167 SwingUtilities.invokeLater(r);
172 void runTask(Image newImage);
190 return NbBundle.getMessage(
AddImageAction.class,
"CTL_AddImageButton");
200 return HelpCtx.DEFAULT_HELP;
210 ImageIcon icon =
new ImageIcon(getClass().getResource(
"btn_icon_add_image.png"));
211 toolbarButton.setIcon(icon);
212 toolbarButton.setText(this.getName());
213 return toolbarButton;
223 super.setEnabled(value);
224 toolbarButton.setEnabled(value);
238 Object[] wizardButtons = wizardDescriptor.getOptions();
239 for (
int i = 0; i < wizardButtons.length; i++) {
240 JButton tempButton = (JButton) wizardButtons[i];
241 if (tempButton.getText().equals(buttonText)) {
242 tempButton.setDefaultCapable(
true);
243 tempButton.requestFocus();
254 cleanupSupport.fireChange();
257 ChangeSupport cleanupSupport =
new ChangeSupport(
this);
268 abstract class CleanupTask
implements ChangeListener {
271 public void stateChanged(ChangeEvent e) {
275 }
catch (Exception ex) {
276 Logger logger = Logger.
getLogger(this.getClass().getName());
277 logger.log(Level.WARNING,
"Error cleaning up from wizard.", ex);
286 public void enable() {
287 cleanupSupport.addChangeListener(
this);
295 abstract void cleanup() throws Exception;
300 public
void disable() {
301 cleanupSupport.removeChangeListener(
this);
static synchronized IngestManager getInstance()
Component getToolbarPresenter()
WizardDescriptor wizardDescriptor
void setEnabled(boolean value)
boolean isIngestRunning()
void actionPerformed(ActionEvent e)
synchronized static Logger getLogger(String name)
void requestFocusButton(String buttonText)
WizardDescriptor.Iterator< WizardDescriptor > iterator