Autopsy  4.0
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.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(categoryName = "#OptionsCategory_Name_General",
33  iconBase = "org/sleuthkit/autopsy/corecomponents/checkbox32.png",
34  position = 1,
35  keywords = "#OptionsCategory_Keywords_General",
36  keywordsCategory = "General")
37 public final class AutopsyOptionsPanelController extends OptionsPanelController {
38 
39  private AutopsyOptionsPanel panel;
40  private final PropertyChangeSupport pcs = new PropertyChangeSupport(this);
41  private boolean changed;
42  private static final Logger logger = Logger.getLogger(AutopsyOptionsPanelController.class.getName());
43 
44  @Override
45  public void update() {
46  getPanel().load();
47  changed = false;
48  }
49 
50  @Override
51  public void applyChanges() {
52  getPanel().store();
53  changed = false;
54  }
55 
56  @Override
57  public void cancel() {
58  }
59 
60  @Override
61  public boolean isValid() {
62  return getPanel().valid();
63  }
64 
65  @Override
66  public boolean isChanged() {
67  return changed;
68  }
69 
70  @Override
71  public HelpCtx getHelpCtx() {
72  return null;
73  }
74 
75  @Override
76  public JComponent getComponent(Lookup masterLookup) {
77  return getPanel();
78  }
79 
80  @Override
81  public void addPropertyChangeListener(PropertyChangeListener l) {
82  pcs.addPropertyChangeListener(l);
83  }
84 
85  @Override
86  public void removePropertyChangeListener(PropertyChangeListener l) {
87  pcs.removePropertyChangeListener(l);
88  }
89 
90  private AutopsyOptionsPanel getPanel() {
91  if (panel == null) {
92  panel = new AutopsyOptionsPanel(this);
93  }
94  return panel;
95  }
96 
97  void changed() {
98  if (!changed) {
99  changed = true;
100 
101  try {
102  pcs.firePropertyChange(OptionsPanelController.PROP_CHANGED, false, true);
103  } catch (Exception e) {
104  logger.log(Level.SEVERE, "GeneralOptionsPanelController listener threw exception", e); //NON-NLS
105  MessageNotifyUtil.Notify.show(
106  NbBundle.getMessage(this.getClass(), "GeneralOptionsPanelController.moduleErr"),
107  NbBundle.getMessage(this.getClass(), "GeneralOptionsPanelController.moduleErr.msg"),
108  MessageNotifyUtil.MessageType.ERROR);
109  }
110  }
111 
112  try {
113  pcs.firePropertyChange(OptionsPanelController.PROP_VALID, null, null);
114  } catch (Exception e) {
115  logger.log(Level.SEVERE, "GeneralOptionsPanelController listener threw exception", e); //NON-NLS
116  MessageNotifyUtil.Notify.show(
117  NbBundle.getMessage(this.getClass(), "GeneralOptionsPanelController.moduleErr"),
118  NbBundle.getMessage(this.getClass(), "GeneralOptionsPanelController.moduleErr.msg"),
119  MessageNotifyUtil.MessageType.ERROR);
120  }
121  }
122 }
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.