19 package org.sleuthkit.autopsy.report;
21 import java.awt.Component;
22 import java.util.Arrays;
23 import java.util.List;
24 import java.util.NoSuchElementException;
25 import javax.swing.JComponent;
26 import javax.swing.event.ChangeListener;
27 import org.openide.WizardDescriptor;
28 import org.openide.util.NbPreferences;
30 final class ReportWizardIterator
implements WizardDescriptor.Iterator<WizardDescriptor> {
33 private ReportWizardPanel1 firstPanel;
34 private ReportWizardPanel2 tableConfigPanel;
35 private ReportWizardFileOptionsPanel fileConfigPanel;
37 private List<WizardDescriptor.Panel<WizardDescriptor>> panels;
41 private WizardDescriptor.Panel<WizardDescriptor>[] allConfigPanels;
42 private String[] allConfigIndex;
45 private WizardDescriptor.Panel<WizardDescriptor>[] tableConfigPanels;
46 private String[] tableConfigIndex;
49 private WizardDescriptor.Panel<WizardDescriptor>[] fileConfigPanels;
50 private String[] fileConfigIndex;
52 @SuppressWarnings({
"rawtypes",
"unchecked"})
53 ReportWizardIterator() {
54 firstPanel =
new ReportWizardPanel1();
55 tableConfigPanel =
new ReportWizardPanel2();
56 fileConfigPanel =
new ReportWizardFileOptionsPanel();
58 allConfigPanels =
new WizardDescriptor.Panel[]{firstPanel, tableConfigPanel, fileConfigPanel};
59 tableConfigPanels =
new WizardDescriptor.Panel[]{firstPanel, tableConfigPanel};
60 fileConfigPanels =
new WizardDescriptor.Panel[]{firstPanel, fileConfigPanel};
63 private List<WizardDescriptor.Panel<WizardDescriptor>> getPanels() {
65 panels = Arrays.asList(allConfigPanels);
66 String[] steps =
new String[panels.size()];
67 for (
int i = 0; i < panels.size(); i++) {
68 Component c = panels.get(i).getComponent();
70 steps[i] = c.getName();
71 if (c instanceof JComponent) {
72 JComponent jc = (JComponent) c;
73 jc.putClientProperty(WizardDescriptor.PROP_CONTENT_SELECTED_INDEX, i);
74 jc.putClientProperty(WizardDescriptor.PROP_CONTENT_DATA, steps);
75 jc.putClientProperty(WizardDescriptor.PROP_AUTO_WIZARD_STYLE,
true);
76 jc.putClientProperty(WizardDescriptor.PROP_CONTENT_DISPLAYED,
false);
77 jc.putClientProperty(WizardDescriptor.PROP_CONTENT_NUMBERED,
true);
81 allConfigIndex = steps;
82 tableConfigIndex =
new String[] {steps[0], steps[1]};
83 fileConfigIndex =
new String[] {steps[0], steps[2]};
93 private void enableConfigPanels(
boolean generalModule,
boolean tableModule) {
96 }
else if (tableModule) {
99 panels = Arrays.asList(tableConfigPanels);
103 panels = Arrays.asList(fileConfigPanels);
108 public WizardDescriptor.Panel<WizardDescriptor> current() {
109 return getPanels().get(index);
113 public String name() {
118 public boolean hasNext() {
119 return index < getPanels().size() - 1;
123 public boolean hasPrevious() {
128 public void nextPanel() {
130 throw new NoSuchElementException();
135 boolean generalModule, tableModule;
137 generalModule = NbPreferences.forModule(ReportWizardPanel1.class).getBoolean(
"generalModule",
true);
138 tableModule = NbPreferences.forModule(ReportWizardPanel1.class).getBoolean(
"tableModule",
true);
139 enableConfigPanels(generalModule, tableModule);
146 public void previousPanel() {
147 if (!hasPrevious()) {
148 throw new NoSuchElementException();
154 public void addChangeListener(ChangeListener l) {
158 public void removeChangeListener(ChangeListener l) {