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

Copyright © 2012-2016 Basis Technology. Generated on: Mon May 7 2018
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.