Autopsy  4.19.3
Graphical digital forensics platform for The Sleuth Kit and other tools.
EamOptionsPanelController.java
Go to the documentation of this file.
1 /*
2  * Central Repository
3  *
4  * Copyright 2015-2017 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.centralrepository.optionspanel;
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 import java.util.logging.Level;
30 import org.openide.util.NbBundle.Messages;
32 
36 @OptionsPanelController.TopLevelRegistration(categoryName = "#OptionsCategory_Name_Central_Repository_Options",
37  iconBase = "org/sleuthkit/autopsy/centralrepository/images/options-icon.png",
38  position = 15,
39  keywords = "#OptionsCategory_Keywords_Central_Repository_Options",
40  keywordsCategory = "CentralRepository")
41 public final class EamOptionsPanelController extends OptionsPanelController {
42 
44  private final PropertyChangeSupport pcs = new PropertyChangeSupport(this);
45  private boolean changed;
46  private static final Logger LOGGER = Logger.getLogger(EamOptionsPanelController.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  }
63 
64  @Override
65  public boolean isValid() {
66  return getPanel().valid();
67  }
68 
69  @Override
70  public boolean isChanged() {
71  return changed;
72  }
73 
74  @Override
75  public HelpCtx getHelpCtx() {
76  return null;
77  }
78 
79  @Override
80  public JComponent getComponent(Lookup masterLookup) {
81  return getPanel();
82  }
83 
84  @Override
85  public void addPropertyChangeListener(PropertyChangeListener l) {
86  if (pcs.getPropertyChangeListeners().length == 0) {
87  pcs.addPropertyChangeListener(l);
88  }
89  }
90 
91  @Override
92  public void removePropertyChangeListener(PropertyChangeListener l) {
100  }
101 
103  if (panel == null) {
104  panel = new GlobalSettingsPanel();
105  panel.addPropertyChangeListener((PropertyChangeEvent evt) -> {
106  if (evt.getPropertyName().equals(OptionsPanelController.PROP_CHANGED)) {
107  changed();
108  }
109  });
110  }
111  return panel;
112  }
113 
114  @Messages({"EamOptionsController.moduleErr=Error processing value changes.",
115  "EamOptionsController.moduleErr.msg=Value change processing failed."})
116  void changed() {
117  if (!changed) {
118  changed = true;
119 
120  try {
121  pcs.firePropertyChange(OptionsPanelController.PROP_CHANGED, false, true);
122  } catch (Exception ex) {
123  LOGGER.log(Level.SEVERE, "Error processing property change", ex); //NON-NLS
124  MessageNotifyUtil.Notify.show(
125  Bundle.EamOptionsController_moduleErr(),
126  Bundle.EamOptionsController_moduleErr_msg(),
127  MessageNotifyUtil.MessageType.ERROR);
128  }
129  }
130 
131  try {
132  pcs.firePropertyChange(OptionsPanelController.PROP_VALID, null, null);
133  } catch (Exception e) {
134  LOGGER.log(Level.SEVERE, "Error processing property change validation.", e); //NON-NLS
135  MessageNotifyUtil.Notify.show(
136  Bundle.EamOptionsController_moduleErr(),
137  Bundle.EamOptionsController_moduleErr_msg(),
138  MessageNotifyUtil.MessageType.ERROR);
139  }
140  }
141 }
synchronized static Logger getLogger(String name)
Definition: Logger.java:124

Copyright © 2012-2022 Basis Technology. Generated on: Wed Sep 28 2022
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.