Autopsy  4.9.1
Graphical digital forensics platform for The Sleuth Kit and other tools.
AddImageWizardIngestConfigPanel.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2011-2018 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 org.openide.util.NbBundle;
22 import java.awt.Component;
23 import java.util.List;
24 import javax.swing.JButton;
25 import javax.swing.JOptionPane;
26 import javax.swing.event.ChangeListener;
27 import org.openide.WizardDescriptor;
28 import org.openide.util.HelpCtx;
29 import org.openide.util.NbBundle.Messages;
30 import org.openide.windows.WindowManager;
36 
43 @SuppressWarnings("PMD.SingularField") // UI widgets cause lots of false positives
44 class AddImageWizardIngestConfigPanel extends ShortcutWizardDescriptorPanel {
45 
46  @Messages("AddImageWizardIngestConfigPanel.name.text=Configure Ingest Modules")
47  private final IngestJobSettingsPanel ingestJobSettingsPanel;
52  private Component component = null;
53  private String lastProfileUsed = AddImageWizardIngestConfigPanel.class.getCanonicalName();
54  private final AddImageWizardAddingProgressPanel progressPanel;
55 
56  AddImageWizardIngestConfigPanel(AddImageWizardAddingProgressPanel proPanel) {
57  this.progressPanel = proPanel;
58  IngestJobSettings ingestJobSettings = new IngestJobSettings(AddImageWizardIngestConfigPanel.class.getCanonicalName());
59  showWarnings(ingestJobSettings);
60  //When this panel is viewed by the user it will always be displaying the
61  //IngestJobSettingsPanel with the AddImageWizardIngestConfigPanel.class.getCanonicalName();
62  this.ingestJobSettingsPanel = new IngestJobSettingsPanel(ingestJobSettings);
63 
64  }
65 
74  @Override
75  public Component getComponent() {
76  if (component == null) {
77  component = new AddImageWizardIngestConfigVisual(this.ingestJobSettingsPanel);
78  component.setName(Bundle.AddImageWizardIngestConfigPanel_name_text());
79  }
80  return component;
81  }
82 
89  @Override
90  public HelpCtx getHelp() {
91  // Show no Help button for this panel:
92  return HelpCtx.DEFAULT_HELP;
93  // If you have context help:
94  // return new HelpCtx(SampleWizardPanel1.class);
95  }
96 
103  @Override
104  public boolean isValid() {
105  // If it is always OK to press Next or Finish, then:
106  return true;
107  // If it depends on some condition (form filled out...), then:
108  // return someCondition();
109  // and when this condition changes (last form field filled in...) then:
110  // fireChangeEvent();
111  // and uncomment the complicated stuff below.
112  }
113 
119  @Override
120  public final void addChangeListener(ChangeListener l) {
121  }
122 
128  @Override
129  public final void removeChangeListener(ChangeListener l) {
130  }
131 
132  // You can use a settings object to keep track of state. Normally the
133  // settings object will be the WizardDescriptor, so you can use
134  // WizardDescriptor.getProperty & putProperty to store information entered
135  // by the user.
144  @Override
145  public void readSettings(WizardDescriptor settings) {
146  JButton cancel = new JButton(
147  NbBundle.getMessage(this.getClass(), "AddImageWizardIngestConfigPanel.CANCEL_BUTTON.text"));
148  cancel.setEnabled(false);
149  settings.setOptions(new Object[]{WizardDescriptor.PREVIOUS_OPTION, WizardDescriptor.NEXT_OPTION, WizardDescriptor.FINISH_OPTION, cancel});
150  }
151 
161  @Override
162  public void storeSettings(WizardDescriptor settings) {
163  IngestJobSettings ingestJobSettings = ingestJobSettingsPanel.getSettings();
164  ingestJobSettings.save();
165  progressPanel.setIngestJobSettings(ingestJobSettings); //prepare ingest for being started
166  }
167 
168  private static void showWarnings(IngestJobSettings ingestJobSettings) {
169  List<String> warnings = ingestJobSettings.getWarnings();
170  if (warnings.isEmpty() == false) {
171  StringBuilder warningMessage = new StringBuilder();
172  for (String warning : warnings) {
173  warningMessage.append(warning).append("\n");
174  }
175  JOptionPane.showMessageDialog(WindowManager.getDefault().getMainWindow(), warningMessage.toString());
176  }
177  }
178 
184  @Override
185  public void processThisPanelBeforeSkipped() {
186  if (!(ModuleSettings.getConfigSetting(IngestProfileSelectionWizardPanel.getLastProfilePropertiesFile(), AddImageWizardIterator.getPropLastprofileName()) == null)
187  && !ModuleSettings.getConfigSetting(IngestProfileSelectionWizardPanel.getLastProfilePropertiesFile(), AddImageWizardIterator.getPropLastprofileName()).isEmpty()) {
188  lastProfileUsed = ModuleSettings.getConfigSetting(IngestProfileSelectionWizardPanel.getLastProfilePropertiesFile(), AddImageWizardIterator.getPropLastprofileName());
189  }
190  //Because this panel kicks off ingest during the wizard we need to
191  //swap out the ingestJobSettings for the ones of the chosen profile before
192  IngestJobSettings ingestJobSettings = new IngestJobSettings(lastProfileUsed);
193  progressPanel.setIngestJobSettings(ingestJobSettings); //prepare ingest for being started
194  }
195 }

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.