Autopsy  3.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 2013-2014 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 
43 public final class RunIngestModulesDialog extends JDialog {
44 
45  private static final String TITLE = NbBundle.getMessage(RunIngestModulesDialog.class, "IngestDialog.title.text");
46  private static Dimension DIMENSIONS = new Dimension(500, 300);
47  private final List<Content> dataSources = new ArrayList<>();
49 
59  public RunIngestModulesDialog(JFrame frame, String title, boolean modal, List<Content> dataSources) {
60  super(frame, title, modal);
61  this.dataSources.addAll(dataSources);
62  }
63 
70  public RunIngestModulesDialog(List<Content> dataSources) {
71  this(new JFrame(TITLE), TITLE, true, dataSources);
72  }
73 
83  @Deprecated
84  public RunIngestModulesDialog(JFrame frame, String title, boolean modal) {
85  super(frame, title, modal);
86  }
87 
94  @Deprecated
96  this(new JFrame(TITLE), TITLE, true);
97  }
98 
105  @Deprecated
106  public void setDataSources(List<Content> dataSources) {
107  this.dataSources.clear();
108  this.dataSources.addAll(dataSources);
109  }
110 
114  public void display() {
115  setLayout(new BorderLayout());
116 
120  Dimension screenDimension = Toolkit.getDefaultToolkit().getScreenSize();
121  setSize(DIMENSIONS);
122  int width = this.getSize().width;
123  int height = this.getSize().height;
124  setLocation((screenDimension.width - width) / 2, (screenDimension.height - height) / 2);
125 
130  IngestJobSettings ingestJobSettings = new IngestJobSettings(RunIngestModulesDialog.class.getCanonicalName());
131  RunIngestModulesDialog.showWarnings(ingestJobSettings);
132  this.ingestJobSettingsPanel = new IngestJobSettingsPanel(ingestJobSettings);
133  add(this.ingestJobSettingsPanel, BorderLayout.PAGE_START);
134 
135  // Add a start ingest button.
136  JButton startButton = new JButton(NbBundle.getMessage(this.getClass(), "IngestDialog.startButton.title"));
137  startButton.addActionListener(new ActionListener() {
138  @Override
139  public void actionPerformed(ActionEvent e) {
140  doButtonAction(true);
141  }
142  });
143 
144  // Add a close button.
145  JButton closeButton = new JButton(NbBundle.getMessage(this.getClass(), "IngestDialog.closeButton.title"));
146  closeButton.addActionListener(new ActionListener() {
147  @Override
148  public void actionPerformed(ActionEvent e) {
149  doButtonAction(false);
150  }
151  });
152 
153  // Put the buttons in their own panel, under the settings panel.
154  JPanel buttonPanel = new JPanel();
155  buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.LINE_AXIS));
156  buttonPanel.add(new javax.swing.Box.Filler(new Dimension(10, 10), new Dimension(10, 10), new Dimension(10, 10)));
157  buttonPanel.add(startButton);
158  buttonPanel.add(new javax.swing.Box.Filler(new Dimension(10, 10), new Dimension(10, 10), new Dimension(10, 10)));
159  buttonPanel.add(closeButton);
160  add(buttonPanel, BorderLayout.LINE_START);
161 
166  this.addWindowListener(new WindowAdapter() {
167  @Override
168  public void windowClosing(WindowEvent e) {
169  doButtonAction(false);
170  }
171  });
172 
176  pack();
177  setResizable(false);
178  setVisible(true);
179  }
180 
184  @Deprecated
185  public void close() {
186  setVisible(false);
187  dispose();
188  }
189 
197  private void doButtonAction(boolean startIngestJob) {
198  IngestJobSettings ingestJobSettings = this.ingestJobSettingsPanel.getSettings();
199  ingestJobSettings.save();
200  showWarnings(ingestJobSettings);
201  if (startIngestJob) {
203  }
204  setVisible(false);
205  dispose();
206  }
207 
208  private static void showWarnings(IngestJobSettings ingestJobSettings) {
209  List<String> warnings = ingestJobSettings.getWarnings();
210  if (warnings.isEmpty() == false) {
211  StringBuilder warningMessage = new StringBuilder();
212  for (String warning : warnings) {
213  warningMessage.append(warning).append("\n");
214  }
215  JOptionPane.showMessageDialog(null, warningMessage.toString());
216  }
217  }
218 }
static void showWarnings(IngestJobSettings ingestJobSettings)
static synchronized IngestManager getInstance()
synchronized 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: Mon Oct 19 2015
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.