19 package org.sleuthkit.autopsy.casemodule;
21 import java.awt.Component;
22 import java.util.ArrayList;
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.NbBundle;
37 class AddImageWizardIterator
implements WizardDescriptor.Iterator<WizardDescriptor> {
39 private int index = 0;
40 private List<ShortcutWizardDescriptorPanel> panels;
41 private final AddImageAction action;
42 private int progressPanelIndex;
43 private int dsPanelIndex;
44 private int ingestPanelIndex;
45 private final static String PROP_LASTPROFILE_NAME =
"AIW_LASTPROFILE_NAME";
47 AddImageWizardIterator(AddImageAction action) {
55 private List<ShortcutWizardDescriptorPanel> getPanels() {
57 panels =
new ArrayList<>();
58 AddImageWizardSelectDspPanel dspSelection =
new AddImageWizardSelectDspPanel();
59 panels.add(dspSelection);
60 AddImageWizardAddingProgressPanel progressPanel =
new AddImageWizardAddingProgressPanel(action);
62 AddImageWizardDataSourceSettingsPanel dsPanel =
new AddImageWizardDataSourceSettingsPanel();
63 AddImageWizardIngestConfigPanel ingestConfigPanel =
new AddImageWizardIngestConfigPanel(progressPanel);
65 List<IngestProfiles.IngestProfile> profiles = IngestProfiles.getIngestProfiles();
66 if (!profiles.isEmpty()) {
67 panels.add(
new IngestProfileSelectionWizardPanel(AddImageWizardIngestConfigPanel.class.getCanonicalName(), getPropLastprofileName()));
69 panels.add(ingestConfigPanel);
70 panels.add(progressPanel);
71 progressPanelIndex = panels.indexOf(progressPanel);
72 dsPanelIndex = panels.indexOf(dsPanel);
73 ingestPanelIndex = panels.indexOf(ingestConfigPanel);
74 String[] steps =
new String[panels.size()];
75 for (
int i = 0; i < panels.size(); i++) {
76 Component c = panels.get(i).getComponent();
78 steps[i] = c.getName();
79 if (c instanceof JComponent) {
80 JComponent jc = (JComponent) c;
82 jc.putClientProperty(
"WizardPanel_contentSelectedIndex", i);
84 jc.putClientProperty(
"WizardPanel_contentData", steps);
86 jc.putClientProperty(
"WizardPanel_autoWizardStyle", Boolean.TRUE);
88 jc.putClientProperty(
"WizardPanel_contentDisplayed", Boolean.TRUE);
90 jc.putClientProperty(
"WizardPanel_contentNumbered", Boolean.TRUE);
103 public int getIndex() {
113 static String getPropLastprofileName() {
114 return PROP_LASTPROFILE_NAME;
120 static String getPROP_LASTPROFILE_NAME() {
121 return PROP_LASTPROFILE_NAME;
130 public ShortcutWizardDescriptorPanel current() {
131 if (panels != null) {
132 return panels.get(index);
134 return getPanels().get(index);
144 public String name() {
145 return NbBundle.getMessage(this.getClass(),
"AddImageWizardIterator.stepXofN", Integer.toString(index + 1),
155 public boolean hasNext() {
156 return index < getPanels().size() - 1;
166 public boolean hasPrevious() {
167 return (index == dsPanelIndex);
175 public void nextPanel() {
177 throw new NoSuchElementException();
182 if (index == ingestPanelIndex) {
183 ((AddImageWizardAddingProgressPanel) panels.get(progressPanelIndex)).
184 startDataSourceProcessing(((AddImageWizardDataSourceSettingsPanel) panels.get(dsPanelIndex)).getComponent().getCurrentDSProcessor());
186 boolean panelEnablesSkipping = current().panelEnablesSkipping();
187 boolean skipNextPanel = current().skipNextPanel();
189 if (panelEnablesSkipping && skipNextPanel) {
190 current().processThisPanelBeforeSkipped();
200 public void previousPanel() {
201 if (!hasPrevious()) {
202 throw new NoSuchElementException();
204 if (index == progressPanelIndex) {
212 public void addChangeListener(ChangeListener l) {
216 public void removeChangeListener(ChangeListener l) {