Autopsy  4.0
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.Toolkit;
24 import java.awt.event.ActionEvent;
25 import java.awt.event.ActionListener;
26 import java.awt.event.WindowAdapter;
27 import java.awt.event.WindowEvent;
28 import java.util.ArrayList;
29 import java.util.List;
30 import javax.swing.BoxLayout;
31 import javax.swing.JButton;
32 import javax.swing.JDialog;
33 import javax.swing.JFrame;
34 import javax.swing.JOptionPane;
35 import javax.swing.JPanel;
36 import org.openide.util.NbBundle;
38 import org.sleuthkit.datamodel.Content;
39 import org.sleuthkit.datamodel.Directory;
40 
47 public final class RunIngestModulesDialog extends JDialog {
48 
49  private static final long serialVersionUID = 1L;
50  private static final String TITLE = NbBundle.getMessage(RunIngestModulesDialog.class, "IngestDialog.title.text");
51  private final IngestType ingestType;
52  private static Dimension DIMENSIONS = new Dimension(500, 300);
53  private final List<Content> dataSources = new ArrayList<>();
55 
65  public RunIngestModulesDialog(JFrame frame, String title, boolean modal, List<Content> dataSources) {
66  super(frame, title, modal);
67  this.dataSources.addAll(dataSources);
68  this.ingestType = IngestType.ALL_MODULES;
69  }
70 
77  public RunIngestModulesDialog(List<Content> dataSources) {
78  this(new JFrame(TITLE), TITLE, true, dataSources);
79  }
80 
87  public RunIngestModulesDialog(Directory dir) {
88  this.dataSources.add(dir);
89  this.ingestType = IngestType.FILES_ONLY;
90  }
91 
95  public void display() {
96  setLayout(new BorderLayout());
97 
101  Dimension screenDimension = Toolkit.getDefaultToolkit().getScreenSize();
102  setSize(DIMENSIONS);
103  int width = this.getSize().width;
104  int height = this.getSize().height;
105  setLocation((screenDimension.width - width) / 2, (screenDimension.height - height) / 2);
106 
111  IngestJobSettings ingestJobSettings = new IngestJobSettings(RunIngestModulesDialog.class.getCanonicalName(), this.ingestType);
112  RunIngestModulesDialog.showWarnings(ingestJobSettings);
113  this.ingestJobSettingsPanel = new IngestJobSettingsPanel(ingestJobSettings);
114  add(this.ingestJobSettingsPanel, BorderLayout.PAGE_START);
115 
116  // Add a start ingest button.
117  JButton startButton = new JButton(NbBundle.getMessage(this.getClass(), "IngestDialog.startButton.title"));
118  startButton.addActionListener(new ActionListener() {
119  @Override
120  public void actionPerformed(ActionEvent e) {
121  doButtonAction(true);
122  }
123  });
124 
125  // Add a close button.
126  JButton closeButton = new JButton(NbBundle.getMessage(this.getClass(), "IngestDialog.closeButton.title"));
127  closeButton.addActionListener(new ActionListener() {
128  @Override
129  public void actionPerformed(ActionEvent e) {
130  doButtonAction(false);
131  }
132  });
133 
134  // Put the buttons in their own panel, under the settings panel.
135  JPanel buttonPanel = new JPanel();
136  buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.LINE_AXIS));
137  buttonPanel.add(new javax.swing.Box.Filler(new Dimension(10, 10), new Dimension(10, 10), new Dimension(10, 10)));
138  buttonPanel.add(startButton);
139  buttonPanel.add(new javax.swing.Box.Filler(new Dimension(10, 10), new Dimension(10, 10), new Dimension(10, 10)));
140  buttonPanel.add(closeButton);
141  add(buttonPanel, BorderLayout.LINE_START);
142 
147  this.addWindowListener(new WindowAdapter() {
148  @Override
149  public void windowClosing(WindowEvent e) {
150  doButtonAction(false);
151  }
152  });
153 
157  pack();
158  setResizable(false);
159  setVisible(true);
160  }
161 
165  @Deprecated
166  public void close() {
167  setVisible(false);
168  dispose();
169  }
170 
178  private void doButtonAction(boolean startIngestJob) {
179  IngestJobSettings ingestJobSettings = this.ingestJobSettingsPanel.getSettings();
180  ingestJobSettings.save();
181  showWarnings(ingestJobSettings);
182  if (startIngestJob) {
184  }
185  setVisible(false);
186  dispose();
187  }
188 
189  private static void showWarnings(IngestJobSettings ingestJobSettings) {
190  List<String> warnings = ingestJobSettings.getWarnings();
191  if (warnings.isEmpty() == false) {
192  StringBuilder warningMessage = new StringBuilder();
193  for (String warning : warnings) {
194  warningMessage.append(warning).append("\n");
195  }
196  JOptionPane.showMessageDialog(null, warningMessage.toString());
197  }
198  }
199 
210  @Deprecated
211  public RunIngestModulesDialog(JFrame frame, String title, boolean modal) {
212  super(frame, title, modal);
213  this.ingestType = IngestType.ALL_MODULES;
214  }
215 
222  @Deprecated
224  this(new JFrame(TITLE), TITLE, true);
225  }
226 
234  @Deprecated
235  public void setDataSources(List<Content> dataSources) {
236  this.dataSources.clear();
237  this.dataSources.addAll(dataSources);
238  }
239 
240 }
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-2015 Basis Technology. Generated on: Wed Apr 6 2016
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.