Autopsy  4.20.0
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.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_KeywordSearchOptions",
32  iconBase = "org/sleuthkit/autopsy/keywordsearch/options-icon.png",
33  position = 6,
34  keywords = "#OptionsCategory_Keywords_KeywordSearchOptions",
35  keywordsCategory = "KeywordSearchOptions")
36 public final class KeywordSearchOptionsPanelController extends OptionsPanelController {
37 
38  private KeywordSearchGlobalSettingsPanel panel;
39  private final PropertyChangeSupport pcs = new PropertyChangeSupport(this);
40  private boolean changed;
41  private static final Logger logger = Logger.getLogger(KeywordSearchGlobalSettingsPanel.class.getName());
42 
46  @Override
47  public void update() {
48  getPanel().load();
49  changed = false;
50  }
51 
57  @Override
58  public void applyChanges() {
59  if (changed) {
60  getPanel().store();
61  changed = false;
62  }
63  }
64 
70  @Override
71  public void cancel() {
72  getPanel().cancel();
73  }
74 
75  @Override
76  public boolean isValid() {
77  return getPanel().valid();
78  }
79 
86  @Override
87  public boolean isChanged() {
88  return changed;
89  }
90 
91  @Override
92  public HelpCtx getHelpCtx() {
93  return null;
94  }
95 
96  @Override
97  public JComponent getComponent(Lookup masterLookup) {
98  return getPanel();
99  }
100 
101  @Override
102  public void addPropertyChangeListener(PropertyChangeListener l) {
103  pcs.addPropertyChangeListener(l);
104  }
105 
106  @Override
107  public void removePropertyChangeListener(PropertyChangeListener l) {
108  pcs.removePropertyChangeListener(l);
109  }
110 
111  private KeywordSearchGlobalSettingsPanel getPanel() {
112  if (panel == null) {
113  panel = new KeywordSearchGlobalSettingsPanel();
114  panel.addPropertyChangeListener(new PropertyChangeListener() {
115  @Override
116  public void propertyChange(PropertyChangeEvent evt) {
117  if (evt.getPropertyName().equals(OptionsPanelController.PROP_CHANGED)) {
118  changed();
119  }
120  }
121  });
122  }
123  return panel;
124  }
125 
126  void changed() {
127  if (!changed) {
128  changed = true;
129  pcs.firePropertyChange(OptionsPanelController.PROP_CHANGED, false, true);
130  }
131  pcs.firePropertyChange(OptionsPanelController.PROP_VALID, null, null);
132  }
133 }
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.