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

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