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 List<ShortcutWizardDescriptorPanel> panels;
39 private int currentPanelIndex;
48 RunIngestModulesWizardIterator(String executionContext, IngestJobSettings.IngestType ingestType, List<Content> dataSources) {
49 panels =
new ArrayList<>();
50 List<IngestProfiles.IngestProfile> profiles = IngestProfiles.getIngestProfiles();
51 if (!profiles.isEmpty() && IngestJobSettings.IngestType.FILES_ONLY != ingestType) {
52 panels.add(
new IngestProfileSelectionWizardPanel(executionContext, PROP_LASTPROFILE_NAME));
55 panels.add(
new IngestModulesConfigWizardPanel(executionContext, ingestType, dataSources));
56 String[] steps =
new String[panels.size()];
57 for (
int i = 0; i < panels.size(); i++) {
58 Component c = panels.get(i).getComponent();
59 steps[i] = c.getName();
60 if (c instanceof JComponent) {
61 JComponent jc = (JComponent) c;
62 jc.putClientProperty(WizardDescriptor.PROP_CONTENT_SELECTED_INDEX, i);
63 jc.putClientProperty(WizardDescriptor.PROP_CONTENT_DATA, steps);
64 jc.putClientProperty(WizardDescriptor.PROP_AUTO_WIZARD_STYLE,
true);
65 jc.putClientProperty(WizardDescriptor.PROP_CONTENT_DISPLAYED,
true);
66 jc.putClientProperty(WizardDescriptor.PROP_CONTENT_NUMBERED,
true);
71 IngestJobSettings getIngestJobSettings() {
72 ShortcutWizardDescriptorPanel panel = current();
73 if (panel instanceof IngestProfileSelectionWizardPanel) {
74 return ((IngestProfileSelectionWizardPanel) panel).getIngestJobSettings();
76 return ((IngestModulesConfigWizardPanel) panel).getIngestJobSettings();
81 public ShortcutWizardDescriptorPanel current() {
82 return panels.get(currentPanelIndex);
86 public String name() {
87 return currentPanelIndex + 1 +
". from " + panels.size();
91 public boolean hasNext() {
92 return (currentPanelIndex < panels.size() - 1
93 && !(current().panelEnablesSkipping() && current().skipNextPanel()));
97 public boolean hasPrevious() {
98 return currentPanelIndex > 0;
102 public void nextPanel() {
104 throw new NoSuchElementException();
110 public void previousPanel() {
111 if (!hasPrevious()) {
112 throw new NoSuchElementException();
118 public void addChangeListener(ChangeListener l) {
122 public void removeChangeListener(ChangeListener l) {