Autopsy  4.14.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
HashDatabaseOptionsPanelController.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.modules.hashdatabase;
20 
21 import java.beans.PropertyChangeEvent;
22 import java.beans.PropertyChangeListener;
23 import java.beans.PropertyChangeSupport;
24 import javax.swing.JComponent;
25 import org.netbeans.spi.options.OptionsPanelController;
26 import org.openide.util.HelpCtx;
27 import org.openide.util.Lookup;
29 
30 @OptionsPanelController.TopLevelRegistration(
31  categoryName = "#OptionsCategory_Name_HashDatabase",
32  iconBase = "org/sleuthkit/autopsy/modules/hashdatabase/options_icon.png",
33  position = 8,
34  keywords = "#OptionsCategory_Keywords_HashDatabase",
35  keywordsCategory = "HashDatabase",
36  id = "HashDatabase")
37 // moved messages to Bundle.properties
38 //@org.openide.util.NbBundle.Messages({"OptionsCategory_Name_HashDatabase=Hash Set", "OptionsCategory_Keywords_HashDatabase=Hash Set"})
39 public final class HashDatabaseOptionsPanelController extends OptionsPanelController {
40 
42  private final PropertyChangeSupport pcs = new PropertyChangeSupport(this);
43  private boolean changed;
44  private static final Logger logger = Logger.getLogger(HashDatabaseOptionsPanelController.class.getName());
45 
49  @Override
50  public void update() {
51  getPanel().load();
52  changed = false;
53  }
54 
60  @Override
61  public void applyChanges() {
62  if (changed) {
63  getPanel().store();
64  changed = false;
65  }
66  }
67 
73  @Override
74  public void cancel() {
75  getPanel().cancel();
76  }
77 
78  @Override
79  public boolean isValid() {
80  return getPanel().valid();
81  }
82 
89  @Override
90  public boolean isChanged() {
91  return changed;
92  }
93 
94  @Override
95  public HelpCtx getHelpCtx() {
96  return null; // new HelpCtx("...ID") if you have a help set
97  }
98 
99  @Override
100  public JComponent getComponent(Lookup masterLookup) {
101  return getPanel();
102  }
103 
104  @Override
105  public void addPropertyChangeListener(PropertyChangeListener l) {
106  pcs.addPropertyChangeListener(l);
107  }
108 
109  @Override
110  public void removePropertyChangeListener(PropertyChangeListener l) {
111  pcs.removePropertyChangeListener(l);
112  }
113 
115  if (panel == null) {
116  panel = new HashLookupSettingsPanel();
117  panel.addPropertyChangeListener(new PropertyChangeListener() {
118  @Override
119  public void propertyChange(PropertyChangeEvent evt) {
120  if (evt.getPropertyName().equals(OptionsPanelController.PROP_CHANGED)) {
121  changed();
122  }
123  }
124  });
125  }
126  return panel;
127  }
128 
129  void changed() {
130  if (!changed) {
131  changed = true;
132 
133  pcs.firePropertyChange(OptionsPanelController.PROP_CHANGED, false, true);
134  }
135 
136  pcs.firePropertyChange(OptionsPanelController.PROP_VALID, null, null);
137  }
138 }
synchronized static Logger getLogger(String name)
Definition: Logger.java:124

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.