Autopsy  4.20.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
ExternalViewerOptionsPanelController.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2011-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.directorytree;
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;
28 
32 @OptionsPanelController.TopLevelRegistration(
33  categoryName = "#OptionsCategory_Name_ExternalViewer",
34  iconBase = "org/sleuthkit/autopsy/directorytree/external-viewer-rules-32x32.png",
35  keywords = "#OptionsCategory_Keywords_ExternalViewer",
36  keywordsCategory = "ExternalViewer",
37  position = 13
38 )
39 public final class ExternalViewerOptionsPanelController extends OptionsPanelController {
40 
41  private ExternalViewerGlobalSettingsPanel panel;
42  private final PropertyChangeSupport pcs = new PropertyChangeSupport(this);
43  private boolean changed;
44 
45  @Override
46  public void update() {
47  getPanel().load();
48  changed = false;
49  }
50 
51  @Override
52  public void applyChanges() {
53  if (changed) {
54  getPanel().store();
55  changed = false;
56  }
57  }
58 
59  @Override
60  public void cancel() {
61  }
62 
63  @Override
64  public boolean isValid() {
65  return true;
66  }
67 
68  @Override
69  public boolean isChanged() {
70  return changed;
71  }
72 
73  @Override
74  public JComponent getComponent(Lookup lkp) {
75  return getPanel();
76  }
77 
78  @Override
79  public HelpCtx getHelpCtx() {
80  return null;
81  }
82 
83  @Override
84  public void addPropertyChangeListener(PropertyChangeListener l) {
85  pcs.addPropertyChangeListener(l);
86  }
87 
88  @Override
89  public void removePropertyChangeListener(PropertyChangeListener l) {
90  pcs.removePropertyChangeListener(l);
91  }
92 
93  private ExternalViewerGlobalSettingsPanel getPanel() {
94  if (panel == null) {
95  panel = new ExternalViewerGlobalSettingsPanel();
96  panel.addPropertyChangeListener((PropertyChangeEvent evt) -> {
97  if (evt.getPropertyName().equals(OptionsPanelController.PROP_CHANGED)) {
98  changed();
99  }
100  });
101  }
102  return panel;
103  }
104 
105  void changed() {
106  if (!changed) {
107  changed = true;
108  pcs.firePropertyChange(OptionsPanelController.PROP_CHANGED, false, true);
109  }
110  pcs.firePropertyChange(OptionsPanelController.PROP_VALID, null, null);
111  }
112 }

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.