Autopsy  4.19.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  }
59 
60  return component;
61  }
62 
69  @Override
70  public HelpCtx getHelp() {
71  /*
72  * Currently, no help is provided for this panel.
73  */
74  return HelpCtx.DEFAULT_HELP;
75  }
76 
84  @Override
85  public boolean isValid() {
86  return true;
87  }
88 
94  @Override
95  public final void addChangeListener(ChangeListener listener) {
96  synchronized (listeners) {
97  listeners.add(listener);
98  }
99  }
100 
106  @Override
107  public final void removeChangeListener(ChangeListener listener) {
108  synchronized (listeners) {
109  listeners.remove(listener);
110  }
111  }
112 
116  protected final void fireChangeEvent() {
117  Iterator<ChangeListener> it;
118  synchronized (listeners) {
119  it = new HashSet<>(listeners).iterator();
120  }
121  ChangeEvent ev = new ChangeEvent(this);
122  while (it.hasNext()) {
123  it.next().stateChanged(ev);
124  }
125  }
126 
135  @Override
136  public void readSettings(WizardDescriptor settings) {
137  NewCaseVisualPanel2 panel = getComponent();
138  panel.refreshCaseDetailsFields();
139  try {
140  String lastExaminerName = ModuleSettings.getConfigSetting(ModuleSettings.MAIN_SETTINGS, PROP_EXAMINER_NAME);
141  String lastExaminerPhone = ModuleSettings.getConfigSetting(ModuleSettings.MAIN_SETTINGS, PROP_EXAMINER_PHONE);
142  String lastExaminerEmail = ModuleSettings.getConfigSetting(ModuleSettings.MAIN_SETTINGS, PROP_EXAMINER_EMAIL);
143  String lastOrganizationName = ModuleSettings.getConfigSetting(ModuleSettings.MAIN_SETTINGS, PROP_ORGANIZATION_NAME);
144  panel.setExaminerName(lastExaminerName);
145  panel.setExaminerPhone(lastExaminerPhone);
146  panel.setExaminerEmail(lastExaminerEmail);
147  panel.setOrganization(CentralRepository.isEnabled() ? lastOrganizationName : "");
148  panel.setCaseNumber(""); //clear the number field
149  panel.setCaseNotes(""); //clear the notes field
150  } catch (Exception e) {
151  logger.log(Level.WARNING, "Could not read wizard settings in NewCaseWizardPanel2, ", e); //NON-NLS
152  }
153  }
154 
164  @Override
165  public void storeSettings(WizardDescriptor settings) {
166  settings.putProperty("caseNumber", component.getCaseNumber()); //NON-NLS
167  settings.putProperty("caseExaminerName", component.getExaminerName()); //NON-NLS
168  ModuleSettings.setConfigSetting(ModuleSettings.MAIN_SETTINGS, PROP_EXAMINER_NAME, component.getExaminerName());
169  settings.putProperty("caseExaminerPhone", component.getExaminerPhone()); //NON-NLS
170  ModuleSettings.setConfigSetting(ModuleSettings.MAIN_SETTINGS, PROP_EXAMINER_PHONE, component.getExaminerPhone());
171  settings.putProperty("caseExaminerEmail", component.getExaminerEmail()); //NON-NLS
172  ModuleSettings.setConfigSetting(ModuleSettings.MAIN_SETTINGS, PROP_EXAMINER_EMAIL, component.getExaminerEmail());
173  settings.putProperty("caseNotes", component.getCaseNotes()); //NON-NLS
174  settings.putProperty("caseOrganization", component.getOrganization()); //NON-NLS
175  ModuleSettings.setConfigSetting(ModuleSettings.MAIN_SETTINGS, PROP_ORGANIZATION_NAME, component.getOrganization());
176  }
177 
178  @Override
179  public void validate() throws WizardValidationException {
180  WindowManager.getDefault().getMainWindow().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
181  }
182 }

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