Autopsy  3.1
Graphical digital forensics platform for The Sleuth Kit and other tools.
KeywordSearchOptionsPanelController.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2011-2014 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.keywordsearch;
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_KeywordSearchOptions",
34  iconBase = "org/sleuthkit/autopsy/keywordsearch/options-icon.png",
35  position = 2,
36  keywords = "#OptionsCategory_Keywords_KeywordSearchOptions",
37  keywordsCategory = "KeywordSearchOptions")
38 public final class KeywordSearchOptionsPanelController extends OptionsPanelController {
39 
40  private KeywordSearchGlobalSettingsPanel panel;
41  private final PropertyChangeSupport pcs = new PropertyChangeSupport(this);
42  private boolean changed;
43  private static final Logger logger = Logger.getLogger(KeywordSearchGlobalSettingsPanel.class.getName());
44 
45  @Override
46  public void update() {
47  getPanel().load();
48  changed = false;
49  }
50 
51  @Override
52  public void applyChanges() {
53  getPanel().store();
54  changed = false;
55  }
56 
57  @Override
58  public void cancel() {
59  getPanel().cancel();
60  }
61 
62  @Override
63  public boolean isValid() {
64  return getPanel().valid();
65  }
66 
67  @Override
68  public boolean isChanged() {
69  return changed;
70  }
71 
72  @Override
73  public HelpCtx getHelpCtx() {
74  return null;
75  }
76 
77  @Override
78  public JComponent getComponent(Lookup masterLookup) {
79  return getPanel();
80  }
81 
82  @Override
83  public void addPropertyChangeListener(PropertyChangeListener l) {
84  pcs.addPropertyChangeListener(l);
85  }
86 
87  @Override
88  public void removePropertyChangeListener(PropertyChangeListener l) {
89  pcs.removePropertyChangeListener(l);
90  }
91 
92  private KeywordSearchGlobalSettingsPanel getPanel() {
93  if (panel == null) {
94  panel = new KeywordSearchGlobalSettingsPanel();
95  }
96  return panel;
97  }
98 
99  void changed() {
100  if (!changed) {
101  changed = true;
102 
103  try {
104  pcs.firePropertyChange(OptionsPanelController.PROP_CHANGED, false, true);
105  } catch (Exception e) {
106  logger.log(Level.SEVERE, "KeywordSearchOptionsPanelController listener threw exception", e); //NON-NLS
107  MessageNotifyUtil.Notify.show(
108  NbBundle.getMessage(this.getClass(), "KeywordSearchOptionsPanelController.moduleErr"),
109  NbBundle.getMessage(this.getClass(), "KeywordSearchOptionsPanelController.moduleErr.msg1"),
110  MessageNotifyUtil.MessageType.ERROR);
111  }
112  }
113  try {
114  pcs.firePropertyChange(OptionsPanelController.PROP_VALID, null, null);
115  } catch (Exception e) {
116  logger.log(Level.SEVERE, "KeywordSearchOptionsPanelController listener threw exception", e); //NON-NLS
117  MessageNotifyUtil.Notify.show(
118  NbBundle.getMessage(this.getClass(), "KeywordSearchOptionsPanelController.moduleErr"),
119  NbBundle.getMessage(this.getClass(), "KeywordSearchOptionsPanelController.moduleErr.msg2"),
120  MessageNotifyUtil.MessageType.ERROR);
121  }
122  }
123 }
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.