19 package org.sleuthkit.autopsy.casemodule;
21 import java.awt.Component;
22 import java.awt.Cursor;
23 import java.awt.Dialog;
24 import java.awt.Dimension;
25 import java.awt.event.ActionEvent;
26 import java.awt.event.ActionListener;
27 import java.text.MessageFormat;
28 import java.util.logging.Level;
29 import javax.swing.Action;
30 import javax.swing.ImageIcon;
31 import javax.swing.JButton;
32 import javax.swing.RootPaneContainer;
33 import javax.swing.SwingUtilities;
34 import javax.swing.event.ChangeEvent;
35 import javax.swing.event.ChangeListener;
36 import org.openide.DialogDisplayer;
37 import org.openide.WizardDescriptor;
38 import org.openide.awt.ActionID;
39 import org.openide.awt.ActionReference;
40 import org.openide.awt.ActionReferences;
41 import org.openide.awt.ActionRegistration;
42 import org.openide.util.ChangeSupport;
43 import org.openide.util.HelpCtx;
44 import org.openide.util.NbBundle;
45 import org.openide.util.actions.CallableSystemAction;
46 import org.openide.util.actions.Presenter;
47 import org.openide.util.lookup.ServiceProvider;
48 import org.openide.windows.WindowManager;
58 @ActionID(category =
"Tools",
id =
"org.sleuthkit.autopsy.casemodule.AddImageAction")
59 @ActionRegistration(displayName =
"#CTL_AddImage", lazy =
false)
60 @ActionReferences(value = {
61 @ActionReference(path =
"Toolbars/Case", position = 100)})
63 public final class
AddImageAction extends CallableSystemAction implements Presenter.Toolbar {
65 private static final long serialVersionUID = 1L;
66 private static final Dimension SIZE =
new Dimension(875, 550);
67 private final ChangeSupport cleanupSupport =
new ChangeSupport(
this);
73 static final String TIMEZONE_PROP =
"timeZone";
75 static final String DATASOURCEPATH_PROP =
"dataSrcPath";
77 static final String DATASOURCETYPE_PROP =
"dataSrcType";
79 static final String IMAGECLEANUPTASK_PROP =
"finalFileCleanup";
81 static final String IMAGEID_PROP =
"imageId";
83 static final String PROCESS_PROP =
"process";
85 static final String LOOKUPFILES_PROP =
"lookupFiles";
87 static final String NOFATORPHANS_PROP =
"nofatorphans";
91 private WizardDescriptor.Iterator<WizardDescriptor>
iterator;
93 private final JButton toolbarButton =
new JButton();
99 putValue(Action.NAME, NbBundle.getMessage(
AddImageAction.class,
"CTL_AddImage"));
102 toolbarButton.addActionListener(
new ActionListener() {
105 public void actionPerformed(ActionEvent e) {
114 this.setEnabled(
false);
119 String optionsDlgTitle = NbBundle.getMessage(this.getClass(),
"AddImageAction.ingestConfig.ongoingIngest.title");
120 String optionsDlgMessage = NbBundle.getMessage(this.getClass(),
"AddImageAction.ingestConfig.ongoingIngest.msg");
122 RootPaneContainer root = (RootPaneContainer) WindowManager.getDefault().getMainWindow();
123 root.getGlassPane().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
124 root.getGlassPane().setVisible(
true);
125 WindowManager.getDefault().getMainWindow().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
126 iterator =
new AddImageWizardIterator(
this);
127 wizardDescriptor =
new WizardDescriptor(iterator);
128 wizardDescriptor.setTitle(NbBundle.getMessage(
this.getClass(),
"AddImageAction.wizard.title"));
129 wizardDescriptor.putProperty(NAME, e);
130 wizardDescriptor.setTitleFormat(
new MessageFormat(
"{0}"));
132 if (dialog != null) {
133 dialog.setVisible(
false);
135 dialog = DialogDisplayer.getDefault().createDialog(wizardDescriptor);
136 Dimension d = dialog.getSize();
137 dialog.setSize(SIZE);
138 root.getGlassPane().setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
139 root.getGlassPane().setVisible(
false);
140 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);
177 actionPerformed(null);
187 return NbBundle.getMessage(
AddImageAction.class,
"CTL_AddImageButton");
197 return HelpCtx.DEFAULT_HELP;
207 ImageIcon icon =
new ImageIcon(getClass().getResource(
"btn_icon_add_image.png"));
208 toolbarButton.setIcon(icon);
209 toolbarButton.setText(this.getName());
210 return toolbarButton;
220 super.setEnabled(value);
221 toolbarButton.setEnabled(value);
235 Object[] wizardButtons = wizardDescriptor.getOptions();
236 for (Object wizardButton : wizardButtons) {
237 JButton tempButton = (JButton) wizardButton;
238 if (tempButton.getText().equals(buttonText)) {
239 tempButton.setDefaultCapable(
true);
240 tempButton.requestFocus();
251 cleanupSupport.fireChange();
263 abstract class CleanupTask
implements ChangeListener {
266 public void stateChanged(ChangeEvent e) {
270 }
catch (Exception ex) {
271 Logger logger = Logger.
getLogger(this.getClass().getName());
272 logger.log(Level.WARNING,
"Error cleaning up from wizard.", ex);
281 public void enable() {
282 cleanupSupport.addChangeListener(
this);
290 abstract void cleanup() throws Exception;
295 public
void disable() {
296 cleanupSupport.removeChangeListener(
this);
Component getToolbarPresenter()
WizardDescriptor wizardDescriptor
static boolean checkAndConfirmProceed(String optionsDlgTitle, String optionsDlgMessage)
void setEnabled(boolean value)
void actionPerformed(ActionEvent e)
synchronized static Logger getLogger(String name)
void requestFocusButton(String buttonText)
WizardDescriptor.Iterator< WizardDescriptor > iterator