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

Copyright © 2012-2024 Sleuth Kit Labs. Generated on:
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.