Autopsy  4.1
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 = 103),
51  @ActionReference(path = "Toolbars/Case", position = 103)})
52 public final class ReportWizardAction extends CallableSystemAction implements Presenter.Toolbar, ActionListener {
53 
54  private final JButton toolbarButton = new JButton();
55  private static final String ACTION_NAME = NbBundle.getMessage(ReportWizardAction.class, "ReportWizardAction.actionName.text");
56 
62  @SuppressWarnings("unchecked")
63  public static void doReportWizard() {
64  WizardDescriptor wiz = new WizardDescriptor(new ReportWizardIterator());
65  wiz.setTitleFormat(new MessageFormat("{0} {1}"));
66  wiz.setTitle(NbBundle.getMessage(ReportWizardAction.class, "ReportWizardAction.reportWiz.title"));
67  if (DialogDisplayer.getDefault().notify(wiz) == WizardDescriptor.FINISH_OPTION) {
68  @SuppressWarnings("unchecked")
69  ReportGenerator generator = new ReportGenerator(); //NON-NLS
70  TableReportModule tableReport = (TableReportModule) wiz.getProperty("tableModule");
71  GeneralReportModule generalReport = (GeneralReportModule) wiz.getProperty("generalModule");
72  FileReportModule fileReport = (FileReportModule) wiz.getProperty("fileModule");
73  if (tableReport != null) {
74  generator.generateTableReport(tableReport, (Map<BlackboardArtifact.Type, Boolean>) wiz.getProperty("artifactStates"), (Map<String, Boolean>) wiz.getProperty("tagStates")); //NON-NLS
75  } else if (generalReport != null) {
76  generator.generateGeneralReport(generalReport);
77  } else if (fileReport != null) {
78  generator.generateFileListReport(fileReport, (Map<FileReportDataTypes, Boolean>) wiz.getProperty("fileReportOptions")); //NON-NLS
79  }
80  }
81  }
82 
83  public ReportWizardAction() {
84  setEnabled(false);
85  Case.addPropertyChangeListener((PropertyChangeEvent evt) -> {
86  if (evt.getPropertyName().equals(Case.Events.CURRENT_CASE.toString())) {
87  Case newCase = (Case) evt.getNewValue();
88  setEnabled(newCase != null && RuntimeProperties.coreComponentsAreActive());
89  }
90  });
91 
92  // Initialize the Generate Report button
93  toolbarButton.addActionListener(ReportWizardAction.this::actionPerformed);
94  }
95 
96  @Override
97  @SuppressWarnings("unchecked")
98  public void actionPerformed(ActionEvent e) {
99  doReportWizard();
100  }
101 
102  @Override
103  public void performAction() {
104  }
105 
106  @Override
107  public String getName() {
108  return ACTION_NAME;
109  }
110 
111  @Override
112  public HelpCtx getHelpCtx() {
113  return HelpCtx.DEFAULT_HELP;
114  }
115 
121  @Override
122  public Component getToolbarPresenter() {
123  ImageIcon icon = new ImageIcon(getClass().getResource("images/btn_icon_generate_report.png")); //NON-NLS
124  toolbarButton.setIcon(icon);
125  toolbarButton.setText(NbBundle.getMessage(this.getClass(), "ReportWizardAction.toolBarButton.text"));
126  return toolbarButton;
127  }
128 
134  @Override
135  public void setEnabled(boolean value) {
136  super.setEnabled(value);
137  toolbarButton.setEnabled(value);
138  }
139 }
static void addPropertyChangeListener(PropertyChangeListener listener)
Definition: Case.java:306

Copyright © 2012-2016 Basis Technology. Generated on: Tue Oct 25 2016
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.