Autopsy  4.4
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 = 11
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  }
73 
74  @Override
75  public boolean isValid() {
76  return true;
77  }
78 
85  @Override
86  public boolean isChanged() {
87  return changed;
88  }
89 
90  @Override
91  public JComponent getComponent(Lookup lkp) {
92  return getPanel();
93  }
94 
95  @Override
96  public HelpCtx getHelpCtx() {
97  return null;
98  }
99 
100  @Override
101  public void addPropertyChangeListener(PropertyChangeListener l) {
102  pcs.addPropertyChangeListener(l);
103  }
104 
105  @Override
106  public void removePropertyChangeListener(PropertyChangeListener l) {
107  pcs.removePropertyChangeListener(l);
108  }
109 
110  private TagOptionsPanel getPanel() {
111  if (panel == null) {
112  panel = new TagOptionsPanel();
113  panel.addPropertyChangeListener((PropertyChangeEvent evt) -> {
114  if (evt.getPropertyName().equals(OptionsPanelController.PROP_CHANGED)) {
115  changed();
116  }
117  });
118  }
119  return panel;
120  }
121 
122  void changed() {
123  if (!changed) {
124  changed = true;
125  pcs.firePropertyChange(OptionsPanelController.PROP_CHANGED, false, true);
126  }
127  pcs.firePropertyChange(OptionsPanelController.PROP_VALID, null, null);
128  }
129 }

Copyright © 2012-2016 Basis Technology. Generated on: Tue Jun 13 2017
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.