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;
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  ReportGenerator generator = new ReportGenerator(); //NON-NLS
69  TableReportModule tableReport = (TableReportModule) wiz.getProperty("tableModule");
70  GeneralReportModule generalReport = (GeneralReportModule) wiz.getProperty("generalModule");
71  FileReportModule fileReport = (FileReportModule) wiz.getProperty("fileModule");
72  if (tableReport != null) {
73  generator.generateTableReport(tableReport, (Map<BlackboardArtifact.Type, Boolean>) wiz.getProperty("artifactStates"), (Map<String, Boolean>) wiz.getProperty("tagStates")); //NON-NLS
74  } else if (generalReport != null) {
75  generator.generateGeneralReport(generalReport);
76  } else if (fileReport != null) {
77  generator.generateFileListReport(fileReport, (Map<FileReportDataTypes, Boolean>) wiz.getProperty("fileReportOptions")); //NON-NLS
78  }
79  }
80  }
81 
82  public ReportWizardAction() {
83  setEnabled(false);
84  Case.addPropertyChangeListener((PropertyChangeEvent evt) -> {
85  if (evt.getPropertyName().equals(Case.Events.CURRENT_CASE.toString())) {
86  Case newCase = (Case) evt.getNewValue();
87  setEnabled(newCase != null && RuntimeProperties.runningWithGUI());
88  }
89  });
90 
91  // Initialize the Generate Report button
92  toolbarButton.addActionListener(ReportWizardAction.this::actionPerformed);
93  }
94 
95  @Override
96  @SuppressWarnings("unchecked")
97  public void actionPerformed(ActionEvent e) {
98  doReportWizard();
99  }
100 
101  @Override
102  public void performAction() {
103  }
104 
105  @Override
106  public String getName() {
107  return ACTION_NAME;
108  }
109 
110  @Override
111  public HelpCtx getHelpCtx() {
112  return HelpCtx.DEFAULT_HELP;
113  }
114 
120  @Override
121  public Component getToolbarPresenter() {
122  ImageIcon icon = new ImageIcon(getClass().getResource("images/btn_icon_generate_report.png")); //NON-NLS
123  toolbarButton.setIcon(icon);
124  toolbarButton.setText(NbBundle.getMessage(this.getClass(), "ReportWizardAction.toolBarButton.text"));
125  return toolbarButton;
126  }
127 
133  @Override
134  public void setEnabled(boolean value) {
135  super.setEnabled(value);
136  toolbarButton.setEnabled(value);
137  }
138 }
static void addPropertyChangeListener(PropertyChangeListener listener)
Definition: Case.java:372

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