Autopsy  4.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 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.PropertyChangeListener;
22 import java.beans.PropertyChangeSupport;
23 import javax.swing.JComponent;
24 import org.netbeans.spi.options.OptionsPanelController;
25 import org.openide.util.HelpCtx;
26 import org.openide.util.Lookup;
27 import org.openide.util.NbBundle;
29 import java.util.logging.Level;
31 
32 @OptionsPanelController.TopLevelRegistration(
33  categoryName = "#OptionsCategory_Name_HashDatabase",
34  iconBase = "org/sleuthkit/autopsy/modules/hashdatabase/options_icon.png",
35  position = 4,
36  keywords = "#OptionsCategory_Keywords_HashDatabase",
37  keywordsCategory = "HashDatabase",
38  id = "HashDatabase")
39 // moved messages to Bundle.properties
40 //@org.openide.util.NbBundle.Messages({"OptionsCategory_Name_HashDatabase=Hash Database", "OptionsCategory_Keywords_HashDatabase=Hash Database"})
41 public final class HashDatabaseOptionsPanelController extends OptionsPanelController {
42 
44  private final PropertyChangeSupport pcs = new PropertyChangeSupport(this);
45  private boolean changed;
46  private static final Logger logger = Logger.getLogger(HashDatabaseOptionsPanelController.class.getName());
47 
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  } catch (Exception e) {
109  logger.log(Level.SEVERE, "HashDatabaseOptionsPanelController listener threw exception", e); //NON-NLS
110  MessageNotifyUtil.Notify.show(
111  NbBundle.getMessage(this.getClass(), "HashDatabaseOptionsPanelController.moduleErr"),
112  NbBundle.getMessage(this.getClass(), "HashDatabaseOptionsPanelController.moduleErrMsg"),
113  MessageNotifyUtil.MessageType.ERROR);
114  }
115  }
116 
117  try {
118  pcs.firePropertyChange(OptionsPanelController.PROP_VALID, null, null);
119  } catch (Exception e) {
120  logger.log(Level.SEVERE, "HashDatabaseOptionsPanelController listener threw exception", e); //NON-NLS
121  MessageNotifyUtil.Notify.show(
122  NbBundle.getMessage(this.getClass(), "HashDatabaseOptionsPanelController.moduleErr"),
123  NbBundle.getMessage(this.getClass(), "HashDatabaseOptionsPanelController.moduleErrMsg"),
124  MessageNotifyUtil.MessageType.ERROR);
125  }
126  }
127 }
synchronized static Logger getLogger(String name)
Definition: Logger.java:166

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