20 package org.sleuthkit.autopsy.casemodule;
 
   22 import java.awt.Component;
 
   23 import java.awt.Dialog;
 
   24 import java.awt.event.ActionEvent;
 
   25 import java.awt.event.ActionListener;
 
   26 import java.util.logging.Level;
 
   27 import javax.swing.Action;
 
   28 import javax.swing.ImageIcon;
 
   29 import javax.swing.JButton;
 
   30 import javax.swing.JOptionPane;
 
   31 import javax.swing.SwingUtilities;
 
   32 import javax.swing.event.ChangeEvent;
 
   33 import javax.swing.event.ChangeListener;
 
   34 import org.openide.DialogDisplayer;
 
   35 import org.openide.WizardDescriptor;
 
   36 import org.openide.util.ChangeSupport;
 
   37 import org.openide.util.HelpCtx;
 
   38 import org.openide.util.NbBundle;
 
   39 import org.openide.util.actions.CallableSystemAction;
 
   40 import org.openide.util.actions.Presenter;
 
   41 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"; 
 
   80     private WizardDescriptor.Iterator<WizardDescriptor> 
iterator;
 
   82     private JButton toolbarButton = 
new JButton();
 
   88         putValue(Action.NAME, NbBundle.getMessage(
AddImageAction.class, 
"CTL_AddImage")); 
 
   91         toolbarButton.addActionListener(
new ActionListener() {
 
   94             public void actionPerformed(ActionEvent e) {
 
   99         this.setEnabled(
false); 
 
  110             final String msg = NbBundle.getMessage(this.getClass(), 
"AddImageAction.ingestConfig.ongoingIngest.msg");
 
  111             if (JOptionPane.showConfirmDialog(null, msg,
 
  112                                               NbBundle.getMessage(
this.getClass(),
 
  113                                                                   "AddImageAction.ingestConfig.ongoingIngest.title"),
 
  114                                               JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE) == JOptionPane.NO_OPTION) {
 
  119         iterator = 
new AddImageWizardIterator(
this);
 
  120         wizardDescriptor = 
new WizardDescriptor(iterator);
 
  121         wizardDescriptor.setTitle(NbBundle.getMessage(
this.getClass(), 
"AddImageAction.wizard.title"));
 
  122         wizardDescriptor.putProperty(NAME, e);
 
  124         if (dialog != null) {
 
  125             dialog.setVisible(
false); 
 
  127         dialog = DialogDisplayer.getDefault().createDialog(wizardDescriptor);
 
  128         dialog.setVisible(
true);
 
  142         wizardDescriptor.setValue(WizardDescriptor.FINISH_OPTION);
 
  143         dialog.setVisible(
false);
 
  147         final Runnable r = 
new Runnable()  {
 
  150                 actionPerformed(null);
 
  154         SwingUtilities.invokeLater(r);
 
  158         void runTask(
Image newImage);
 
  175         return NbBundle.getMessage(
AddImageAction.class, 
"CTL_AddImageButton");
 
  185         return HelpCtx.DEFAULT_HELP;
 
  195         ImageIcon icon = 
new ImageIcon(getClass().getResource(
"btn_icon_add_image.png")); 
 
  196         toolbarButton.setIcon(icon);
 
  197         toolbarButton.setText(this.getName());
 
  198         return toolbarButton;
 
  208         super.setEnabled(value);
 
  209         toolbarButton.setEnabled(value);
 
  223         Object[] wizardButtons = wizardDescriptor.getOptions();
 
  224         for (
int i = 0; i < wizardButtons.length; i++) {
 
  225             JButton tempButton = (JButton) wizardButtons[i];
 
  226             if (tempButton.getText().equals(buttonText)) {
 
  227                 tempButton.setDefaultCapable(
true);
 
  228                 tempButton.requestFocus();
 
  239         cleanupSupport.fireChange();
 
  242     ChangeSupport cleanupSupport = 
new ChangeSupport(
this);
 
  253     abstract class CleanupTask 
implements ChangeListener {
 
  256         public void stateChanged(ChangeEvent e) {
 
  260             } 
catch (Exception ex) {
 
  261                 Logger logger = Logger.
getLogger(this.getClass().getName());
 
  262                 logger.log(Level.WARNING, 
"Error cleaning up from wizard.", ex); 
 
  271         public void enable() {
 
  272             cleanupSupport.addChangeListener(
this);
 
  279         abstract void cleanup() throws Exception;
 
  284         public 
void disable() {
 
  285             cleanupSupport.removeChangeListener(
this);
 
static synchronized IngestManager getInstance()
Component getToolbarPresenter()
WizardDescriptor wizardDescriptor
void setEnabled(boolean value)
boolean isIngestRunning()
void actionPerformed(ActionEvent e)
void requestFocusButton(String buttonText)
WizardDescriptor.Iterator< WizardDescriptor > iterator
static Logger getLogger(String name)