Autopsy  4.14.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
TranslationOptionsPanelController.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2019 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.texttranslation;
20 
21 import java.beans.PropertyChangeListener;
22 import java.beans.PropertyChangeSupport;
23 import javax.swing.JComponent;
24 import org.netbeans.spi.options.OptionsPanelController;
25 import org.openide.util.HelpCtx;
26 import org.openide.util.Lookup;
27 import org.openide.util.NbBundle;
29 import java.util.logging.Level;
31 
35 @OptionsPanelController.TopLevelRegistration(categoryName = "#OptionsCategory_Name_Machine_Translation",
36  iconBase = "org/sleuthkit/autopsy/images/translate32.png",
37  position = 7,
38  keywords = "#OptionsCategory_Keywords_Machine_Translation_Settings",
39  keywordsCategory = "Machine Translation")
40 public class TranslationOptionsPanelController extends OptionsPanelController {
41 
42  private static final Logger logger = Logger.getLogger(TranslationOptionsPanelController.class.getName());
43  private final PropertyChangeSupport pcs = new PropertyChangeSupport(this);
44  private boolean changed;
45  private TranslationOptionsPanel panel;
46 
47  @Override
48  public void update() {
49  getPanel().load();
50  changed = false;
51  }
52 
53  @Override
54  public void applyChanges() {
55  getPanel().store();
56  changed = false;
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 HelpCtx getHelpCtx() {
75  return null;
76  }
77 
78  @Override
79  public JComponent getComponent(Lookup masterLookup) {
80  return getPanel();
81  }
82 
83  @Override
84  public void addPropertyChangeListener(PropertyChangeListener l) {
85  if (pcs.getPropertyChangeListeners().length == 0) {
86  pcs.addPropertyChangeListener(l);
87  }
88  }
89 
90  @Override
91  public void removePropertyChangeListener(PropertyChangeListener l) {
99  }
100 
106  private TranslationOptionsPanel getPanel() {
107  if (panel == null) {
108  panel = new TranslationOptionsPanel(this);
109  }
110  return panel;
111  }
112 
116  void changed() {
117  if (!changed) {
118  changed = true;
119 
120  try {
121  pcs.firePropertyChange(OptionsPanelController.PROP_CHANGED, false, true);
122  } catch (Exception e) {
123  logger.log(Level.SEVERE, "TranslationOptionsPanelController listener threw exception", e); //NON-NLS
124  MessageNotifyUtil.Notify.show(
125  NbBundle.getMessage(this.getClass(), "TranslationOptionsPanelController.moduleErr"),
126  NbBundle.getMessage(this.getClass(), "TranslationOptionsPanelController.moduleErr.msg"),
127  MessageNotifyUtil.MessageType.ERROR);
128  }
129  }
130 
131  try {
132  pcs.firePropertyChange(OptionsPanelController.PROP_VALID, null, null);
133  } catch (Exception e) {
134  logger.log(Level.SEVERE, "TranslationOptionsPanelController listener threw exception", e); //NON-NLS
135  MessageNotifyUtil.Notify.show(
136  NbBundle.getMessage(this.getClass(), "TranslationOptionsPanelController.moduleErr"),
137  NbBundle.getMessage(this.getClass(), "TranslationOptionsPanelController.moduleErr.msg"),
138  MessageNotifyUtil.MessageType.ERROR);
139  }
140  }
141 }
synchronized static Logger getLogger(String name)
Definition: Logger.java:124

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