Autopsy 4.22.1
Graphical digital forensics platform for The Sleuth Kit and other tools.
ViewPreferencesPanelController.java
Go to the documentation of this file.
1/*
2 * Autopsy Forensic Browser
3 *
4 * Copyright 2018 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 */
19package org.sleuthkit.autopsy.corecomponents;
20
21import java.beans.PropertyChangeEvent;
22import java.beans.PropertyChangeListener;
23import java.beans.PropertyChangeSupport;
24import javax.swing.JComponent;
25import org.netbeans.spi.options.OptionsPanelController;
26import org.openide.util.HelpCtx;
27import org.openide.util.Lookup;
28import org.sleuthkit.autopsy.coreutils.MessageNotifyUtil;
29import java.util.logging.Level;
30import org.openide.util.NbBundle.Messages;
31import org.sleuthkit.autopsy.coreutils.Logger;
32
36@OptionsPanelController.TopLevelRegistration(categoryName = "#OptionsCategory_Name_View",
37 iconBase = "org/sleuthkit/autopsy/images/view-preferences-32.png",
38 position = 2,
39 keywords = "#OptionsCategory_Keywords_View",
40 keywordsCategory = "View")
41public final class ViewPreferencesPanelController extends OptionsPanelController {
42
44 private final PropertyChangeSupport pcs = new PropertyChangeSupport(this);
45 private boolean changed;
46 private static final Logger logger = Logger.getLogger(ViewPreferencesPanelController.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 true;
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
108 if (panel == null) {
109 panel = new ViewPreferencesPanel(false);
110 panel.addPropertyChangeListener((PropertyChangeEvent evt) -> {
111 if (evt.getPropertyName().equals(OptionsPanelController.PROP_CHANGED)) {
112 changed();
113 }
114 });
115 }
116 return panel;
117 }
118
122 @Messages({"ViewOptionsController.moduleErr=Error processing value changes.",
123 "ViewOptionsController.moduleErr.msg=Value change processing failed."})
124 void changed() {
125 if (!changed) {
126 changed = true;
127
128 try {
129 pcs.firePropertyChange(OptionsPanelController.PROP_CHANGED, false, true);
130 } catch (Exception ex) {
131 logger.log(Level.SEVERE, "Error processing property change", ex); //NON-NLS
132 MessageNotifyUtil.Notify.show(
133 Bundle.ViewOptionsController_moduleErr(),
134 Bundle.ViewOptionsController_moduleErr_msg(),
135 MessageNotifyUtil.MessageType.ERROR);
136 }
137 }
138
139 try {
140 pcs.firePropertyChange(OptionsPanelController.PROP_VALID, null, null);
141 } catch (Exception e) {
142 logger.log(Level.SEVERE, "Error processing property change validation.", e); //NON-NLS
143 MessageNotifyUtil.Notify.show(
144 Bundle.ViewOptionsController_moduleErr(),
145 Bundle.ViewOptionsController_moduleErr_msg(),
146 MessageNotifyUtil.MessageType.ERROR);
147 }
148 }
149}
synchronized static Logger getLogger(String name)
Definition Logger.java:124

Copyright © 2012-2024 Sleuth Kit Labs. Generated on:
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.