Autopsy  4.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
ReportWizardAction.java
Go to the documentation of this file.
1  /*
2  *
3  * Autopsy Forensic Browser
4  *
5  * Copyright 2013-2015 Basis Technology Corp.
6  *
7  * Copyright 2012 42six Solutions.
8  * Contact: aebadirad <at> 42six <dot> com
9  * Project Contact/Architect: carrier <at> sleuthkit <dot> org
10  *
11  * Licensed under the Apache License, Version 2.0 (the "License");
12  * you may not use this file except in compliance with the License.
13  * You may obtain a copy of the License at
14  *
15  * http://www.apache.org/licenses/LICENSE-2.0
16  *
17  * Unless required by applicable law or agreed to in writing, software
18  * distributed under the License is distributed on an "AS IS" BASIS,
19  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20  * See the License for the specific language governing permissions and
21  * limitations under the License.
22  */
23 package org.sleuthkit.autopsy.report;
24 
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.text.MessageFormat;
30 import java.util.Map;
31 import javax.swing.ImageIcon;
32 import javax.swing.JButton;
33 import org.openide.DialogDisplayer;
34 import org.openide.WizardDescriptor;
35 import org.openide.awt.ActionID;
36 import org.openide.awt.ActionReference;
37 import org.openide.awt.ActionReferences;
38 import org.openide.awt.ActionRegistration;
39 import org.openide.util.HelpCtx;
40 import org.openide.util.NbBundle;
41 import org.openide.util.actions.CallableSystemAction;
42 import org.openide.util.actions.Presenter;
45 import org.sleuthkit.datamodel.BlackboardArtifact;
46 
47 @ActionID(category = "Tools", id = "org.sleuthkit.autopsy.report.ReportWizardAction")
48 @ActionRegistration(displayName = "#CTL_ReportWizardAction", lazy = false)
49 @ActionReferences(value = {
50  @ActionReference(path = "Menu/Tools", position = 80)})
51 public final class ReportWizardAction extends CallableSystemAction implements Presenter.Toolbar, ActionListener {
52 
53  private final JButton toolbarButton = new JButton();
54  private static final String ACTION_NAME = NbBundle.getMessage(ReportWizardAction.class, "ReportWizardAction.actionName.text");
55 
61  @SuppressWarnings("unchecked")
62  public static void doReportWizard() {
63  WizardDescriptor wiz = new WizardDescriptor(new ReportWizardIterator());
64  wiz.setTitleFormat(new MessageFormat("{0} {1}"));
65  wiz.setTitle(NbBundle.getMessage(ReportWizardAction.class, "ReportWizardAction.reportWiz.title"));
66  if (DialogDisplayer.getDefault().notify(wiz) == WizardDescriptor.FINISH_OPTION) {
67  @SuppressWarnings("unchecked")
68  ReportGenerator generator = new ReportGenerator((Map<TableReportModule, Boolean>) wiz.getProperty("tableModuleStates"), //NON-NLS
69  (Map<GeneralReportModule, Boolean>) wiz.getProperty("generalModuleStates"), //NON-NLS
70  (Map<FileReportModule, Boolean>) wiz.getProperty("fileModuleStates")); //NON-NLS
71  generator.generateTableReports((Map<BlackboardArtifact.Type, Boolean>) wiz.getProperty("artifactStates"), (Map<String, Boolean>) wiz.getProperty("tagStates")); //NON-NLS
72  generator.generateFileListReports((Map<FileReportDataTypes, Boolean>) wiz.getProperty("fileReportOptions")); //NON-NLS
73  generator.generateGeneralReports();
74  generator.displayProgressPanels();
75  }
76  }
77 
78  public ReportWizardAction() {
79  setEnabled(false);
80  Case.addPropertyChangeListener((PropertyChangeEvent evt) -> {
81  if (evt.getPropertyName().equals(Case.Events.CURRENT_CASE.toString())) {
82  Case newCase = (Case) evt.getNewValue();
83  setEnabled(newCase != null && RuntimeProperties.coreComponentsAreActive());
84  }
85  });
86 
87  // Initialize the Generate Report button
88  toolbarButton.addActionListener(ReportWizardAction.this::actionPerformed);
89  }
90 
91  @Override
92  @SuppressWarnings("unchecked")
93  public void actionPerformed(ActionEvent e) {
94  doReportWizard();
95  }
96 
97  @Override
98  public void performAction() {
99  }
100 
101  @Override
102  public String getName() {
103  return ACTION_NAME;
104  }
105 
106  @Override
107  public HelpCtx getHelpCtx() {
108  return HelpCtx.DEFAULT_HELP;
109  }
110 
116  @Override
117  public Component getToolbarPresenter() {
118  ImageIcon icon = new ImageIcon(getClass().getResource("images/btn_icon_generate_report.png")); //NON-NLS
119  toolbarButton.setIcon(icon);
120  toolbarButton.setText(NbBundle.getMessage(this.getClass(), "ReportWizardAction.toolBarButton.text"));
121  return toolbarButton;
122  }
123 
129  @Override
130  public void setEnabled(boolean value) {
131  super.setEnabled(value);
132  toolbarButton.setEnabled(value);
133  }
134 }
static synchronized void addPropertyChangeListener(PropertyChangeListener listener)
Definition: Case.java:1292

Copyright © 2012-2015 Basis Technology. Generated on: Wed Apr 6 2016
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.