19 package org.sleuthkit.autopsy.ingest.runIngestModuleWizard;
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;
35 final class RunIngestModulesWizardIterator
implements WizardDescriptor.Iterator<WizardDescriptor> {
37 private final static String PROP_LASTPROFILE_NAME =
"RIMW_LASTPROFILE_NAME";
38 private final IngestJobSettings.IngestType ingestType;
39 private final List<ShortcutWizardDescriptorPanel> panels;
40 private int currentPanelIndex;
49 RunIngestModulesWizardIterator(String executionContext, IngestJobSettings.IngestType ingestType, List<Content> dataSources) {
50 this.ingestType = ingestType;
51 panels =
new ArrayList<>();
52 List<IngestProfiles.IngestProfile> profiles = IngestProfiles.getIngestProfiles();
53 if (!profiles.isEmpty() && IngestJobSettings.IngestType.FILES_ONLY != this.ingestType) {
54 panels.add(
new IngestProfileSelectionWizardPanel(executionContext, PROP_LASTPROFILE_NAME));
57 panels.add(
new IngestModulesConfigWizardPanel(executionContext, this.ingestType, dataSources));
58 String[] steps =
new String[panels.size()];
59 for (
int i = 0; i < panels.size(); i++) {
60 Component c = panels.get(i).getComponent();
62 if (c instanceof JComponent) {
63 JComponent jc = (JComponent) c;
64 jc.putClientProperty(WizardDescriptor.PROP_CONTENT_SELECTED_INDEX, i);
65 jc.putClientProperty(WizardDescriptor.PROP_CONTENT_DATA, steps);
66 jc.putClientProperty(WizardDescriptor.PROP_AUTO_WIZARD_STYLE,
true);
67 jc.putClientProperty(WizardDescriptor.PROP_CONTENT_DISPLAYED,
true);
68 jc.putClientProperty(WizardDescriptor.PROP_CONTENT_NUMBERED,
true);
73 IngestJobSettings getIngestJobSettings() {
74 ShortcutWizardDescriptorPanel panel = current();
75 if (panel instanceof IngestProfileSelectionWizardPanel) {
76 return ((IngestProfileSelectionWizardPanel) panel).getIngestJobSettings();
78 return ((IngestModulesConfigWizardPanel) panel).getIngestJobSettings();
83 public ShortcutWizardDescriptorPanel current() {
84 return panels.get(currentPanelIndex);
88 public String name() {
89 return currentPanelIndex + 1 +
". from " + panels.size();
93 public boolean hasNext() {
94 return (currentPanelIndex < panels.size() - 1
95 && !(current().panelEnablesSkipping() && current().skipNextPanel()));
99 public boolean hasPrevious() {
100 return currentPanelIndex > 0;
104 public void nextPanel() {
106 throw new NoSuchElementException();
112 public void previousPanel() {
113 if (!hasPrevious()) {
114 throw new NoSuchElementException();
120 public void addChangeListener(ChangeListener l) {
124 public void removeChangeListener(ChangeListener l) {