Autopsy  3.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 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.util.HashSet;
23 import java.util.Iterator;
24 import java.util.Set;
25 import javax.swing.SwingUtilities;
26 import javax.swing.event.ChangeEvent;
27 import javax.swing.event.ChangeListener;
28 import org.openide.WizardDescriptor;
29 import org.openide.WizardValidationException;
30 import org.openide.util.Exceptions;
31 import org.openide.util.HelpCtx;
32 import org.openide.util.NbBundle;
33 
41 class NewCaseWizardPanel2 implements WizardDescriptor.ValidatingPanel<WizardDescriptor> {
42 
47  private NewCaseVisualPanel2 component;
48  private Boolean isFinish = true;
49  private String caseName;
50  private String caseDir;
51  private String createdDirectory;
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 
89  @Override
90  public boolean isValid() {
91  // If it is always OK to press Next or Finish, then:
92  return isFinish;
93  // If it depends on some condition (form filled out...), then:
94  // return someCondition();
95  // and when this condition changes (last form field filled in...) then:
96  // fireChangeEvent();
97  // and uncomment the complicated stuff below.
98  }
99  private final Set<ChangeListener> listeners = new HashSet<ChangeListener>(1); // or can use ChangeSupport in NB 6.0
100 
106  @Override
107  public final void addChangeListener(ChangeListener l) {
108  synchronized (listeners) {
109  listeners.add(l);
110  }
111  }
112 
118  @Override
119  public final void removeChangeListener(ChangeListener l) {
120  synchronized (listeners) {
121  listeners.remove(l);
122  }
123  }
124 
129  protected final void fireChangeEvent() {
130  Iterator<ChangeListener> it;
131  synchronized (listeners) {
132  it = new HashSet<ChangeListener>(listeners).iterator();
133  }
134  ChangeEvent ev = new ChangeEvent(this);
135  while (it.hasNext()) {
136  it.next().stateChanged(ev);
137  }
138  }
139 
140  // You can use a settings object to keep track of state. Normally the
141  // settings object will be the WizardDescriptor, so you can use
142  // WizardDescriptor.getProperty & putProperty to store information entered
143  // by the user.
152  @Override
153  public void readSettings(WizardDescriptor settings) {
154  caseName = (String) settings.getProperty("caseName"); //NON-NLS
155  caseDir = (String) settings.getProperty("caseParentDir"); //NON-NLS
156  createdDirectory = (String) settings.getProperty("createdDirectory"); //NON-NLS
157  }
158 
168  @Override
169  public void storeSettings(WizardDescriptor settings) {
170  }
171 
172  @Override
173  public void validate() throws WizardValidationException {
174 
175  NewCaseVisualPanel2 currentComponent = getComponent();
176  final String caseNumber = currentComponent.getCaseNumber();
177  final String examiner = currentComponent.getExaminer();
178  try {
179  SwingUtilities.invokeLater(new Runnable(){
180 
181  @Override
182  public void run() {
183  try {
184  Case.create(createdDirectory, caseName, caseNumber, examiner);
185  } catch (Exception ex) {
186  Exceptions.printStackTrace(ex);
187  }
188  }
189 
190  });
191 
192  //Case.create(createdDirectory, caseName, caseNumber, examiner);
193  } catch(Exception ex) {
194  throw new WizardValidationException(this.getComponent(),
195  NbBundle.getMessage(this.getClass(),
196  "NewCaseWizardPanel2.validate.errCreateCase.msg"),
197  null);
198  }
199  }
200 }

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.