Autopsy  4.14.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
ConfigWizardPanel3.java
Go to the documentation of this file.
1 /*
2  * Autopsy
3  *
4  * Copyright 2019 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.logicalimager.configuration;
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 javax.swing.event.ChangeEvent;
27 import javax.swing.event.ChangeListener;
28 import org.openide.WizardDescriptor;
29 import org.openide.util.HelpCtx;
30 
34 final class ConfigWizardPanel3 implements WizardDescriptor.Panel<WizardDescriptor> {
35 
36  private final Set<ChangeListener> listeners = new HashSet<>(1); // or can use ChangeSupport in NB 6.0
37  private ConfigVisualPanel3 component;
38 
39  @Override
40  public ConfigVisualPanel3 getComponent() {
41  if (component == null) {
42  component = new ConfigVisualPanel3();
43  component.addPropertyChangeListener(new PropertyChangeListener() {
44  @Override
45  public void propertyChange(PropertyChangeEvent evt) {
46  if (evt.getPropertyName().equals(ConfigVisualPanel3.getSavedEventName())) { // NON-NLS
47  fireChangeEvent();
48  }
49  }
50  });
51  }
52  return component;
53  }
54 
55  @Override
56  public HelpCtx getHelp() {
57  return HelpCtx.DEFAULT_HELP;
58  }
59 
60  @Override
61  public void readSettings(WizardDescriptor wiz) {
62  String configFilename = (String) wiz.getProperty("configFilename"); // NON-NLS
63  LogicalImagerConfig config = (LogicalImagerConfig) wiz.getProperty("config"); // NON-NLS
64  component.setConfigInfoForSaving(configFilename, config);
65  component.resetPanel();
66  }
67 
68  @Override
69  public void storeSettings(WizardDescriptor data) {
70  //no settings to store
71  }
72 
73  @Override
74  public boolean isValid() {
75  return component.isSaved();
76  }
77 
81  private void fireChangeEvent() {
82  Iterator<ChangeListener> it;
83  synchronized (listeners) {
84  it = new HashSet<>(listeners).iterator();
85  }
86  ChangeEvent ev = new ChangeEvent(this);
87  while (it.hasNext()) {
88  it.next().stateChanged(ev);
89  }
90  }
91 
92  @Override
93  public void addChangeListener(ChangeListener cl) {
94  synchronized (listeners) {
95  listeners.add(cl);
96  }
97  }
98 
99  @Override
100  public void removeChangeListener(ChangeListener cl) {
101  synchronized (listeners) {
102  listeners.remove(cl);
103  }
104  }
105 
106 }

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