23package org.sleuthkit.autopsy.report.infrastructure;
25import org.sleuthkit.autopsy.report.modules.portablecase.PortableCaseReportModuleSettings;
26import org.sleuthkit.autopsy.report.modules.portablecase.PortableCaseReportModule;
27import java.awt.Component;
28import java.awt.Cursor;
29import java.awt.event.ActionEvent;
30import java.awt.event.ActionListener;
31import java.beans.PropertyChangeEvent;
32import java.text.MessageFormat;
33import java.util.EnumSet;
37import java.util.concurrent.ExecutionException;
38import java.util.logging.Level;
39import javax.swing.ImageIcon;
40import javax.swing.JButton;
41import javax.swing.SwingWorker;
42import org.openide.DialogDisplayer;
43import org.openide.NotifyDescriptor;
44import org.openide.WizardDescriptor;
45import org.openide.awt.ActionID;
46import org.openide.awt.ActionReference;
47import org.openide.awt.ActionReferences;
48import org.openide.awt.ActionRegistration;
49import org.openide.util.HelpCtx;
50import org.openide.util.NbBundle;
51import org.openide.util.actions.CallableSystemAction;
52import org.openide.util.actions.Presenter;
53import org.openide.windows.WindowManager;
54import org.sleuthkit.autopsy.casemodule.Case;
55import org.sleuthkit.autopsy.core.RuntimeProperties;
56import org.sleuthkit.autopsy.coreutils.Logger;
57import org.sleuthkit.autopsy.report.GeneralReportSettings;
58import org.sleuthkit.autopsy.report.ReportModule;
60@ActionID(category =
"Tools",
id =
"org.sleuthkit.autopsy.report.infrastructure.ReportWizardAction")
61@ActionRegistration(displayName =
"#CTL_ReportWizardAction", lazy =
false)
62@ActionReferences(value = {
63 @ActionReference(path =
"Menu/Tools", position = 301, separatorAfter = 399)
65 @ActionReference(path =
"Toolbars/Case", position = 106)})
66public final class ReportWizardAction extends CallableSystemAction implements Presenter.Toolbar, ActionListener {
74 private static ReportGenerationPanel
panel;
87 @SuppressWarnings(
"unchecked")
88 public static
void doReportWizard(String configName,
boolean displayCaseSpecificData,
boolean runReports) {
89 WizardDescriptor wiz =
new WizardDescriptor(
new ReportWizardIterator(configName, displayCaseSpecificData));
90 wiz.setTitleFormat(
new MessageFormat(
"{0} {1}"));
91 wiz.setTitle(NbBundle.getMessage(
ReportWizardAction.class,
"ReportWizardAction.reportWiz.title"));
92 if (DialogDisplayer.getDefault().notify(wiz) == WizardDescriptor.FINISH_OPTION) {
97 }
catch (ReportConfigException ex) {
98 logger.log(Level.SEVERE,
"Failed to save reporting configuration " + configName, ex);
99 NotifyDescriptor descriptor =
new NotifyDescriptor.Message(
100 NbBundle.getMessage(
ReportWizardAction.class,
"ReportWizardAction.unableToSaveConfig.errorLabel.text"),
101 NotifyDescriptor.ERROR_MESSAGE);
102 DialogDisplayer.getDefault().notify(descriptor);
107 panel =
new ReportGenerationPanel();
108 Map<String, ReportModule> modules = (Map<String, ReportModule>) wiz.getProperty(
"modules");
119 generator.displayProgressPanel();
124 @SuppressWarnings(value =
"unchecked")
127 ReportingConfig reportingConfig =
new ReportingConfig(configName);
128 List<Long> selectedDataSourceIds = (List<Long>) wiz.getProperty(
"dataSourceSelections");
131 FileReportSettings fileSettings = (FileReportSettings) wiz.getProperty(
"fileReportSettings");
132 TableReportSettings tableSettings = (TableReportSettings) wiz.getProperty(
"tableReportSettings");
134 if(selectedDataSourceIds !=
null) {
136 if(fileSettings !=
null) {
137 fileSettings.setSelectedDataSources(selectedDataSourceIds);
139 if(tableSettings !=
null) {
140 tableSettings.setSelectedDataSources(selectedDataSourceIds);
144 reportingConfig.setFileReportSettings(fileSettings);
145 reportingConfig.setTableReportSettings(tableSettings);
146 reportingConfig.setGeneralReportSettings(generalSettings);
148 Map<String, ReportModuleConfig> moduleConfigs = (Map<String, ReportModuleConfig>) wiz.getProperty(
"moduleConfigs");
153 if (portableCaseReportSettings !=
null) {
154 config.setModuleSettings(portableCaseReportSettings);
159 reportingConfig.setModuleConfigs(moduleConfigs);
162 ReportingConfigLoader.saveConfig(reportingConfig);
168 if (evt.getPropertyName().equals(Case.Events.CURRENT_CASE.toString())) {
169 Case newCase = (Case) evt.getNewValue();
170 setEnabled(newCase != null && RuntimeProperties.runningWithGUI());
179 @SuppressWarnings(
"unchecked")
181 WindowManager.getDefault().getMainWindow().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
183 WindowManager.getDefault().getMainWindow().setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
197 return HelpCtx.DEFAULT_HELP;
207 ImageIcon icon =
new ImageIcon(getClass().getResource(
"/org/sleuthkit/autopsy/report/images/btn_icon_generate_report.png"));
209 toolbarButton.setText(NbBundle.getMessage(
this.getClass(),
"ReportWizardAction.toolBarButton.text"));
221 Set<String> nameList = ReportingConfigLoader.getListOfReportConfigs();
235 super.setEnabled(value);
257 }
catch (InterruptedException | ExecutionException ex) {
258 panel.getProgressPanel().updateStatusLabel(NbBundle.getMessage(
this.getClass(),
"ReportGenerator.errors.reportErrorText") + ex.getLocalizedMessage());
259 logger.log(Level.SEVERE,
"failed to generate reports", ex);
261 catch (java.util.concurrent.CancellationException ex) {
static void addEventTypeSubscriber(Set< Events > eventTypes, PropertyChangeListener subscriber)
synchronized static Logger getLogger(String name)
void setSelectedDataSources(List< Long > selectedDataSources)
ReportWorker(Runnable doInBackground)
final Runnable doInBackground
static ReportGenerationPanel panel
Component getToolbarPresenter()
static final boolean DISPLAY_CASE_SPECIFIC_DATA
static final String ACTION_NAME
static void doReportWizard(String configName, boolean displayCaseSpecificData, boolean runReports)
final JButton toolbarButton
void setEnabled(boolean value)
static final boolean RUN_REPORTS
static final String REPORTING_CONFIGURATION_NAME
static void saveReportingConfiguration(String configName, WizardDescriptor wiz)
static final Logger logger
static Set< String > getReportConfigNames()
void actionPerformed(ActionEvent e)