Autopsy  4.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;
20 
21 import java.awt.event.ActionEvent;
22 import java.awt.event.ActionListener;
23 import java.util.Collection;
24 import java.util.Map;
25 import java.util.prefs.Preferences;
26 import javax.swing.JButton;
27 import javax.swing.event.ChangeListener;
28 import org.openide.WizardDescriptor;
29 import org.openide.util.HelpCtx;
30 import org.openide.util.NbBundle;
31 import org.openide.util.NbPreferences;
32 
33 class ReportWizardPanel1 implements WizardDescriptor.FinishablePanel<WizardDescriptor> {
34 
35  private WizardDescriptor wiz;
36  private ReportVisualPanel1 component;
37  private JButton nextButton;
38  private JButton finishButton;
39 
40  ReportWizardPanel1() {
41  nextButton = new JButton(NbBundle.getMessage(this.getClass(), "ReportWizardPanel1.nextButton.text"));
42  finishButton = new JButton(NbBundle.getMessage(this.getClass(), "ReportWizardPanel1.finishButton.text"));
43  finishButton.setEnabled(false);
44 
45  // Initialize our custom next and finish buttons
46  nextButton.addActionListener(new ActionListener() {
47  @Override
48  public void actionPerformed(ActionEvent e) {
49  wiz.doNextClick();
50  }
51  });
52 
53  finishButton.addActionListener(new ActionListener() {
54  @Override
55  public void actionPerformed(ActionEvent e) {
56  wiz.doFinishClick();
57  }
58  });
59  }
60 
61  @Override
62  public ReportVisualPanel1 getComponent() {
63  if (component == null) {
64  component = new ReportVisualPanel1(this);
65  }
66  return component;
67  }
68 
69  @Override
70  public HelpCtx getHelp() {
71  return HelpCtx.DEFAULT_HELP;
72  }
73 
74  @Override
75  public boolean isValid() {
76  // Always valid, but we control the enabled state
77  // of our custom buttons
78  return true;
79  }
80 
81  @Override
82  public boolean isFinishPanel() {
83  return true;
84  }
85 
86  public void setNext(boolean enabled) {
87  nextButton.setEnabled(enabled);
88  }
89 
90  public void setFinish(boolean enabled) {
91  finishButton.setEnabled(enabled);
92  }
93 
94  @Override
95  public void addChangeListener(ChangeListener l) {
96  }
97 
98  @Override
99  public void removeChangeListener(ChangeListener l) {
100  }
101 
102  @Override
103  public void readSettings(WizardDescriptor wiz) {
104  // Add out custom buttons in place of the regular ones
105  this.wiz = wiz;
106  wiz.setOptions(new Object[]{WizardDescriptor.PREVIOUS_OPTION, nextButton, finishButton, WizardDescriptor.CANCEL_OPTION});
107  }
108 
109  @Override
110  public void storeSettings(WizardDescriptor wiz) {
111  Map<TableReportModule, Boolean> tables = getComponent().getTableModuleStates();
112  Map<GeneralReportModule, Boolean> generals = getComponent().getGeneralModuleStates();
113  wiz.putProperty("tableModuleStates", tables); //NON-NLS
114  wiz.putProperty("generalModuleStates", generals); //NON-NLS
115  wiz.putProperty("fileModuleStates", getComponent().getFileModuleStates()); //NON-NLS
116 
117  // Store preferences that WizardIterator will use to determine what
118  // panels need to be shown
119  Preferences prefs = NbPreferences.forModule(ReportWizardPanel1.class);
120  prefs.putBoolean("tableModule", any(tables.values())); //NON-NLS
121  prefs.putBoolean("generalModule", any(generals.values())); //NON-NLS
122  }
123 
131  private boolean any(Collection<Boolean> bools) {
132  for (Boolean b : bools) {
133  if (b) {
134  return true;
135  }
136  }
137  return false;
138  }
139 }

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