Autopsy  4.20.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  if(changed) {
76  getPanel().cancel();
77  changed = false;
78  }
79  }
80 
81  @Override
82  public boolean isValid() {
83  return getPanel().valid();
84  }
85 
92  @Override
93  public boolean isChanged() {
94  return changed;
95  }
96 
97  @Override
98  public HelpCtx getHelpCtx() {
99  return null; // new HelpCtx("...ID") if you have a help set
100  }
101 
102  @Override
103  public JComponent getComponent(Lookup masterLookup) {
104  return getPanel();
105  }
106 
107  @Override
108  public void addPropertyChangeListener(PropertyChangeListener l) {
109  pcs.addPropertyChangeListener(l);
110  }
111 
112  @Override
113  public void removePropertyChangeListener(PropertyChangeListener l) {
114  pcs.removePropertyChangeListener(l);
115  }
116 
118  if (panel == null) {
119  panel = new HashLookupSettingsPanel();
120  panel.addPropertyChangeListener(new PropertyChangeListener() {
121  @Override
122  public void propertyChange(PropertyChangeEvent evt) {
123  if (evt.getPropertyName().equals(OptionsPanelController.PROP_CHANGED)) {
124  changed();
125  }
126  }
127  });
128  }
129  return panel;
130  }
131 
132  void changed() {
133  if (!changed) {
134  changed = true;
135 
136  pcs.firePropertyChange(OptionsPanelController.PROP_CHANGED, false, true);
137  }
138 
139  pcs.firePropertyChange(OptionsPanelController.PROP_VALID, null, null);
140  }
141 }
synchronized static Logger getLogger(String name)
Definition: Logger.java:124

Copyright © 2012-2022 Basis Technology. Generated on: Tue Aug 1 2023
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.