Autopsy  4.19.3
Graphical digital forensics platform for The Sleuth Kit and other tools.
FileTypeIdOptionsPanelController.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.modules.filetypeid;
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 
29 @OptionsPanelController.TopLevelRegistration(
30  categoryName = "#OptionsCategory_Name_FileTypeId",
31  iconBase = "org/sleuthkit/autopsy/modules/filetypeid/user-defined-file-types-settings.png",
32  keywords = "#OptionsCategory_Keywords_FileTypeId",
33  keywordsCategory = "FileTypeId",
34  position = 10
35 )
36 public final class FileTypeIdOptionsPanelController extends OptionsPanelController {
37 
38  private FileTypeIdGlobalSettingsPanel panel;
39  private final PropertyChangeSupport pcs = new PropertyChangeSupport(this);
40  private boolean changed;
41 
45  @Override
46  public void update() {
47 
48  getPanel().load();
49  changed = false;
50 
51  }
52 
58  @Override
59  public void applyChanges() {
60  if (changed) {
61  getPanel().store();
62  changed = false;
63  }
64  }
65 
71  @Override
72  public void cancel() {
73  }
74 
75  @Override
76  public boolean isValid() {
77  return true;
78  }
79 
86  @Override
87  public boolean isChanged() {
88  return changed;
89  }
90 
91  @Override
92  public HelpCtx getHelpCtx() {
93  return null;
94  }
95 
96  @Override
97  public JComponent getComponent(Lookup masterLookup) {
98  return getPanel();
99  }
100 
101  @Override
102  public void addPropertyChangeListener(PropertyChangeListener l) {
103  pcs.addPropertyChangeListener(l);
104  }
105 
106  @Override
107  public void removePropertyChangeListener(PropertyChangeListener l) {
108  pcs.removePropertyChangeListener(l);
109  }
110 
111  private FileTypeIdGlobalSettingsPanel getPanel() {
112  if (panel == null) {
113  panel = new FileTypeIdGlobalSettingsPanel();
114  panel.addPropertyChangeListener(new PropertyChangeListener() {
115  @Override
116  public void propertyChange(PropertyChangeEvent evt) {
117  if (evt.getPropertyName().equals(OptionsPanelController.PROP_CHANGED)) {
118  changed();
119  }
120  }
121  });
122  }
123  return panel;
124  }
125 
126  void changed() {
127  if (!changed) {
128  changed = true;
129  pcs.firePropertyChange(OptionsPanelController.PROP_CHANGED, false, true);
130  }
131  pcs.firePropertyChange(OptionsPanelController.PROP_VALID, null, null);
132  }
133 
134 }

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