Autopsy  4.14.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 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 
41  ReportWizardPanel1(Map<String, ReportModuleConfig> moduleConfigs) {
42  this.moduleConfigs = moduleConfigs;
43  nextButton = new JButton(NbBundle.getMessage(this.getClass(), "ReportWizardPanel1.nextButton.text"));
44  finishButton = new JButton(NbBundle.getMessage(this.getClass(), "ReportWizardPanel1.finishButton.text"));
45  finishButton.setEnabled(false);
46 
47  // Initialize our custom next and finish buttons
48  nextButton.addActionListener(new ActionListener() {
49  @Override
50  public void actionPerformed(ActionEvent e) {
51  wiz.doNextClick();
52  }
53  });
54 
55  finishButton.addActionListener(new ActionListener() {
56  @Override
57  public void actionPerformed(ActionEvent e) {
58  wiz.doFinishClick();
59  }
60  });
61  }
62 
63  @Override
64  public ReportVisualPanel1 getComponent() {
65  if (component == null) {
66  component = new ReportVisualPanel1(this, moduleConfigs);
67  }
68  return component;
69  }
70 
71  @Override
72  public HelpCtx getHelp() {
73  return HelpCtx.DEFAULT_HELP;
74  }
75 
76  @Override
77  public boolean isValid() {
78  // Always valid, but we control the enabled state
79  // of our custom buttons
80  return true;
81  }
82 
83  @Override
84  public boolean isFinishPanel() {
85  return true;
86  }
87 
88  public void setNext(boolean enabled) {
89  nextButton.setEnabled(enabled);
90  }
91 
92  public void setFinish(boolean enabled) {
93  finishButton.setEnabled(enabled);
94  }
95 
96  @Override
97  public void addChangeListener(ChangeListener l) {
98  }
99 
100  @Override
101  public void removeChangeListener(ChangeListener l) {
102  }
103 
104  @Override
105  public void readSettings(WizardDescriptor wiz) {
106  // Add out custom buttons in place of the regular ones
107  this.wiz = wiz;
108  wiz.setOptions(new Object[]{WizardDescriptor.PREVIOUS_OPTION, nextButton, finishButton, WizardDescriptor.CANCEL_OPTION});
109  }
110 
111  @Override
112  public void storeSettings(WizardDescriptor wiz) {
113  wiz.putProperty("moduleConfigs", getComponent().getUpdatedModuleConfigs()); //NON-NLS
114  wiz.putProperty("modules", getComponent().getReportModules()); //NON-NLS
115 
116  // Store preferences that WizardIterator will use to determine what
117  // panels need to be shown
118  Preferences prefs = NbPreferences.forModule(ReportWizardPanel1.class);
119  prefs.putBoolean("tableModule", getComponent().getTableModule() != null); //NON-NLS
120  prefs.putBoolean("generalModule", getComponent().getGeneralModule() != null); //NON-NLS
121  prefs.putBoolean("portableCaseModule", getComponent().getPortableCaseModule() != null); //NON-NLS
122  }
123 }

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