Autopsy  4.18.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
TagsOptionsPanelController.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.casemodule.services;
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_TagNamesOptions",
31  iconBase = "org/sleuthkit/autopsy/casemodule/services/tag-options-panel-icon.png",
32  keywords = "#OptionsCategory_TagNames",
33  keywordsCategory = "CustomTagNames",
34  position = 12
35 )
36 
37 public final class TagsOptionsPanelController extends OptionsPanelController {
38 
39  private TagOptionsPanel panel;
40  private final PropertyChangeSupport pcs = new PropertyChangeSupport(this);
41  private boolean changed;
42 
46  @Override
47  public void update() {
48  getPanel().load();
49  changed = false;
50  }
51 
57  @Override
58  public void applyChanges() {
59  if (changed) {
60  getPanel().store();
61  changed = false;
62  }
63  }
64 
70  @Override
71  public void cancel() {
72  getPanel().cancelChanges();
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 JComponent getComponent(Lookup lkp) {
93  return getPanel();
94  }
95 
96  @Override
97  public HelpCtx getHelpCtx() {
98  return null;
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 TagOptionsPanel getPanel() {
112  if (panel == null) {
113  panel = new TagOptionsPanel();
114  panel.addPropertyChangeListener((PropertyChangeEvent evt) -> {
115  if (evt.getPropertyName().equals(OptionsPanelController.PROP_CHANGED)) {
116  changed();
117  }
118  });
119  }
120  return panel;
121  }
122 
123  void changed() {
124  if (!changed) {
125  changed = true;
126  pcs.firePropertyChange(OptionsPanelController.PROP_CHANGED, false, true);
127  }
128  pcs.firePropertyChange(OptionsPanelController.PROP_VALID, null, null);
129  }
130 }

Copyright © 2012-2021 Basis Technology. Generated on: Thu Jul 8 2021
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.