Autopsy  3.1
Graphical digital forensics platform for The Sleuth Kit and other tools.
AddImageWizardChooseDataSourcePanel.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.beans.PropertyChangeEvent;
22 import java.beans.PropertyChangeListener;
23 import java.io.File;
24 import java.util.HashSet;
25 import java.util.Iterator;
26 import java.util.Set;
27 import java.util.logging.Level;
28 
29 import org.openide.util.NbBundle;
31 import javax.swing.event.ChangeEvent;
32 import javax.swing.event.ChangeListener;
33 import org.openide.WizardDescriptor;
34 import org.openide.util.HelpCtx;
35 import org.openide.util.Lookup;
37 
42 class AddImageWizardChooseDataSourcePanel implements WizardDescriptor.Panel<WizardDescriptor>, PropertyChangeListener {
43 
48  private AddImageWizardAddingProgressPanel progressPanel;
49  private AddImageWizardChooseDataSourceVisual component;
50  private boolean isNextEnable = false;
51  private static final String PROP_LASTDATASOURCE_PATH = "LBL_LastDataSource_PATH"; //NON-NLS
52  private static final String PROP_LASTDATASOURCE_TYPE = "LBL_LastDataSource_TYPE"; //NON-NLS
53  // paths to any set hash lookup databases (can be null)
54  private String NSRLPath, knownBadPath;
55 
56 
57  AddImageWizardChooseDataSourcePanel(AddImageWizardAddingProgressPanel proPanel) {
58 
59  this.progressPanel = proPanel;
60 
61  }
70  @Override
71  public AddImageWizardChooseDataSourceVisual getComponent() {
72  if (component == null) {
73  component = new AddImageWizardChooseDataSourceVisual(this);
74  }
75  component.addPropertyChangeListener(this);
76  return component;
77  }
78 
85  @Override
86  public HelpCtx getHelp() {
87  // Show no Help button for this panel:
88  return HelpCtx.DEFAULT_HELP;
89  // If you have context help:
90  // return new HelpCtx(SampleWizardPanel1.class);
91  }
92 
100  @Override
101  public boolean isValid() {
102  return isNextEnable;
103  }
104 
108  void moveFocusToNext() {
109  // set the focus to the next button of the wizard dialog if it's enabled
110  if (isNextEnable) {
111  Lookup.getDefault().lookup(AddImageAction.class).requestFocusButton(
112  NbBundle.getMessage(this.getClass(), "AddImageWizardChooseDataSourcePanel.moveFocusNext"));
113  }
114  }
115 
121  public void enableNextButton(boolean isEnabled) {
122  isNextEnable = isEnabled;
123  fireChangeEvent();
124  }
125  private final Set<ChangeListener> listeners = new HashSet<ChangeListener>(1); // or can use ChangeSupport in NB 6.0
126 
132  @Override
133  public final void addChangeListener(ChangeListener l) {
134  synchronized (listeners) {
135  listeners.add(l);
136  }
137  }
138 
144  @Override
145  public final void removeChangeListener(ChangeListener l) {
146  synchronized (listeners) {
147  listeners.remove(l);
148  }
149  }
150 
155  protected final void fireChangeEvent() {
156  Iterator<ChangeListener> it;
157  synchronized (listeners) {
158  it = new HashSet<ChangeListener>(listeners).iterator();
159  }
160  ChangeEvent ev = new ChangeEvent(this);
161  while (it.hasNext()) {
162  it.next().stateChanged(ev);
163  }
164  }
165 
166  // You can use a settings object to keep track of state. Normally the
167  // settings object will be the WizardDescriptor, so you can use
168  // WizardDescriptor.getProperty & putProperty to store information entered
169  // by the user.
178  @Override
179  public void readSettings(WizardDescriptor settings) {
180 
181  //reset settings if supports it
182  //getComponent().reset();
183 
184  // Prepopulate the image directory from the properties file
185  try {
186 
187  // Load hash database settings, enable or disable the checkbox
188  this.NSRLPath = null;
189  this.knownBadPath = null;
190  //JCheckBox lookupFilesCheckbox = component.getLookupFilesCheckbox();
191  //lookupFilesCheckbox.setSelected(false);
192  //lookupFilesCheckbox.setEnabled(this.NSRLPath != null || this.knownBadPath != null);
193 
194  // If there is a process object in the settings, revert it and remove it from the settings
195  AddImageAction.CleanupTask cleanupTask = (AddImageAction.CleanupTask) settings.getProperty(AddImageAction.IMAGECLEANUPTASK_PROP);
196  if (cleanupTask != null) {
197  try {
198  cleanupTask.cleanup();
199  } catch (Exception ex) {
200  Logger logger = Logger.getLogger(AddImageWizardChooseDataSourcePanel.class.getName());
201  logger.log(Level.WARNING, "Error cleaning up image task", ex); //NON-NLS
202  } finally {
203  cleanupTask.disable();
204  }
205  }
206  } catch (Exception e) {
207  }
208 
209  }
210 
220  @Override
221  public void storeSettings(WizardDescriptor settings) {
222 
223  return;
224  }
225 
232  @Override
233  public void propertyChange(PropertyChangeEvent evt) {
234  fireChangeEvent();
235  }
236 }

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.