Autopsy  4.1
Graphical digital forensics platform for The Sleuth Kit and other tools.
AutopsyOptionsPanelController.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2013-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.corecomponents;
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(categoryName = "#OptionsCategory_Name_General",
31  iconBase = "org/sleuthkit/autopsy/corecomponents/checkbox32.png",
32  position = 1,
33  keywords = "#OptionsCategory_Keywords_General",
34  keywordsCategory = "General")
35 public final class AutopsyOptionsPanelController extends OptionsPanelController {
36 
37  private AutopsyOptionsPanel panel;
38  private final PropertyChangeSupport pcs = new PropertyChangeSupport(this);
39  private boolean changed;
40  private static final Logger logger = Logger.getLogger(AutopsyOptionsPanelController.class.getName());
41 
45  @Override
46  public void update() {
47  getPanel().load();
48  changed = false;
49  }
50 
56  @Override
57  public void applyChanges() {
58  if (changed) {
59  getPanel().store();
60  changed = false;
61  }
62  }
63 
69  @Override
70  public void cancel() {
71  }
72 
73  @Override
74  public boolean isValid() {
75  return getPanel().valid();
76  }
77 
84  @Override
85  public boolean isChanged() {
86  return changed;
87  }
88 
89  @Override
90  public HelpCtx getHelpCtx() {
91  return null;
92  }
93 
94  @Override
95  public JComponent getComponent(Lookup masterLookup) {
96  return getPanel();
97  }
98 
99  @Override
100  public void addPropertyChangeListener(PropertyChangeListener l) {
101  pcs.addPropertyChangeListener(l);
102  }
103 
104  @Override
105  public void removePropertyChangeListener(PropertyChangeListener l) {
106  pcs.removePropertyChangeListener(l);
107  }
108 
109  private AutopsyOptionsPanel getPanel() {
110  if (panel == null) {
111  panel = new AutopsyOptionsPanel();
112  panel.addPropertyChangeListener(new PropertyChangeListener() {
113  @Override
114  public void propertyChange(PropertyChangeEvent evt) {
115  if (evt.getPropertyName().equals(OptionsPanelController.PROP_CHANGED)) {
116  changed();
117  }
118  }
119  });
120  }
121  return panel;
122  }
123 
124  void changed() {
125  if (!changed) {
126  changed = true;
127  pcs.firePropertyChange(OptionsPanelController.PROP_CHANGED, false, true);
128  }
129  pcs.firePropertyChange(OptionsPanelController.PROP_VALID, null, null);
130 
131  }
132 }
synchronized static Logger getLogger(String name)
Definition: Logger.java:161

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