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 final static String PROP_LASTPROFILE_NAME =
"AIW_LASTPROFILE_NAME";
46 AddImageWizardIterator(AddImageAction action) {
54 private List<ShortcutWizardDescriptorPanel> getPanels() {
56 panels =
new ArrayList<>();
57 AddImageWizardSelectDspPanel dspSelection =
new AddImageWizardSelectDspPanel();
58 panels.add(dspSelection);
59 AddImageWizardAddingProgressPanel progressPanel =
new AddImageWizardAddingProgressPanel(action);
61 AddImageWizardDataSourceSettingsPanel dsPanel =
new AddImageWizardDataSourceSettingsPanel();
62 AddImageWizardIngestConfigPanel ingestConfigPanel =
new AddImageWizardIngestConfigPanel(progressPanel);
64 List<IngestProfiles.IngestProfile> profiles = IngestProfiles.getIngestProfiles();
65 if (!profiles.isEmpty()) {
66 panels.add(
new IngestProfileSelectionWizardPanel(AddImageWizardIngestConfigPanel.class.getCanonicalName(), getPropLastprofileName()));
68 panels.add(ingestConfigPanel);
69 panels.add(progressPanel);
70 progressPanelIndex = panels.indexOf(progressPanel);
71 dsPanelIndex = panels.indexOf(dsPanel);
72 String[] steps =
new String[panels.size()];
73 for (
int i = 0; i < panels.size(); i++) {
74 Component c = panels.get(i).getComponent();
76 steps[i] = c.getName();
77 if (c instanceof JComponent) {
78 JComponent jc = (JComponent) c;
80 jc.putClientProperty(
"WizardPanel_contentSelectedIndex", i);
82 jc.putClientProperty(
"WizardPanel_contentData", steps);
84 jc.putClientProperty(
"WizardPanel_autoWizardStyle", Boolean.TRUE);
86 jc.putClientProperty(
"WizardPanel_contentDisplayed", Boolean.TRUE);
88 jc.putClientProperty(
"WizardPanel_contentNumbered", Boolean.TRUE);
101 public int getIndex() {
111 static String getPropLastprofileName() {
112 return PROP_LASTPROFILE_NAME;
118 static String getPROP_LASTPROFILE_NAME() {
119 return PROP_LASTPROFILE_NAME;
128 public ShortcutWizardDescriptorPanel current() {
129 if (panels != null) {
130 return panels.get(index);
132 return getPanels().get(index);
142 public String name() {
143 return NbBundle.getMessage(this.getClass(),
"AddImageWizardIterator.stepXofN", Integer.toString(index + 1),
153 public boolean hasNext() {
154 return index < getPanels().size() - 1;
164 public boolean hasPrevious() {
165 return (index == dsPanelIndex);
173 public void nextPanel() {
175 throw new NoSuchElementException();
180 if (index == dsPanelIndex) {
181 ((AddImageWizardAddingProgressPanel) panels.get(progressPanelIndex)).
182 startDataSourceProcessing(((AddImageWizardDataSourceSettingsPanel) panels.get(dsPanelIndex)).getComponent().getCurrentDSProcessor());
184 boolean panelEnablesSkipping = current().panelEnablesSkipping();
185 boolean skipNextPanel = current().skipNextPanel();
187 if (panelEnablesSkipping && skipNextPanel) {
188 current().processThisPanelBeforeSkipped();
198 public void previousPanel() {
199 if (!hasPrevious()) {
200 throw new NoSuchElementException();
202 if (index == progressPanelIndex) {
210 public void addChangeListener(ChangeListener l) {
214 public void removeChangeListener(ChangeListener l) {