19 package org.sleuthkit.autopsy.casemodule;
21 import java.awt.Component;
22 import java.awt.Dialog;
23 import java.awt.event.ActionEvent;
24 import java.awt.event.ActionListener;
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.JOptionPane;
30 import javax.swing.SwingUtilities;
31 import javax.swing.event.ChangeEvent;
32 import javax.swing.event.ChangeListener;
33 import org.openide.DialogDisplayer;
34 import org.openide.WizardDescriptor;
35 import org.openide.util.ChangeSupport;
36 import org.openide.util.HelpCtx;
37 import org.openide.util.NbBundle;
38 import org.openide.util.actions.CallableSystemAction;
39 import org.openide.util.actions.Presenter;
40 import org.openide.util.lookup.ServiceProvider;
55 public final class
AddImageAction extends CallableSystemAction implements Presenter.Toolbar {
60 static final String TIMEZONE_PROP =
"timeZone";
62 static final String DATASOURCEPATH_PROP =
"dataSrcPath";
64 static final String DATASOURCETYPE_PROP =
"dataSrcType";
66 static final String IMAGECLEANUPTASK_PROP =
"finalFileCleanup";
68 static final String IMAGEID_PROP =
"imageId";
70 static final String PROCESS_PROP =
"process";
72 static final String LOOKUPFILES_PROP =
"lookupFiles";
74 static final String NOFATORPHANS_PROP =
"nofatorphans";
79 private WizardDescriptor.Iterator<WizardDescriptor>
iterator;
81 private JButton toolbarButton =
new JButton();
87 putValue(Action.NAME, NbBundle.getMessage(
AddImageAction.class,
"CTL_AddImage"));
90 toolbarButton.addActionListener(
new ActionListener() {
93 public void actionPerformed(ActionEvent e) {
98 this.setEnabled(
false);
109 final String msg = NbBundle.getMessage(this.getClass(),
"AddImageAction.ingestConfig.ongoingIngest.msg");
110 if (JOptionPane.showConfirmDialog(null, msg,
111 NbBundle.getMessage(
this.getClass(),
112 "AddImageAction.ingestConfig.ongoingIngest.title"),
113 JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE) == JOptionPane.NO_OPTION) {
118 iterator =
new AddImageWizardIterator(
this);
119 wizardDescriptor =
new WizardDescriptor(iterator);
120 wizardDescriptor.setTitle(NbBundle.getMessage(
this.getClass(),
"AddImageAction.wizard.title"));
121 wizardDescriptor.putProperty(NAME, e);
123 if (dialog != null) {
124 dialog.setVisible(
false);
126 dialog = DialogDisplayer.getDefault().createDialog(wizardDescriptor);
127 dialog.setVisible(
true);
141 wizardDescriptor.setValue(WizardDescriptor.FINISH_OPTION);
142 dialog.setVisible(
false);
146 final Runnable r =
new Runnable() {
149 actionPerformed(null);
153 SwingUtilities.invokeLater(r);
158 void runTask(Image newImage);
176 return NbBundle.getMessage(
AddImageAction.class,
"CTL_AddImageButton");
186 return HelpCtx.DEFAULT_HELP;
196 ImageIcon icon =
new ImageIcon(getClass().getResource(
"btn_icon_add_image.png"));
197 toolbarButton.setIcon(icon);
198 toolbarButton.setText(this.getName());
199 return toolbarButton;
209 super.setEnabled(value);
210 toolbarButton.setEnabled(value);
224 Object[] wizardButtons = wizardDescriptor.getOptions();
225 for (
int i = 0; i < wizardButtons.length; i++) {
226 JButton tempButton = (JButton) wizardButtons[i];
227 if (tempButton.getText().equals(buttonText)) {
228 tempButton.setDefaultCapable(
true);
229 tempButton.requestFocus();
240 cleanupSupport.fireChange();
243 ChangeSupport cleanupSupport =
new ChangeSupport(
this);
254 abstract class CleanupTask
implements ChangeListener {
257 public void stateChanged(ChangeEvent e) {
261 }
catch (Exception ex) {
262 Logger logger = Logger.
getLogger(this.getClass().getName());
263 logger.log(Level.WARNING,
"Error cleaning up from wizard.", ex);
272 public void enable() {
273 cleanupSupport.addChangeListener(
this);
281 abstract void cleanup() throws Exception;
286 public
void disable() {
287 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