Autopsy  4.4.1
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.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 JButton nextButton;
37  private JButton finishButton;
38 
39  ReportWizardPanel1() {
40  nextButton = new JButton(NbBundle.getMessage(this.getClass(), "ReportWizardPanel1.nextButton.text"));
41  finishButton = new JButton(NbBundle.getMessage(this.getClass(), "ReportWizardPanel1.finishButton.text"));
42  finishButton.setEnabled(false);
43 
44  // Initialize our custom next and finish buttons
45  nextButton.addActionListener(new ActionListener() {
46  @Override
47  public void actionPerformed(ActionEvent e) {
48  wiz.doNextClick();
49  }
50  });
51 
52  finishButton.addActionListener(new ActionListener() {
53  @Override
54  public void actionPerformed(ActionEvent e) {
55  wiz.doFinishClick();
56  }
57  });
58  }
59 
60  @Override
61  public ReportVisualPanel1 getComponent() {
62  if (component == null) {
63  component = new ReportVisualPanel1(this);
64  }
65  return component;
66  }
67 
68  @Override
69  public HelpCtx getHelp() {
70  return HelpCtx.DEFAULT_HELP;
71  }
72 
73  @Override
74  public boolean isValid() {
75  // Always valid, but we control the enabled state
76  // of our custom buttons
77  return true;
78  }
79 
80  @Override
81  public boolean isFinishPanel() {
82  return true;
83  }
84 
85  public void setNext(boolean enabled) {
86  nextButton.setEnabled(enabled);
87  }
88 
89  public void setFinish(boolean enabled) {
90  finishButton.setEnabled(enabled);
91  }
92 
93  @Override
94  public void addChangeListener(ChangeListener l) {
95  }
96 
97  @Override
98  public void removeChangeListener(ChangeListener l) {
99  }
100 
101  @Override
102  public void readSettings(WizardDescriptor wiz) {
103  // Add out custom buttons in place of the regular ones
104  this.wiz = wiz;
105  wiz.setOptions(new Object[]{WizardDescriptor.PREVIOUS_OPTION, nextButton, finishButton, WizardDescriptor.CANCEL_OPTION});
106  }
107 
108  @Override
109  public void storeSettings(WizardDescriptor wiz) {
110  TableReportModule module = getComponent().getTableModule();
111  GeneralReportModule general = getComponent().getGeneralModule();
112  wiz.putProperty("tableModule", module); //NON-NLS
113  wiz.putProperty("generalModule", general); //NON-NLS
114  wiz.putProperty("fileModule", getComponent().getFileModule()); //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", module != null); //NON-NLS
120  prefs.putBoolean("generalModule", general != null); //NON-NLS
121  }
122 
130  private boolean any(Collection<Boolean> bools) {
131  for (Boolean b : bools) {
132  if (b) {
133  return true;
134  }
135  }
136  return false;
137  }
138 }

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