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.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;
 
   47 import org.openide.windows.WindowManager;
 
   57 @ActionID(category = 
"Tools", 
id = 
"org.sleuthkit.autopsy.casemodule.AddImageAction")
 
   58 @ActionRegistration(displayName = 
"#CTL_AddImage", lazy = 
false)
 
   59 @ActionReferences(value = {@ActionReference(path = 
"Toolbars/Case", position = 100)})
 
   61 public final class 
AddImageAction extends CallableSystemAction implements Presenter.Toolbar {
 
   63     private static final long serialVersionUID = 1L;
 
   64     private static final Dimension SIZE = 
new Dimension(875, 550);
 
   65     private final ChangeSupport cleanupSupport = 
new ChangeSupport(
this);
 
   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"; 
 
   88     private WizardDescriptor.Iterator<WizardDescriptor> 
iterator;
 
   90     private final JButton toolbarButton = 
new JButton();
 
   96         putValue(Action.NAME, NbBundle.getMessage(
AddImageAction.class, 
"CTL_AddImage")); 
 
   99         toolbarButton.addActionListener(
new ActionListener() {
 
  102             public void actionPerformed(ActionEvent e) {
 
  111         this.setEnabled(
false);
 
  116         String optionsDlgTitle = NbBundle.getMessage(this.getClass(), 
"AddImageAction.ingestConfig.ongoingIngest.title");
 
  117         String optionsDlgMessage = NbBundle.getMessage(this.getClass(), 
"AddImageAction.ingestConfig.ongoingIngest.msg");
 
  119             WindowManager.getDefault().getMainWindow().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
 
  120             iterator = 
new AddImageWizardIterator(
this);
 
  121             wizardDescriptor = 
new WizardDescriptor(iterator);
 
  122             wizardDescriptor.setTitle(NbBundle.getMessage(
this.getClass(), 
"AddImageAction.wizard.title"));
 
  123             wizardDescriptor.putProperty(NAME, e);
 
  124             wizardDescriptor.setTitleFormat(
new MessageFormat(
"{0}"));
 
  126             if (dialog != null) {
 
  127                 dialog.setVisible(
false); 
 
  129             dialog = DialogDisplayer.getDefault().createDialog(wizardDescriptor);
 
  130             Dimension d = dialog.getSize();
 
  131             dialog.setSize(SIZE);
 
  132             WindowManager.getDefault().getMainWindow().setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
 
  133             dialog.setVisible(
true);
 
  148         wizardDescriptor.setValue(WizardDescriptor.FINISH_OPTION);
 
  149         dialog.setVisible(
false);
 
  153         final Runnable r = 
new Runnable() {
 
  156                 actionPerformed(null);
 
  160         SwingUtilities.invokeLater(r);
 
  165         void runTask(
Image newImage);
 
  170         actionPerformed(null);
 
  180         return NbBundle.getMessage(
AddImageAction.class, 
"CTL_AddImageButton");
 
  190         return HelpCtx.DEFAULT_HELP;
 
  200         ImageIcon icon = 
new ImageIcon(getClass().getResource(
"btn_icon_add_image.png")); 
 
  201         toolbarButton.setIcon(icon);
 
  202         toolbarButton.setText(this.getName());
 
  203         return toolbarButton;
 
  213         super.setEnabled(value);
 
  214         toolbarButton.setEnabled(value);
 
  228         Object[] wizardButtons = wizardDescriptor.getOptions();
 
  229         for (Object wizardButton : wizardButtons) {
 
  230             JButton tempButton = (JButton) wizardButton;
 
  231             if (tempButton.getText().equals(buttonText)) {
 
  232                 tempButton.setDefaultCapable(
true);
 
  233                 tempButton.requestFocus();
 
  244         cleanupSupport.fireChange();
 
  256     abstract class CleanupTask 
implements ChangeListener {
 
  259         public void stateChanged(ChangeEvent e) {
 
  263             } 
catch (Exception ex) {
 
  264                 Logger logger = Logger.
getLogger(this.getClass().getName());
 
  265                 logger.log(Level.WARNING, 
"Error cleaning up from wizard.", ex); 
 
  274         public void enable() {
 
  275             cleanupSupport.addChangeListener(
this);
 
  283         abstract void cleanup() throws Exception;
 
  288         public 
void disable() {
 
  289             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