Autopsy  4.9.1
Graphical digital forensics platform for The Sleuth Kit and other tools.
NewCaseWizardPanel2.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;
20 
21 import java.util.HashSet;
22 import java.util.Iterator;
23 import java.util.Set;
24 import javax.swing.event.ChangeEvent;
25 import javax.swing.event.ChangeListener;
26 import org.openide.WizardDescriptor;
27 import org.openide.WizardValidationException;
28 import org.openide.util.HelpCtx;
29 import org.openide.windows.WindowManager;
30 import java.awt.Cursor;
31 import java.util.logging.Level;
35 
39 class NewCaseWizardPanel2 implements WizardDescriptor.ValidatingPanel<WizardDescriptor> {
40 
41  private static final Logger logger = Logger.getLogger(NewCaseWizardPanel2.class.getName());
42  private static final String PROP_EXAMINER_NAME = "LBL_EXAMINER_NAME"; //NON-NLS
43  private static final String PROP_EXAMINER_PHONE = "LBL_EXAMINER_PHONE"; //NON-NLS
44  private static final String PROP_EXAMINER_EMAIL = "LBL_EXAMINER_EMAIL"; //NON-NLS
45  private static final String PROP_ORGANIZATION_NAME = "LBL_ORGANIZATION_NAME"; //NON-NLS
46  private NewCaseVisualPanel2 component;
47  private final Set<ChangeListener> listeners = new HashSet<>(1);
48 
54  @Override
55  public NewCaseVisualPanel2 getComponent() {
56  if (component == null) {
57  component = new NewCaseVisualPanel2();
58  } else {
59  component.refreshCaseDetailsFields();
60  }
61 
62  return component;
63  }
64 
71  @Override
72  public HelpCtx getHelp() {
73  /*
74  * Currently, no help is provided for this panel.
75  */
76  return HelpCtx.DEFAULT_HELP;
77  }
78 
86  @Override
87  public boolean isValid() {
88  return true;
89  }
90 
96  @Override
97  public final void addChangeListener(ChangeListener listener) {
98  synchronized (listeners) {
99  listeners.add(listener);
100  }
101  }
102 
108  @Override
109  public final void removeChangeListener(ChangeListener listener) {
110  synchronized (listeners) {
111  listeners.remove(listener);
112  }
113  }
114 
118  protected final void fireChangeEvent() {
119  Iterator<ChangeListener> it;
120  synchronized (listeners) {
121  it = new HashSet<>(listeners).iterator();
122  }
123  ChangeEvent ev = new ChangeEvent(this);
124  while (it.hasNext()) {
125  it.next().stateChanged(ev);
126  }
127  }
128 
137  @Override
138  public void readSettings(WizardDescriptor settings) {
139  NewCaseVisualPanel2 panel = getComponent();
140  try {
141  String lastExaminerName = ModuleSettings.getConfigSetting(ModuleSettings.MAIN_SETTINGS, PROP_EXAMINER_NAME);
142  String lastExaminerPhone = ModuleSettings.getConfigSetting(ModuleSettings.MAIN_SETTINGS, PROP_EXAMINER_PHONE);
143  String lastExaminerEmail = ModuleSettings.getConfigSetting(ModuleSettings.MAIN_SETTINGS, PROP_EXAMINER_EMAIL);
144  String lastOrganizationName = ModuleSettings.getConfigSetting(ModuleSettings.MAIN_SETTINGS, PROP_ORGANIZATION_NAME);
145  panel.setExaminerName(lastExaminerName);
146  panel.setExaminerPhone(lastExaminerPhone);
147  panel.setExaminerEmail(lastExaminerEmail);
148  panel.setOrganization(EamDb.isEnabled() ? lastOrganizationName : "");
149  panel.setCaseNumber(""); //clear the number field
150  panel.setCaseNotes(""); //clear the notes field
151  } catch (Exception e) {
152  logger.log(Level.WARNING, "Could not read wizard settings in NewCaseWizardPanel2, ", e); //NON-NLS
153  }
154  }
155 
165  @Override
166  public void storeSettings(WizardDescriptor settings) {
167  settings.putProperty("caseNumber", component.getCaseNumber()); //NON-NLS
168  settings.putProperty("caseExaminerName", component.getExaminerName()); //NON-NLS
169  ModuleSettings.setConfigSetting(ModuleSettings.MAIN_SETTINGS, PROP_EXAMINER_NAME, component.getExaminerName());
170  settings.putProperty("caseExaminerPhone", component.getExaminerPhone()); //NON-NLS
171  ModuleSettings.setConfigSetting(ModuleSettings.MAIN_SETTINGS, PROP_EXAMINER_PHONE, component.getExaminerPhone());
172  settings.putProperty("caseExaminerEmail", component.getExaminerEmail()); //NON-NLS
173  ModuleSettings.setConfigSetting(ModuleSettings.MAIN_SETTINGS, PROP_EXAMINER_EMAIL, component.getExaminerEmail());
174  settings.putProperty("caseNotes", component.getCaseNotes()); //NON-NLS
175  settings.putProperty("caseOrganization", component.getOrganization()); //NON-NLS
176  ModuleSettings.setConfigSetting(ModuleSettings.MAIN_SETTINGS, PROP_ORGANIZATION_NAME, component.getOrganization());
177  }
178 
179  @Override
180  public void validate() throws WizardValidationException {
181  WindowManager.getDefault().getMainWindow().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
182  }
183 }

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