Autopsy  4.5.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-2017 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 IngestJobSettings.IngestType ingestType;
39  private final List<ShortcutWizardDescriptorPanel> panels;
40  private int currentPanelIndex;
41 
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));
55  }
56 
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();
61  steps[i] = c.getName();
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);
69  }
70  }
71  }
72 
73  IngestJobSettings getIngestJobSettings() {
74  ShortcutWizardDescriptorPanel panel = current();
75  if (panel instanceof IngestProfileSelectionWizardPanel) {
76  return ((IngestProfileSelectionWizardPanel) panel).getIngestJobSettings();
77  } else {
78  return ((IngestModulesConfigWizardPanel) panel).getIngestJobSettings();
79  }
80  }
81 
82  @Override
83  public ShortcutWizardDescriptorPanel current() {
84  return panels.get(currentPanelIndex);
85  }
86 
87  @Override
88  public String name() {
89  return currentPanelIndex + 1 + ". from " + panels.size();
90  }
91 
92  @Override
93  public boolean hasNext() {
94  return (currentPanelIndex < panels.size() - 1
95  && !(current().panelEnablesSkipping() && current().skipNextPanel()));
96  }
97 
98  @Override
99  public boolean hasPrevious() {
100  return currentPanelIndex > 0;
101  }
102 
103  @Override
104  public void nextPanel() {
105  if (!hasNext()) {
106  throw new NoSuchElementException();
107  }
108  currentPanelIndex++;
109  }
110 
111  @Override
112  public void previousPanel() {
113  if (!hasPrevious()) {
114  throw new NoSuchElementException();
115  }
116  currentPanelIndex--;
117  }
118 
119  @Override
120  public void addChangeListener(ChangeListener l) {
121  }
122 
123  @Override
124  public void removeChangeListener(ChangeListener l) {
125  }
126 
127 }

Copyright © 2012-2016 Basis Technology. Generated on: Tue Feb 20 2018
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.