Autopsy  3.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 
20 package org.sleuthkit.autopsy.casemodule;
21 
22 import java.awt.Component;
23 import java.util.ArrayList;
24 import java.util.List;
25 import java.util.NoSuchElementException;
26 import javax.swing.JComponent;
27 import javax.swing.event.ChangeListener;
28 import org.openide.WizardDescriptor;
29 import org.openide.util.NbBundle;
30 
35 class AddImageWizardIterator implements WizardDescriptor.Iterator<WizardDescriptor> {
36 
37  private int index = 0;
38  private List<WizardDescriptor.Panel<WizardDescriptor>> panels;
39  private AddImageAction action;
40 
41  AddImageWizardIterator(AddImageAction action) {
42  this.action = action;
43  }
44 
49  private List<WizardDescriptor.Panel<WizardDescriptor>> getPanels() {
50  if (panels == null) {
51  panels = new ArrayList<WizardDescriptor.Panel<WizardDescriptor>>();
52 
53  AddImageWizardAddingProgressPanel progressPanel = new AddImageWizardAddingProgressPanel();
54 
55  AddImageWizardChooseDataSourcePanel dsPanel = new AddImageWizardChooseDataSourcePanel(progressPanel);
56  AddImageWizardIngestConfigPanel ingestConfigPanel = new AddImageWizardIngestConfigPanel(dsPanel, action, progressPanel);
57 
58  panels.add(dsPanel);
59  panels.add(ingestConfigPanel);
60  panels.add(progressPanel);
61 
62  String[] steps = new String[panels.size()];
63  for (int i = 0; i < panels.size(); i++) {
64  Component c = panels.get(i).getComponent();
65  // Default step name to component name of panel.
66  steps[i] = c.getName();
67  if (c instanceof JComponent) { // assume Swing components
68  JComponent jc = (JComponent) c;
69  // Sets step number of a component
70  jc.putClientProperty("WizardPanel_contentSelectedIndex", new Integer(i));
71  // Sets steps names for a panel
72  jc.putClientProperty("WizardPanel_contentData", steps);
73  // Turn on subtitle creation on each step
74  jc.putClientProperty("WizardPanel_autoWizardStyle", Boolean.TRUE);
75  // Show steps on the left side with the image on the background
76  jc.putClientProperty("WizardPanel_contentDisplayed", Boolean.TRUE);
77  // Turn on numbering of all steps
78  jc.putClientProperty("WizardPanel_contentNumbered", Boolean.TRUE);
79  }
80  }
81  }
82  return panels;
83  }
84 
91  public int getIndex() {
92  return index;
93  }
94 
100  @Override
101  public WizardDescriptor.Panel<WizardDescriptor> current() {
102  if (panels != null) {
103  return panels.get(index);
104  } else {
105  return getPanels().get(index);
106  }
107  }
108 
114  @Override
115  public String name() {
116  return NbBundle.getMessage(this.getClass(), "AddImageWizardIterator.stepXofN", Integer.toString(index + 1),
117  getPanels().size());
118  }
119 
125  @Override
126  public boolean hasNext() {
127  return index < getPanels().size() - 1;
128  }
129 
135  @Override
136  // disable the previous button on all panels
137  public boolean hasPrevious() {
138  return false;
139  }
140 
145  @Override
146  public void nextPanel() {
147  if (!hasNext()) {
148  throw new NoSuchElementException();
149  }
150  index++;
151  }
152 
157  @Override
158  public void previousPanel() {
159  if (!hasPrevious()) {
160  throw new NoSuchElementException();
161  }
162  if(index == 2)
163  index--;
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-2015 Basis Technology. Generated on: Mon Oct 19 2015
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.