Autopsy  4.6.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-2018 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  component.setLocation(WindowManager.getDefault().getMainWindow().getLocation());
69  }
70  component.addPropertyChangeListener(this);
71  return component;
72  }
73 
80  @Override
81  public HelpCtx getHelp() {
82  // Show no Help button for this panel:
83  return HelpCtx.DEFAULT_HELP;
84 
85  }
86 
94  @Override
95  public boolean isValid() {
96  return isNextEnable;
97  }
98 
102  void moveFocusToNext() {
103  // set the focus to the next button of the wizard dialog if it's enabled
104  if (isNextEnable) {
105  Lookup.getDefault().lookup(AddImageAction.class).requestFocusButton(
106  NbBundle.getMessage(this.getClass(), "AddImageWizardChooseDataSourcePanel.moveFocusNext"));
107  }
108  }
109 
115  public void enableNextButton(boolean isEnabled) {
116  isNextEnable = isEnabled;
117  fireChangeEvent();
118  }
119  private final Set<ChangeListener> listeners = new HashSet<>(1); // or can use ChangeSupport in NB 6.0
120 
126  @Override
127  public final void addChangeListener(ChangeListener l) {
128  synchronized (listeners) {
129  listeners.add(l);
130  }
131  }
132 
138  @Override
139  public final void removeChangeListener(ChangeListener l) {
140  synchronized (listeners) {
141  listeners.remove(l);
142  }
143  }
144 
149  protected final void fireChangeEvent() {
150  Iterator<ChangeListener> it;
151  synchronized (listeners) {
152  it = new HashSet<>(listeners).iterator();
153  }
154  ChangeEvent ev = new ChangeEvent(this);
155  while (it.hasNext()) {
156  it.next().stateChanged(ev);
157  }
158  }
159 
168  @Override
169  public void readSettings(WizardDescriptor settings) {
170  // Prepopulate the image directory from the properties file
171  try {
172 
173  // If there is a process object in the settings, revert it and remove it from the settings
174  AddImageAction.CleanupTask cleanupTask = (AddImageAction.CleanupTask) settings.getProperty(AddImageAction.IMAGECLEANUPTASK_PROP);
175  if (cleanupTask != null) {
176  try {
177  cleanupTask.cleanup();
178  } catch (Exception ex) {
179  Logger logger = Logger.getLogger(AddImageWizardDataSourceSettingsPanel.class.getName());
180  logger.log(Level.WARNING, "Error cleaning up image task", ex); //NON-NLS
181  } finally {
182  cleanupTask.disable();
183  }
184  }
185  } catch (Exception e) {
186  }
187  component.setDspSelection((String) settings.getProperty("SelectedDsp")); //NON-NLS magic string used SelectDataSourceProcessorPanel
188  }
189 
199  @Override
200  public void storeSettings(WizardDescriptor settings) {
201  }
202 
209  @Override
210  public void propertyChange(PropertyChangeEvent evt) {
211  fireChangeEvent();
212  }
213 }

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