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;
38 class AddImageWizardIterator
implements WizardDescriptor.Iterator<WizardDescriptor> {
40 private int index = 0;
41 private List<ShortcutWizardDescriptorPanel> panels;
42 private final AddImageAction action;
43 private int progressPanelIndex;
44 private int dsPanelIndex;
45 private int hostPanelIndex;
46 private int ingestPanelIndex;
47 private final static String PROP_LASTPROFILE_NAME =
"AIW_LASTPROFILE_NAME";
48 private AddImageWizardSelectHostPanel hostPanel = null;
50 AddImageWizardIterator(AddImageAction action) {
58 private List<ShortcutWizardDescriptorPanel> getPanels() {
60 panels =
new ArrayList<>();
61 hostPanel =
new AddImageWizardSelectHostPanel();
62 panels.add(hostPanel);
63 hostPanelIndex = panels.indexOf(hostPanel);
64 AddImageWizardSelectDspPanel dspSelection =
new AddImageWizardSelectDspPanel();
65 panels.add(dspSelection);
66 AddImageWizardAddingProgressPanel progressPanel =
new AddImageWizardAddingProgressPanel(action);
67 AddImageWizardDataSourceSettingsPanel dsPanel =
new AddImageWizardDataSourceSettingsPanel();
68 AddImageWizardIngestConfigPanel ingestConfigPanel =
new AddImageWizardIngestConfigPanel(progressPanel);
70 List<IngestProfiles.IngestProfile> profiles = IngestProfiles.getIngestProfiles();
71 if (!profiles.isEmpty()) {
72 panels.add(
new IngestProfileSelectionWizardPanel(AddImageWizardIngestConfigPanel.class.getCanonicalName(), getPropLastprofileName()));
74 panels.add(ingestConfigPanel);
75 panels.add(progressPanel);
76 progressPanelIndex = panels.indexOf(progressPanel);
77 dsPanelIndex = panels.indexOf(dsPanel);
78 ingestPanelIndex = panels.indexOf(ingestConfigPanel);
79 String[] steps =
new String[panels.size()];
80 for (
int i = 0; i < panels.size(); i++) {
81 Component c = panels.get(i).getComponent();
83 steps[i] = c.getName();
84 if (c instanceof JComponent) {
85 JComponent jc = (JComponent) c;
87 jc.putClientProperty(
"WizardPanel_contentSelectedIndex", i);
89 jc.putClientProperty(
"WizardPanel_contentData", steps);
91 jc.putClientProperty(
"WizardPanel_autoWizardStyle", Boolean.TRUE);
93 jc.putClientProperty(
"WizardPanel_contentDisplayed", Boolean.TRUE);
95 jc.putClientProperty(
"WizardPanel_contentNumbered", Boolean.TRUE);
108 public int getIndex() {
118 static String getPropLastprofileName() {
119 return PROP_LASTPROFILE_NAME;
125 static String getPROP_LASTPROFILE_NAME() {
126 return PROP_LASTPROFILE_NAME;
135 public ShortcutWizardDescriptorPanel current() {
136 if (panels != null) {
137 return panels.get(index);
139 return getPanels().get(index);
149 public String name() {
150 return NbBundle.getMessage(this.getClass(),
"AddImageWizardIterator.stepXofN", Integer.toString(index + 1),
160 public boolean hasNext() {
161 return index < getPanels().size() - 1;
171 public boolean hasPrevious() {
172 return (index <= dsPanelIndex && index > 0);
180 public void nextPanel() {
182 throw new NoSuchElementException();
187 if (index == ingestPanelIndex) {
188 AddImageWizardAddingProgressPanel addingProgressPanel = (AddImageWizardAddingProgressPanel) panels.get(progressPanelIndex);
189 AddImageWizardDataSourceSettingsVisual dspSettingsPanel = ((AddImageWizardDataSourceSettingsPanel) panels.get(dsPanelIndex)).getComponent();
190 Host host = (hostPanel == null) ? null : hostPanel.getSelectedHost();
191 addingProgressPanel.startDataSourceProcessing(dspSettingsPanel.getCurrentDSProcessor(), host);
193 boolean panelEnablesSkipping = current().panelEnablesSkipping();
194 boolean skipNextPanel = current().skipNextPanel();
196 if (panelEnablesSkipping && skipNextPanel) {
197 current().processThisPanelBeforeSkipped();
207 public void previousPanel() {
208 if (!hasPrevious()) {
209 throw new NoSuchElementException();
211 if (index == progressPanelIndex) {
219 public void addChangeListener(ChangeListener l) {
223 public void removeChangeListener(ChangeListener l) {