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.beans.PropertyChangeListener;
31 import java.text.MessageFormat;
33 import java.util.logging.Level;
34 import javax.swing.ImageIcon;
35 import javax.swing.JButton;
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.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 = 80)})
56 public final class ReportWizardAction extends CallableSystemAction implements Presenter.Toolbar, ActionListener {
59 private JButton toolbarButton =
new JButton();
60 private static final String ACTION_NAME = NbBundle.getMessage(
ReportWizardAction.class,
"ReportWizardAction.actionName.text");
67 @SuppressWarnings(
"unchecked")
68 public static
void doReportWizard() {
69 WizardDescriptor wiz =
new WizardDescriptor(
new ReportWizardIterator());
70 wiz.setTitleFormat(
new MessageFormat(
"{0} {1}"));
71 wiz.setTitle(NbBundle.getMessage(
ReportWizardAction.class,
"ReportWizardAction.reportWiz.title"));
72 if (DialogDisplayer.getDefault().notify(wiz) == WizardDescriptor.FINISH_OPTION) {
73 @SuppressWarnings(
"unchecked")
74 ReportGenerator generator =
new ReportGenerator((Map<TableReportModule, Boolean>)wiz.getProperty(
"tableModuleStates"),
75 (Map<GeneralReportModule, Boolean>)wiz.getProperty(
"generalModuleStates"),
76 (Map<FileReportModule, Boolean>)wiz.getProperty(
"fileModuleStates"));
77 generator.generateTableReports((Map<ARTIFACT_TYPE, Boolean>)wiz.getProperty(
"artifactStates"), (Map<String, Boolean>)wiz.getProperty(
"tagStates"));
78 generator.generateFileListReports((Map<FileReportDataTypes, Boolean>)wiz.getProperty(
"fileReportOptions"));
79 generator.generateGeneralReports();
80 generator.displayProgressPanels();
88 public void propertyChange(PropertyChangeEvent evt) {
90 Case newCase = (
Case) evt.getNewValue();
91 setEnabled(newCase != null);
94 if (newCase != null) {
95 boolean exists = (
new File(newCase.
getCaseDirectory() + File.separator +
"Reports")).exists();
97 boolean reportCreate = (
new File(newCase.
getCaseDirectory() + File.separator +
"Reports")).mkdirs();
99 logger.log(Level.WARNING,
"Could not create Reports directory for case. It does not exist.");
108 toolbarButton.addActionListener(
new ActionListener() {
110 public void actionPerformed(ActionEvent e) {
117 @SuppressWarnings(
"unchecked")
118 public
void actionPerformed(ActionEvent e) {
133 return HelpCtx.DEFAULT_HELP;
143 ImageIcon icon =
new ImageIcon(getClass().getResource(
"images/btn_icon_generate_report.png"));
144 toolbarButton.setIcon(icon);
145 toolbarButton.setText(NbBundle.getMessage(
this.getClass(),
"ReportWizardAction.toolBarButton.text"));
146 return toolbarButton;
156 super.setEnabled(value);
157 toolbarButton.setEnabled(value);
void actionPerformed(ActionEvent e)
String getCaseDirectory()
void setEnabled(boolean value)
static synchronized void addPropertyChangeListener(PropertyChangeListener listener)
Component getToolbarPresenter()
static Logger getLogger(String name)