Autopsy  4.17.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
RunIngestModulesWizardIterator.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2011-2018 Basis Technology Corp.
5  * Contact: carrier <at> sleuthkit <dot> org
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */
19 package org.sleuthkit.autopsy.ingest.runIngestModuleWizard;
20 
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;
30 import org.sleuthkit.datamodel.Content;
31 
35 final class RunIngestModulesWizardIterator implements WizardDescriptor.Iterator<WizardDescriptor> {
36 
37  private final static String PROP_LASTPROFILE_NAME = "RIMW_LASTPROFILE_NAME"; //NON-NLS
38  private final List<ShortcutWizardDescriptorPanel> panels;
39  private int currentPanelIndex;
40 
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));
53  }
54 
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);
67  }
68  }
69  }
70 
71  IngestJobSettings getIngestJobSettings() {
72  ShortcutWizardDescriptorPanel panel = current();
73  if (panel instanceof IngestProfileSelectionWizardPanel) {
74  return ((IngestProfileSelectionWizardPanel) panel).getIngestJobSettings();
75  } else {
76  return ((IngestModulesConfigWizardPanel) panel).getIngestJobSettings();
77  }
78  }
79 
80  @Override
81  public ShortcutWizardDescriptorPanel current() {
82  return panels.get(currentPanelIndex);
83  }
84 
85  @Override
86  public String name() {
87  return currentPanelIndex + 1 + ". from " + panels.size();
88  }
89 
90  @Override
91  public boolean hasNext() {
92  return (currentPanelIndex < panels.size() - 1
93  && !(current().panelEnablesSkipping() && current().skipNextPanel()));
94  }
95 
96  @Override
97  public boolean hasPrevious() {
98  return currentPanelIndex > 0;
99  }
100 
101  @Override
102  public void nextPanel() {
103  if (!hasNext()) {
104  throw new NoSuchElementException();
105  }
106  currentPanelIndex++;
107  }
108 
109  @Override
110  public void previousPanel() {
111  if (!hasPrevious()) {
112  throw new NoSuchElementException();
113  }
114  currentPanelIndex--;
115  }
116 
117  @Override
118  public void addChangeListener(ChangeListener l) {
119  }
120 
121  @Override
122  public void removeChangeListener(ChangeListener l) {
123  }
124 
125 }

Copyright © 2012-2021 Basis Technology. Generated on: Tue Jan 19 2021
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.