Autopsy  4.1
Graphical digital forensics platform for The Sleuth Kit and other tools.
NewCaseWizardPanel2.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2011-2015 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.util.HashSet;
22 import java.util.Iterator;
23 import java.util.Set;
24 import javax.swing.event.ChangeEvent;
25 import javax.swing.event.ChangeListener;
26 import org.openide.WizardDescriptor;
27 import org.openide.WizardValidationException;
28 import org.openide.util.HelpCtx;
29 import org.openide.windows.WindowManager;
30 import java.awt.Cursor;
32 
40 class NewCaseWizardPanel2 implements WizardDescriptor.ValidatingPanel<WizardDescriptor> {
41 
46  private NewCaseVisualPanel2 component;
47  private Boolean isFinish = true;
48  private String caseName;
49  private String caseDir;
50  private String createdDirectory;
51  private CaseType caseType;
52 
61  @Override
62  public NewCaseVisualPanel2 getComponent() {
63  if (component == null) {
64  component = new NewCaseVisualPanel2();
65  }
66  return component;
67  }
68 
75  @Override
76  public HelpCtx getHelp() {
77  // Show no Help button for this panel:
78  return HelpCtx.DEFAULT_HELP;
79  // If you have context help:
80  // return new HelpCtx(SampleWizardPanel1.class);
81  }
82 
90  @Override
91  public boolean isValid() {
92  // If it is always OK to press Next or Finish, then:
93  return isFinish;
94  // If it depends on some condition (form filled out...), then:
95  // return someCondition();
96  // and when this condition changes (last form field filled in...) then:
97  // fireChangeEvent();
98  // and uncomment the complicated stuff below.
99  }
100  private final Set<ChangeListener> listeners = new HashSet<ChangeListener>(1); // or can use ChangeSupport in NB 6.0
101 
107  @Override
108  public final void addChangeListener(ChangeListener l) {
109  synchronized (listeners) {
110  listeners.add(l);
111  }
112  }
113 
119  @Override
120  public final void removeChangeListener(ChangeListener l) {
121  synchronized (listeners) {
122  listeners.remove(l);
123  }
124  }
125 
130  protected final void fireChangeEvent() {
131  Iterator<ChangeListener> it;
132  synchronized (listeners) {
133  it = new HashSet<>(listeners).iterator();
134  }
135  ChangeEvent ev = new ChangeEvent(this);
136  while (it.hasNext()) {
137  it.next().stateChanged(ev);
138  }
139  }
140 
141  // You can use a settings object to keep track of state. Normally the
142  // settings object will be the WizardDescriptor, so you can use
143  // WizardDescriptor.getProperty & putProperty to store information entered
144  // by the user.
153  @Override
154  public void readSettings(WizardDescriptor settings) {
155  caseName = (String) settings.getProperty("caseName"); //NON-NLS
156  caseDir = (String) settings.getProperty("caseParentDir"); //NON-NLS
157  createdDirectory = (String) settings.getProperty("createdDirectory"); //NON-NLS
158  caseType = CaseType.values()[(int) settings.getProperty("caseType")]; //NON-NLS
159  }
160 
170  @Override
171  public void storeSettings(WizardDescriptor settings) {
172  NewCaseVisualPanel2 currentComponent = getComponent();
173  settings.putProperty("caseNumber", currentComponent.getCaseNumber()); //NON-NLS
174  settings.putProperty("caseExaminer", currentComponent.getExaminer()); //NON-NLS
175  }
176 
177  @Override
178  public void validate() throws WizardValidationException {
179  WindowManager.getDefault().getMainWindow().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
180  }
181 }

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