Autopsy  4.17.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
ReportWizardPanel1.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2012-2020 Basis Technology Corp.
5  * Contact: carrier <at> sleuthkit <dot> org
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */
19 package org.sleuthkit.autopsy.report.infrastructure;
20 
21 import java.awt.event.ActionEvent;
22 import java.awt.event.ActionListener;
23 import java.util.Map;
24 import java.util.prefs.Preferences;
25 import javax.swing.JButton;
26 import javax.swing.event.ChangeListener;
27 import org.openide.WizardDescriptor;
28 import org.openide.util.HelpCtx;
29 import org.openide.util.NbBundle;
30 import org.openide.util.NbPreferences;
32 
33 class ReportWizardPanel1 implements WizardDescriptor.FinishablePanel<WizardDescriptor> {
34 
35  private WizardDescriptor wiz;
36  private ReportVisualPanel1 component;
37  private final Map<String, ReportModuleConfig> moduleConfigs;
38  private final JButton nextButton;
39  private final JButton finishButton;
40  private final boolean displayCaseSpecificData;
41 
42  ReportWizardPanel1(Map<String, ReportModuleConfig> moduleConfigs, boolean displayCaseSpecificData) {
43  this.moduleConfigs = moduleConfigs;
44  this.displayCaseSpecificData = displayCaseSpecificData;
45  nextButton = new JButton(NbBundle.getMessage(this.getClass(), "ReportWizardPanel1.nextButton.text"));
46  finishButton = new JButton(NbBundle.getMessage(this.getClass(), "ReportWizardPanel1.finishButton.text"));
47  finishButton.setEnabled(false);
48 
49  // Initialize our custom next and finish buttons
50  nextButton.addActionListener(new ActionListener() {
51  @Override
52  public void actionPerformed(ActionEvent e) {
53  wiz.doNextClick();
54  }
55  });
56 
57  finishButton.addActionListener(new ActionListener() {
58  @Override
59  public void actionPerformed(ActionEvent e) {
60  wiz.doFinishClick();
61  }
62  });
63  }
64 
65  @Override
66  public ReportVisualPanel1 getComponent() {
67  if (component == null) {
68  component = new ReportVisualPanel1(this, moduleConfigs, displayCaseSpecificData);
69  }
70  return component;
71  }
72 
73  @Override
74  public HelpCtx getHelp() {
75  return HelpCtx.DEFAULT_HELP;
76  }
77 
78  @Override
79  public boolean isValid() {
80  // Always valid, but we control the enabled state
81  // of our custom buttons
82  return true;
83  }
84 
85  @Override
86  public boolean isFinishPanel() {
87  return true;
88  }
89 
90  public void setNext(boolean enabled) {
91  nextButton.setEnabled(enabled);
92  }
93 
94  public void setFinish(boolean enabled) {
95  finishButton.setEnabled(enabled);
96  }
97 
98  @Override
99  public void addChangeListener(ChangeListener l) {
100  }
101 
102  @Override
103  public void removeChangeListener(ChangeListener l) {
104  }
105 
106  @Override
107  public void readSettings(WizardDescriptor wiz) {
108  // Add out custom buttons in place of the regular ones
109  this.wiz = wiz;
110  wiz.setOptions(new Object[]{WizardDescriptor.PREVIOUS_OPTION, nextButton, finishButton, WizardDescriptor.CANCEL_OPTION});
111  }
112 
113  @Override
114  public void storeSettings(WizardDescriptor wiz) {
115  wiz.putProperty("moduleConfigs", getComponent().getUpdatedModuleConfigs()); //NON-NLS
116  wiz.putProperty("modules", getComponent().getReportModules()); //NON-NLS
117 
118  // Store preferences that WizardIterator will use to determine what
119  // panels need to be shown
120  Preferences prefs = NbPreferences.forModule(ReportWizardPanel1.class);
121  TableReportModule tableModuleSelection = getComponent().getTableModule();
122  GeneralReportModule generalModuleSelection = getComponent().getGeneralModule();
123  FileReportModule fileModuleSelection = getComponent().getFileModule();
124 
125  prefs.putBoolean("tableModule", tableModuleSelection != null); //NON-NLS
126  prefs.putBoolean("generalModule", generalModuleSelection != null); //NON-NLS
127  prefs.putBoolean("portableCaseModule", getComponent().getPortableCaseModule() != null); //NON-NLS
128  prefs.putBoolean("showDataSourceSelectionPanel", false);
129 
130  if(generalModuleSelection != null && generalModuleSelection.supportsDataSourceSelection()) {
131  prefs.putBoolean("showDataSourceSelectionPanel", true);
132  }
133 
134  if(tableModuleSelection != null) {
135  prefs.putBoolean("showDataSourceSelectionPanel", true);
136  }
137 
138  if(fileModuleSelection != null) {
139  prefs.putBoolean("showDataSourceSelectionPanel", true);
140  }
141  }
142 }

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