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> {
34 private final ReportWizardPanel1 firstPanel;
35 private final ReportWizardPanel2 tableConfigPanel;
36 private final ReportWizardFileOptionsPanel fileConfigPanel;
37 private final ReportWizardPortableCaseOptionsPanel portableCaseConfigPanel;
39 private List<WizardDescriptor.Panel<WizardDescriptor>> panels;
43 private final WizardDescriptor.Panel<WizardDescriptor>[] allConfigPanels;
47 private final WizardDescriptor.Panel<WizardDescriptor>[] tableConfigPanels;
51 private final WizardDescriptor.Panel<WizardDescriptor>[] fileConfigPanels;
55 private final WizardDescriptor.Panel<WizardDescriptor>[] portableCaseConfigPanels;
57 @SuppressWarnings({
"rawtypes",
"unchecked"})
58 ReportWizardIterator() {
59 firstPanel =
new ReportWizardPanel1();
60 tableConfigPanel =
new ReportWizardPanel2();
61 fileConfigPanel =
new ReportWizardFileOptionsPanel();
62 portableCaseConfigPanel =
new ReportWizardPortableCaseOptionsPanel();
64 allConfigPanels =
new WizardDescriptor.Panel[]{firstPanel, tableConfigPanel, fileConfigPanel, portableCaseConfigPanel};
65 tableConfigPanels =
new WizardDescriptor.Panel[]{firstPanel, tableConfigPanel};
66 fileConfigPanels =
new WizardDescriptor.Panel[]{firstPanel, fileConfigPanel};
67 portableCaseConfigPanels =
new WizardDescriptor.Panel[]{firstPanel, portableCaseConfigPanel};
70 private List<WizardDescriptor.Panel<WizardDescriptor>> getPanels() {
72 panels = Arrays.asList(allConfigPanels);
73 String[] steps =
new String[panels.size()];
74 for (
int i = 0; i < panels.size(); i++) {
75 Component c = panels.get(i).getComponent();
77 steps[i] = c.getName();
78 if (c instanceof JComponent) {
79 JComponent jc = (JComponent) c;
80 jc.putClientProperty(WizardDescriptor.PROP_CONTENT_SELECTED_INDEX, i);
81 jc.putClientProperty(WizardDescriptor.PROP_CONTENT_DATA, steps);
82 jc.putClientProperty(WizardDescriptor.PROP_AUTO_WIZARD_STYLE,
true);
83 jc.putClientProperty(WizardDescriptor.PROP_CONTENT_DISPLAYED,
false);
84 jc.putClientProperty(WizardDescriptor.PROP_CONTENT_NUMBERED,
true);
98 private void enableConfigPanels(
boolean generalModule,
boolean tableModule,
boolean portableCaseModule) {
101 }
else if (tableModule) {
104 panels = Arrays.asList(tableConfigPanels);
105 }
else if (portableCaseModule) {
108 panels = Arrays.asList(portableCaseConfigPanels);
112 panels = Arrays.asList(fileConfigPanels);
117 public WizardDescriptor.Panel<WizardDescriptor> current() {
118 return getPanels().get(index);
122 public String name() {
127 public boolean hasNext() {
128 return index < getPanels().size() - 1;
132 public boolean hasPrevious() {
137 public void nextPanel() {
139 throw new NoSuchElementException();
144 boolean generalModule, tableModule, portableModule;
146 generalModule = NbPreferences.forModule(ReportWizardPanel1.class).getBoolean(
"generalModule",
true);
147 tableModule = NbPreferences.forModule(ReportWizardPanel1.class).getBoolean(
"tableModule",
true);
148 portableModule = NbPreferences.forModule(ReportWizardPanel1.class).getBoolean(
"portableCaseModule",
true);
149 enableConfigPanels(generalModule, tableModule, portableModule);
156 public void previousPanel() {
157 if (!hasPrevious()) {
158 throw new NoSuchElementException();
164 public void addChangeListener(ChangeListener l) {
168 public void removeChangeListener(ChangeListener l) {