Autopsy  4.1
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-2016 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 = 8
35 )
36 public final class TagsOptionsPanelController extends OptionsPanelController {
37 
38  private TagOptionsPanel panel;
39  private final PropertyChangeSupport pcs = new PropertyChangeSupport(this);
40  private boolean changed;
41 
45  @Override
46  public void update() {
47  getPanel().load();
48  changed = false;
49  }
50 
56  @Override
57  public void applyChanges() {
58  if (changed) {
59  getPanel().store();
60  changed = false;
61  }
62  }
63 
69  @Override
70  public void cancel() {
71  }
72 
73  @Override
74  public boolean isValid() {
75  return true;
76  }
77 
84  @Override
85  public boolean isChanged() {
86  return changed;
87  }
88 
89  @Override
90  public JComponent getComponent(Lookup lkp) {
91  return getPanel();
92  }
93 
94  @Override
95  public HelpCtx getHelpCtx() {
96  return null;
97  }
98 
99  @Override
100  public void addPropertyChangeListener(PropertyChangeListener l) {
101  pcs.addPropertyChangeListener(l);
102  }
103 
104  @Override
105  public void removePropertyChangeListener(PropertyChangeListener l) {
106  pcs.removePropertyChangeListener(l);
107  }
108 
109  private TagOptionsPanel getPanel() {
110  if (panel == null) {
111  panel = new TagOptionsPanel();
112  panel.addPropertyChangeListener((PropertyChangeEvent evt) -> {
113  if (evt.getPropertyName().equals(OptionsPanelController.PROP_CHANGED)) {
114  changed();
115  }
116  });
117  }
118  return panel;
119  }
120 
121  void changed() {
122  if (!changed) {
123  changed = true;
124  pcs.firePropertyChange(OptionsPanelController.PROP_CHANGED, false, true);
125  }
126  pcs.firePropertyChange(OptionsPanelController.PROP_VALID, null, null);
127  }
128 }

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