Autopsy  3.1
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 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 
20 package org.sleuthkit.autopsy.modules.hashdatabase;
21 
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;
28 import org.openide.util.NbBundle;
30 import java.util.logging.Level;
32 
33 @OptionsPanelController.TopLevelRegistration(
34  categoryName = "#OptionsCategory_Name_HashDatabase",
35 iconBase = "org/sleuthkit/autopsy/modules/hashdatabase/options_icon.png",
36 position = 3,
37 keywords = "#OptionsCategory_Keywords_HashDatabase",
38 keywordsCategory = "HashDatabase",
39 id = "HashDatabase")
40 // moved messages to Bundle.properties
41 //@org.openide.util.NbBundle.Messages({"OptionsCategory_Name_HashDatabase=Hash Database", "OptionsCategory_Keywords_HashDatabase=Hash Database"})
42 public final class HashDatabaseOptionsPanelController extends OptionsPanelController {
43 
45  private final PropertyChangeSupport pcs = new PropertyChangeSupport(this);
46  private boolean changed;
47  private static final Logger logger = Logger.getLogger(HashDatabaseOptionsPanelController.class.getName());
48  @Override
49  public void update() {
50  getPanel().load();
51  changed = false;
52  }
53 
54  @Override
55  public void applyChanges() {
56  getPanel().store();
57  changed = false;
58  }
59 
60  @Override
61  public void cancel() {
62  getPanel().cancel();
63  }
64 
65  @Override
66  public boolean isValid() {
67  return getPanel().valid();
68  }
69 
70  @Override
71  public boolean isChanged() {
72  return changed;
73  }
74 
75  @Override
76  public HelpCtx getHelpCtx() {
77  return null; // new HelpCtx("...ID") if you have a help set
78  }
79 
80  @Override
81  public JComponent getComponent(Lookup masterLookup) {
82  return getPanel();
83  }
84 
85  @Override
86  public void addPropertyChangeListener(PropertyChangeListener l) {
87  pcs.addPropertyChangeListener(l);
88  }
89 
90  @Override
91  public void removePropertyChangeListener(PropertyChangeListener l) {
92  pcs.removePropertyChangeListener(l);
93  }
94 
96  if (panel == null) {
97  panel = new HashLookupSettingsPanel();
98  }
99  return panel;
100  }
101 
102  void changed() {
103  if (!changed) {
104  changed = true;
105 
106  try {
107  pcs.firePropertyChange(OptionsPanelController.PROP_CHANGED, false, true);
108  }
109  catch (Exception e) {
110  logger.log(Level.SEVERE, "HashDatabaseOptionsPanelController listener threw exception", e); //NON-NLS
111  MessageNotifyUtil.Notify.show(
112  NbBundle.getMessage(this.getClass(), "HashDatabaseOptionsPanelController.moduleErr"),
113  NbBundle.getMessage(this.getClass(), "HashDatabaseOptionsPanelController.moduleErrMsg"),
114  MessageNotifyUtil.MessageType.ERROR);
115  }
116  }
117 
118  try {
119  pcs.firePropertyChange(OptionsPanelController.PROP_VALID, null, null);
120  }
121  catch (Exception e) {
122  logger.log(Level.SEVERE, "HashDatabaseOptionsPanelController listener threw exception", e); //NON-NLS
123  MessageNotifyUtil.Notify.show(
124  NbBundle.getMessage(this.getClass(), "HashDatabaseOptionsPanelController.moduleErr"),
125  NbBundle.getMessage(this.getClass(), "HashDatabaseOptionsPanelController.moduleErrMsg"),
126  MessageNotifyUtil.MessageType.ERROR);
127  }
128  }
129 }
static Logger getLogger(String name)
Definition: Logger.java:131

Copyright © 2012-2015 Basis Technology. Generated on: Mon Oct 19 2015
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.