Autopsy  4.16.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 @SuppressWarnings("PMD.SingularField") // UI widgets cause lots of false positives
43 class AddImageWizardDataSourceSettingsPanel extends ShortcutWizardDescriptorPanel implements PropertyChangeListener {
44 
49  private AddImageWizardDataSourceSettingsVisual component;
50  private boolean isNextEnable = false;
51  // paths to any set hash lookup databases (can be null)
52 
53  AddImageWizardDataSourceSettingsPanel() {
54  }
55 
64  @Override
65  public AddImageWizardDataSourceSettingsVisual getComponent() {
66  if (component == null) {
67  WindowManager.getDefault().getMainWindow().setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
68  component = new AddImageWizardDataSourceSettingsVisual(this);
69  component.setLocation(WindowManager.getDefault().getMainWindow().getLocation());
70  }
71  component.addPropertyChangeListener(this);
72  return component;
73  }
74 
81  @Override
82  public HelpCtx getHelp() {
83  // Show no Help button for this panel:
84  return HelpCtx.DEFAULT_HELP;
85 
86  }
87 
95  @Override
96  public boolean isValid() {
97  return isNextEnable;
98  }
99 
103  void moveFocusToNext() {
104  // set the focus to the next button of the wizard dialog if it's enabled
105  if (isNextEnable) {
106  Lookup.getDefault().lookup(AddImageAction.class).requestFocusButton(
107  NbBundle.getMessage(this.getClass(), "AddImageWizardChooseDataSourcePanel.moveFocusNext"));
108  }
109  }
110 
116  public void enableNextButton(boolean isEnabled) {
117  isNextEnable = isEnabled;
118  fireChangeEvent();
119  }
120  private final Set<ChangeListener> listeners = new HashSet<>(1); // or can use ChangeSupport in NB 6.0
121 
127  @Override
128  public final void addChangeListener(ChangeListener l) {
129  synchronized (listeners) {
130  listeners.add(l);
131  }
132  }
133 
139  @Override
140  public final void removeChangeListener(ChangeListener l) {
141  synchronized (listeners) {
142  listeners.remove(l);
143  }
144  }
145 
150  protected final void fireChangeEvent() {
151  Iterator<ChangeListener> it;
152  synchronized (listeners) {
153  it = new HashSet<>(listeners).iterator();
154  }
155  ChangeEvent ev = new ChangeEvent(this);
156  while (it.hasNext()) {
157  it.next().stateChanged(ev);
158  }
159  }
160 
169  @Override
170  public void readSettings(WizardDescriptor settings) {
171  // Prepopulate the image directory from the properties file
172  try {
173 
174  // If there is a process object in the settings, revert it and remove it from the settings
175  AddImageAction.CleanupTask cleanupTask = (AddImageAction.CleanupTask) settings.getProperty(AddImageAction.IMAGECLEANUPTASK_PROP);
176  if (cleanupTask != null) {
177  try {
178  cleanupTask.cleanup();
179  } catch (Exception ex) {
180  Logger logger = Logger.getLogger(AddImageWizardDataSourceSettingsPanel.class.getName());
181  logger.log(Level.WARNING, "Error cleaning up image task", ex); //NON-NLS
182  } finally {
183  cleanupTask.disable();
184  }
185  }
186  } catch (Exception e) {
187  }
188  component.setDspSelection((String) settings.getProperty("SelectedDsp")); //NON-NLS magic string used SelectDataSourceProcessorPanel
189  }
190 
200  @Override
201  public void storeSettings(WizardDescriptor settings) {
202  }
203 
210  @Override
211  public void propertyChange(PropertyChangeEvent evt) {
212  fireChangeEvent();
213  }
214 }

Copyright © 2012-2020 Basis Technology. Generated on: Tue Sep 22 2020
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.