Autopsy  4.1
Graphical digital forensics platform for The Sleuth Kit and other tools.
AddImageWizardIterator.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2011 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.casemodule;
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;
28 import org.openide.util.NbBundle;
29 
34 class AddImageWizardIterator implements WizardDescriptor.Iterator<WizardDescriptor> {
35 
36  private int index = 0;
37  private List<WizardDescriptor.Panel<WizardDescriptor>> panels;
38  private AddImageAction action;
39 
40  AddImageWizardIterator(AddImageAction action) {
41  this.action = action;
42  }
43 
48  private List<WizardDescriptor.Panel<WizardDescriptor>> getPanels() {
49  if (panels == null) {
50  panels = new ArrayList<WizardDescriptor.Panel<WizardDescriptor>>();
51 
52  AddImageWizardAddingProgressPanel progressPanel = new AddImageWizardAddingProgressPanel();
53 
54  AddImageWizardChooseDataSourcePanel dsPanel = new AddImageWizardChooseDataSourcePanel(progressPanel);
55  AddImageWizardIngestConfigPanel ingestConfigPanel = new AddImageWizardIngestConfigPanel(dsPanel, action, progressPanel);
56 
57  panels.add(dsPanel);
58  panels.add(ingestConfigPanel);
59  panels.add(progressPanel);
60 
61  String[] steps = new String[panels.size()];
62  for (int i = 0; i < panels.size(); i++) {
63  Component c = panels.get(i).getComponent();
64  // Default step name to component name of panel.
65  steps[i] = c.getName();
66  if (c instanceof JComponent) { // assume Swing components
67  JComponent jc = (JComponent) c;
68  // Sets step number of a component
69  jc.putClientProperty("WizardPanel_contentSelectedIndex", new Integer(i));
70  // Sets steps names for a panel
71  jc.putClientProperty("WizardPanel_contentData", steps);
72  // Turn on subtitle creation on each step
73  jc.putClientProperty("WizardPanel_autoWizardStyle", Boolean.TRUE);
74  // Show steps on the left side with the image on the background
75  jc.putClientProperty("WizardPanel_contentDisplayed", Boolean.TRUE);
76  // Turn on numbering of all steps
77  jc.putClientProperty("WizardPanel_contentNumbered", Boolean.TRUE);
78  }
79  }
80  }
81  return panels;
82  }
83 
90  public int getIndex() {
91  return index;
92  }
93 
99  @Override
100  public WizardDescriptor.Panel<WizardDescriptor> current() {
101  if (panels != null) {
102  return panels.get(index);
103  } else {
104  return getPanels().get(index);
105  }
106  }
107 
113  @Override
114  public String name() {
115  return NbBundle.getMessage(this.getClass(), "AddImageWizardIterator.stepXofN", Integer.toString(index + 1),
116  getPanels().size());
117  }
118 
124  @Override
125  public boolean hasNext() {
126  return index < getPanels().size() - 1;
127  }
128 
134  @Override
135  // disable the previous button on all panels
136  public boolean hasPrevious() {
137  return false;
138  }
139 
144  @Override
145  public void nextPanel() {
146  if (!hasNext()) {
147  throw new NoSuchElementException();
148  }
149  index++;
150  }
151 
156  @Override
157  public void previousPanel() {
158  if (!hasPrevious()) {
159  throw new NoSuchElementException();
160  }
161  if (index == 2) {
162  index--;
163  }
164  index--;
165  }
166 
167  // If nothing unusual changes in the middle of the wizard, simply:
168  @Override
169  public void addChangeListener(ChangeListener l) {
170  }
171 
172  @Override
173  public void removeChangeListener(ChangeListener l) {
174  }
175 }

Copyright © 2012-2016 Basis Technology. Generated on: Mon Jan 2 2017
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.