Autopsy  4.5.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
AddImageWizardDataSourceSettingsPanel.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2011-2017 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.util.HashSet;
24 import java.util.Iterator;
25 import java.util.Set;
26 import java.util.logging.Level;
27 import org.openide.util.NbBundle;
29 import javax.swing.event.ChangeEvent;
30 import javax.swing.event.ChangeListener;
31 import org.openide.WizardDescriptor;
32 import org.openide.util.HelpCtx;
33 import org.openide.util.Lookup;
34 import org.openide.windows.WindowManager;
35 import java.awt.Cursor;
37 
42 class AddImageWizardDataSourceSettingsPanel extends ShortcutWizardDescriptorPanel implements PropertyChangeListener {
43 
48  private AddImageWizardDataSourceSettingsVisual component;
49  private boolean isNextEnable = false;
50  // paths to any set hash lookup databases (can be null)
51 
52  AddImageWizardDataSourceSettingsPanel() {
53  }
54 
63  @Override
64  public AddImageWizardDataSourceSettingsVisual getComponent() {
65  if (component == null) {
66  WindowManager.getDefault().getMainWindow().setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
67  component = new AddImageWizardDataSourceSettingsVisual(this);
68  }
69  component.addPropertyChangeListener(this);
70  return component;
71  }
72 
79  @Override
80  public HelpCtx getHelp() {
81  // Show no Help button for this panel:
82  return HelpCtx.DEFAULT_HELP;
83 
84  }
85 
93  @Override
94  public boolean isValid() {
95  return isNextEnable;
96  }
97 
101  void moveFocusToNext() {
102  // set the focus to the next button of the wizard dialog if it's enabled
103  if (isNextEnable) {
104  Lookup.getDefault().lookup(AddImageAction.class).requestFocusButton(
105  NbBundle.getMessage(this.getClass(), "AddImageWizardChooseDataSourcePanel.moveFocusNext"));
106  }
107  }
108 
114  public void enableNextButton(boolean isEnabled) {
115  isNextEnable = isEnabled;
116  fireChangeEvent();
117  }
118  private final Set<ChangeListener> listeners = new HashSet<>(1); // or can use ChangeSupport in NB 6.0
119 
125  @Override
126  public final void addChangeListener(ChangeListener l) {
127  synchronized (listeners) {
128  listeners.add(l);
129  }
130  }
131 
137  @Override
138  public final void removeChangeListener(ChangeListener l) {
139  synchronized (listeners) {
140  listeners.remove(l);
141  }
142  }
143 
148  protected final void fireChangeEvent() {
149  Iterator<ChangeListener> it;
150  synchronized (listeners) {
151  it = new HashSet<>(listeners).iterator();
152  }
153  ChangeEvent ev = new ChangeEvent(this);
154  while (it.hasNext()) {
155  it.next().stateChanged(ev);
156  }
157  }
158 
167  @Override
168  public void readSettings(WizardDescriptor settings) {
169  // Prepopulate the image directory from the properties file
170  try {
171 
172  // If there is a process object in the settings, revert it and remove it from the settings
173  AddImageAction.CleanupTask cleanupTask = (AddImageAction.CleanupTask) settings.getProperty(AddImageAction.IMAGECLEANUPTASK_PROP);
174  if (cleanupTask != null) {
175  try {
176  cleanupTask.cleanup();
177  } catch (Exception ex) {
178  Logger logger = Logger.getLogger(AddImageWizardDataSourceSettingsPanel.class.getName());
179  logger.log(Level.WARNING, "Error cleaning up image task", ex); //NON-NLS
180  } finally {
181  cleanupTask.disable();
182  }
183  }
184  } catch (Exception e) {
185  }
186  component.setDspSelection((String) settings.getProperty("SelectedDsp")); //NON-NLS magic string used SelectDataSourceProcessorPanel
187  }
188 
198  @Override
199  public void storeSettings(WizardDescriptor settings) {
200  }
201 
208  @Override
209  public void propertyChange(PropertyChangeEvent evt) {
210  fireChangeEvent();
211  }
212 }

Copyright © 2012-2016 Basis Technology. Generated on: Tue Feb 20 2018
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.