23 package org.sleuthkit.autopsy.report;
 
   25 import java.awt.Component;
 
   26 import java.awt.event.ActionEvent;
 
   27 import java.awt.event.ActionListener;
 
   28 import java.beans.PropertyChangeEvent;
 
   29 import java.io.IOException;
 
   30 import java.text.MessageFormat;
 
   31 import java.util.EnumSet;
 
   33 import javax.swing.ImageIcon;
 
   34 import javax.swing.JButton;
 
   35 import org.openide.DialogDisplayer;
 
   36 import org.openide.NotifyDescriptor;
 
   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.HelpCtx;
 
   43 import org.openide.util.NbBundle;
 
   44 import org.openide.util.actions.CallableSystemAction;
 
   45 import org.openide.util.actions.Presenter;
 
   50 @ActionID(category = 
"Tools", 
id = 
"org.sleuthkit.autopsy.report.ReportWizardAction")
 
   51 @ActionRegistration(displayName = 
"#CTL_ReportWizardAction", lazy = 
false)
 
   52 @ActionReferences(value = {
 
   53     @ActionReference(path = 
"Menu/Tools", position = 301, separatorAfter = 399),
 
   54     @ActionReference(path = 
"Toolbars/Case", position = 105)})
 
   55 public final class ReportWizardAction extends CallableSystemAction implements Presenter.Toolbar, ActionListener {
 
   57     private final JButton toolbarButton = 
new JButton();
 
   58     private static final String ACTION_NAME = NbBundle.getMessage(
ReportWizardAction.class, 
"ReportWizardAction.actionName.text");
 
   65     @SuppressWarnings(
"unchecked")
 
   66     public static 
void doReportWizard() {
 
   67         WizardDescriptor wiz = 
new WizardDescriptor(
new ReportWizardIterator());
 
   68         wiz.setTitleFormat(
new MessageFormat(
"{0} {1}"));
 
   69         wiz.setTitle(NbBundle.getMessage(
ReportWizardAction.class, 
"ReportWizardAction.reportWiz.title"));
 
   70         if (DialogDisplayer.getDefault().notify(wiz) == WizardDescriptor.FINISH_OPTION) {
 
   71             ReportGenerator generator = 
new ReportGenerator(); 
 
   72             TableReportModule tableReport = (TableReportModule) wiz.getProperty(
"tableModule");
 
   74             FileReportModule fileReport = (FileReportModule) wiz.getProperty(
"fileModule");
 
   76                 if (tableReport != null) {
 
   77                     generator.generateTableReport(tableReport, (Map<BlackboardArtifact.Type, Boolean>) wiz.getProperty(
"artifactStates"), (Map<String, Boolean>) wiz.getProperty(
"tagStates")); 
 
   78                 } 
else if (generalReport != null) {
 
   79                     generator.generateGeneralReport(generalReport);
 
   80                 } 
else if (fileReport != null) {
 
   81                     generator.generateFileListReport(fileReport, (Map<FileReportDataTypes, Boolean>) wiz.getProperty(
"fileReportOptions")); 
 
   83             } 
catch (IOException e) {
 
   84                 NotifyDescriptor descriptor = 
new NotifyDescriptor.Message(e.getMessage(), NotifyDescriptor.ERROR_MESSAGE);
 
   85                 DialogDisplayer.getDefault().notify(descriptor);
 
   94                 Case newCase = (
Case) evt.getNewValue();
 
  104     @SuppressWarnings(
"unchecked")
 
  105     public 
void actionPerformed(ActionEvent e) {
 
  120         return HelpCtx.DEFAULT_HELP;
 
  130         ImageIcon icon = 
new ImageIcon(getClass().getResource(
"images/btn_icon_generate_report.png")); 
 
  131         toolbarButton.setIcon(icon);
 
  132         toolbarButton.setText(NbBundle.getMessage(
this.getClass(), 
"ReportWizardAction.toolBarButton.text"));
 
  133         return toolbarButton;
 
  143         super.setEnabled(value);
 
  144         toolbarButton.setEnabled(value);
 
static boolean runningWithGUI
void setEnabled(boolean value)
static void addEventTypeSubscriber(Set< Events > eventTypes, PropertyChangeListener subscriber)
Component getToolbarPresenter()