Autopsy  4.4
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-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 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;
35 
42 class AddImageWizardIngestConfigPanel extends ShortcutWizardDescriptorPanel {
43 
44  @Messages("AddImageWizardIngestConfigPanel.name.text=Configure Ingest Modules")
45  private IngestJobSettingsPanel ingestJobSettingsPanel;
50  private Component component = null;
51  private String lastProfileUsed = AddImageWizardIngestConfigPanel.class.getCanonicalName();
52  private final AddImageWizardAddingProgressPanel progressPanel;
53 
54  AddImageWizardIngestConfigPanel(AddImageWizardAddingProgressPanel proPanel) {
55  this.progressPanel = proPanel;
56  IngestJobSettings ingestJobSettings = new IngestJobSettings(AddImageWizardIngestConfigPanel.class.getCanonicalName());
57  showWarnings(ingestJobSettings);
58  //When this panel is viewed by the user it will always be displaying the
59  //IngestJobSettingsPanel with the AddImageWizardIngestConfigPanel.class.getCanonicalName();
60  this.ingestJobSettingsPanel = new IngestJobSettingsPanel(ingestJobSettings);
61 
62  }
63 
72  @Override
73  public Component getComponent() {
74  if (component == null) {
75  component = new AddImageWizardIngestConfigVisual(this.ingestJobSettingsPanel);
76  component.setName(Bundle.AddImageWizardIngestConfigPanel_name_text());
77  }
78  return component;
79  }
80 
87  @Override
88  public HelpCtx getHelp() {
89  // Show no Help button for this panel:
90  return HelpCtx.DEFAULT_HELP;
91  // If you have context help:
92  // return new HelpCtx(SampleWizardPanel1.class);
93  }
94 
101  @Override
102  public boolean isValid() {
103  // If it is always OK to press Next or Finish, then:
104  return true;
105  // If it depends on some condition (form filled out...), then:
106  // return someCondition();
107  // and when this condition changes (last form field filled in...) then:
108  // fireChangeEvent();
109  // and uncomment the complicated stuff below.
110  }
111 
117  @Override
118  public final void addChangeListener(ChangeListener l) {
119  }
120 
126  @Override
127  public final void removeChangeListener(ChangeListener l) {
128  }
129 
130  // You can use a settings object to keep track of state. Normally the
131  // settings object will be the WizardDescriptor, so you can use
132  // WizardDescriptor.getProperty & putProperty to store information entered
133  // by the user.
142  @Override
143  public void readSettings(WizardDescriptor settings) {
144  JButton cancel = new JButton(
145  NbBundle.getMessage(this.getClass(), "AddImageWizardIngestConfigPanel.CANCEL_BUTTON.text"));
146  cancel.setEnabled(false);
147  settings.setOptions(new Object[]{WizardDescriptor.PREVIOUS_OPTION, WizardDescriptor.NEXT_OPTION, WizardDescriptor.FINISH_OPTION, cancel});
148  }
149 
159  @Override
160  public void storeSettings(WizardDescriptor settings) {
161  IngestJobSettings ingestJobSettings = ingestJobSettingsPanel.getSettings();
162  ingestJobSettings.save();
163  progressPanel.setIngestJobSettings(ingestJobSettings); //prepare ingest for being started
164  }
165 
166  private static void showWarnings(IngestJobSettings ingestJobSettings) {
167  List<String> warnings = ingestJobSettings.getWarnings();
168  if (warnings.isEmpty() == false) {
169  StringBuilder warningMessage = new StringBuilder();
170  for (String warning : warnings) {
171  warningMessage.append(warning).append("\n");
172  }
173  JOptionPane.showMessageDialog(null, warningMessage.toString());
174  }
175  }
176 
182  @Override
183  public void processThisPanelBeforeSkipped() {
184  if (!(ModuleSettings.getConfigSetting(IngestProfileSelectionWizardPanel.getLastProfilePropertiesFile(), AddImageWizardIterator.getPropLastprofileName()) == null)
185  && !ModuleSettings.getConfigSetting(IngestProfileSelectionWizardPanel.getLastProfilePropertiesFile(), AddImageWizardIterator.getPropLastprofileName()).isEmpty()) {
186  lastProfileUsed = ModuleSettings.getConfigSetting(IngestProfileSelectionWizardPanel.getLastProfilePropertiesFile(), AddImageWizardIterator.getPropLastprofileName());
187  }
188  //Because this panel kicks off ingest during the wizard we need to
189  //swap out the ingestJobSettings for the ones of the chosen profile before
190  IngestJobSettings ingestJobSettings = new IngestJobSettings(lastProfileUsed);
191  progressPanel.setIngestJobSettings(ingestJobSettings); //prepare ingest for being started
192  }
193 }

Copyright © 2012-2016 Basis Technology. Generated on: Tue Jun 13 2017
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.