Autopsy  4.1
Graphical digital forensics platform for The Sleuth Kit and other tools.
RunIngestModulesDialog.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2011-2016 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.ingest;
20 
21 import java.awt.BorderLayout;
22 import java.awt.Dimension;
23 import java.awt.FlowLayout;
24 import java.awt.Toolkit;
25 import java.awt.event.ActionEvent;
26 import java.awt.event.ActionListener;
27 import java.awt.event.WindowAdapter;
28 import java.awt.event.WindowEvent;
29 import java.util.ArrayList;
30 import java.util.List;
31 import javax.swing.BorderFactory;
32 import javax.swing.JButton;
33 import javax.swing.JDialog;
34 import javax.swing.JFrame;
35 import javax.swing.JOptionPane;
36 import javax.swing.JPanel;
37 import org.openide.util.NbBundle;
38 import org.openide.windows.WindowManager;
40 import org.sleuthkit.datamodel.Content;
41 import org.sleuthkit.datamodel.Directory;
42 
49 public final class RunIngestModulesDialog extends JDialog {
50 
51  private static final long serialVersionUID = 1L;
52  private static final String TITLE = NbBundle.getMessage(RunIngestModulesDialog.class, "IngestDialog.title.text");
53  private final IngestType ingestType;
54  private final List<Content> dataSources = new ArrayList<>();
56 
66  public RunIngestModulesDialog(JFrame frame, String title, boolean modal, List<Content> dataSources) {
67  super(frame, title, modal);
68  this.dataSources.addAll(dataSources);
69  this.ingestType = IngestType.ALL_MODULES;
70  }
71 
78  public RunIngestModulesDialog(List<Content> dataSources) {
79  this((JFrame) WindowManager.getDefault().getMainWindow(), TITLE, true, dataSources);
80  }
81 
88  public RunIngestModulesDialog(Directory dir) {
89  this.dataSources.add(dir);
90  this.ingestType = IngestType.FILES_ONLY;
91  }
92 
96  public void display() {
97  setLayout(new BorderLayout());
98 
102  Dimension screenDimension = Toolkit.getDefaultToolkit().getScreenSize();;
103 
108  IngestJobSettings ingestJobSettings = new IngestJobSettings(RunIngestModulesDialog.class.getCanonicalName(), this.ingestType);
109  RunIngestModulesDialog.showWarnings(ingestJobSettings);
110  this.ingestJobSettingsPanel = new IngestJobSettingsPanel(ingestJobSettings, dataSources);
111  setPreferredSize(this.ingestJobSettingsPanel.getPreferredSize());
112  add(this.ingestJobSettingsPanel, BorderLayout.CENTER);
113 
114  // Add a start ingest button.
115  JButton startButton = new JButton(NbBundle.getMessage(this.getClass(), "IngestDialog.startButton.title"));
116  startButton.addActionListener(new ActionListener() {
117  @Override
118  public void actionPerformed(ActionEvent e) {
119  doButtonAction(true);
120  }
121  });
122 
123  // Add a close button.
124  JButton closeButton = new JButton(NbBundle.getMessage(this.getClass(), "IngestDialog.closeButton.title"));
125  closeButton.addActionListener(new ActionListener() {
126  @Override
127  public void actionPerformed(ActionEvent e) {
128  doButtonAction(false);
129  }
130  });
131 
132  // Put the buttons in their own panel, under the settings panel.
133  JPanel buttonPanel = new JPanel();
134  buttonPanel.setLayout(new FlowLayout(FlowLayout.TRAILING));
135  buttonPanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 5));
136  buttonPanel.add(startButton);
137  buttonPanel.add(new javax.swing.Box.Filler(new Dimension(5, 10), new Dimension(5, 10), new Dimension(5, 10)));
138  buttonPanel.add(closeButton);
139 
140  add(buttonPanel, BorderLayout.SOUTH);
141 
146  this.addWindowListener(new WindowAdapter() {
147  @Override
148  public void windowClosing(WindowEvent e) {
149  doButtonAction(false);
150  }
151  });
152 
156  int width = this.getPreferredSize().width;
157  int height = this.getPreferredSize().height;
158  setLocation((screenDimension.width - width) / 2, (screenDimension.height - height) / 2);
159  pack();
160  setVisible(true);
161  }
162 
166  @Deprecated
167  public void close() {
168  setVisible(false);
169  dispose();
170  }
171 
179  private void doButtonAction(boolean startIngestJob) {
180  IngestJobSettings ingestJobSettings = this.ingestJobSettingsPanel.getSettings();
181  ingestJobSettings.save();
182  showWarnings(ingestJobSettings);
183  if (startIngestJob) {
185  }
186  setVisible(false);
187  dispose();
188  }
189 
190  private static void showWarnings(IngestJobSettings ingestJobSettings) {
191  List<String> warnings = ingestJobSettings.getWarnings();
192  if (warnings.isEmpty() == false) {
193  StringBuilder warningMessage = new StringBuilder();
194  for (String warning : warnings) {
195  warningMessage.append(warning).append("\n");
196  }
197  JOptionPane.showMessageDialog(null, warningMessage.toString());
198  }
199  }
200 
211  @Deprecated
212  public RunIngestModulesDialog(JFrame frame, String title, boolean modal) {
213  super(frame, title, modal);
214  this.ingestType = IngestType.ALL_MODULES;
215  }
216 
223  @Deprecated
225  this(new JFrame(TITLE), TITLE, true);
226  }
227 
235  @Deprecated
236  public void setDataSources(List<Content> dataSources) {
237  this.dataSources.clear();
238  this.dataSources.addAll(dataSources);
239  }
240 
241 }
static void showWarnings(IngestJobSettings ingestJobSettings)
static synchronized IngestManager getInstance()
void queueIngestJob(Collection< Content > dataSources, IngestJobSettings settings)
RunIngestModulesDialog(JFrame frame, String title, boolean modal)
RunIngestModulesDialog(JFrame frame, String title, boolean modal, List< Content > dataSources)

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