19 package org.sleuthkit.autopsy.report.infrastructure;
21 import java.awt.Component;
22 import java.util.Arrays;
23 import java.util.List;
24 import java.util.NoSuchElementException;
25 import java.util.logging.Level;
26 import javax.swing.JComponent;
27 import javax.swing.event.ChangeListener;
28 import org.openide.WizardDescriptor;
29 import org.openide.util.NbPreferences;
32 final class ReportWizardIterator
implements WizardDescriptor.Iterator<WizardDescriptor> {
34 private static final Logger logger = Logger.
getLogger(ReportWizardIterator.class.getName());
37 private final ReportWizardPanel1 firstPanel;
38 private final ReportWizardPanel2 tableConfigPanel;
39 private final ReportWizardFileOptionsPanel fileConfigPanel;
40 private final ReportWizardPortableCaseOptionsPanel portableCaseConfigPanel;
42 private List<WizardDescriptor.Panel<WizardDescriptor>> panels;
46 private final WizardDescriptor.Panel<WizardDescriptor>[] allConfigPanels;
50 private final WizardDescriptor.Panel<WizardDescriptor>[] tableConfigPanels;
54 private final WizardDescriptor.Panel<WizardDescriptor>[] fileConfigPanels;
58 private final WizardDescriptor.Panel<WizardDescriptor>[] portableCaseConfigPanels;
60 @SuppressWarnings({
"rawtypes",
"unchecked"})
61 ReportWizardIterator(String reportingConfigurationName,
boolean useCaseSpecificData) {
63 ReportingConfig config = null;
65 config = ReportingConfigLoader.loadConfig(reportingConfigurationName);
66 }
catch (ReportConfigException ex) {
67 logger.log(Level.SEVERE,
"Unable to load reporting configuration " + reportingConfigurationName +
". Using default settings", ex);
71 firstPanel =
new ReportWizardPanel1(config.getModuleConfigs());
72 tableConfigPanel =
new ReportWizardPanel2(useCaseSpecificData, config.getTableReportSettings());
73 fileConfigPanel =
new ReportWizardFileOptionsPanel(config.getFileReportSettings());
74 portableCaseConfigPanel =
new ReportWizardPortableCaseOptionsPanel(config.getModuleConfigs(), useCaseSpecificData);
76 firstPanel =
new ReportWizardPanel1(null);
77 tableConfigPanel =
new ReportWizardPanel2(useCaseSpecificData, null);
78 fileConfigPanel =
new ReportWizardFileOptionsPanel(null);
79 portableCaseConfigPanel =
new ReportWizardPortableCaseOptionsPanel(null, useCaseSpecificData);
82 allConfigPanels =
new WizardDescriptor.Panel[]{firstPanel, tableConfigPanel, fileConfigPanel, portableCaseConfigPanel};
83 tableConfigPanels =
new WizardDescriptor.Panel[]{firstPanel, tableConfigPanel};
84 fileConfigPanels =
new WizardDescriptor.Panel[]{firstPanel, fileConfigPanel};
85 portableCaseConfigPanels =
new WizardDescriptor.Panel[]{firstPanel, portableCaseConfigPanel};
88 private List<WizardDescriptor.Panel<WizardDescriptor>> getPanels() {
90 panels = Arrays.asList(allConfigPanels);
91 String[] steps =
new String[panels.size()];
92 for (
int i = 0; i < panels.size(); i++) {
93 Component c = panels.get(i).getComponent();
95 steps[i] = c.getName();
96 if (c instanceof JComponent) {
97 JComponent jc = (JComponent) c;
98 jc.putClientProperty(WizardDescriptor.PROP_CONTENT_SELECTED_INDEX, i);
99 jc.putClientProperty(WizardDescriptor.PROP_CONTENT_DATA, steps);
100 jc.putClientProperty(WizardDescriptor.PROP_AUTO_WIZARD_STYLE,
true);
101 jc.putClientProperty(WizardDescriptor.PROP_CONTENT_DISPLAYED,
false);
102 jc.putClientProperty(WizardDescriptor.PROP_CONTENT_NUMBERED,
true);
116 private void enableConfigPanels(
boolean generalModule,
boolean tableModule,
boolean portableCaseModule) {
119 }
else if (tableModule) {
122 panels = Arrays.asList(tableConfigPanels);
123 }
else if (portableCaseModule) {
126 panels = Arrays.asList(portableCaseConfigPanels);
130 panels = Arrays.asList(fileConfigPanels);
135 public WizardDescriptor.Panel<WizardDescriptor> current() {
136 return getPanels().get(index);
140 public String name() {
145 public boolean hasNext() {
146 return index < getPanels().size() - 1;
150 public boolean hasPrevious() {
155 public void nextPanel() {
157 throw new NoSuchElementException();
162 boolean generalModule, tableModule, portableModule;
164 generalModule = NbPreferences.forModule(ReportWizardPanel1.class).getBoolean(
"generalModule",
true);
165 tableModule = NbPreferences.forModule(ReportWizardPanel1.class).getBoolean(
"tableModule",
true);
166 portableModule = NbPreferences.forModule(ReportWizardPanel1.class).getBoolean(
"portableCaseModule",
true);
167 enableConfigPanels(generalModule, tableModule, portableModule);
174 public void previousPanel() {
175 if (!hasPrevious()) {
176 throw new NoSuchElementException();
182 public void addChangeListener(ChangeListener l) {
186 public void removeChangeListener(ChangeListener l) {
synchronized static Logger getLogger(String name)