Autopsy  4.1
Graphical digital forensics platform for The Sleuth Kit and other tools.
IngestProgressSnapshotDialog.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 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.Container;
23 import java.awt.Dialog;
24 import java.awt.Dimension;
25 import java.awt.Toolkit;
26 import java.awt.Window;
27 import java.awt.event.KeyEvent;
28 import java.awt.event.WindowAdapter;
29 import java.awt.event.WindowEvent;
30 import javax.swing.JComponent;
31 import javax.swing.JDialog;
32 import javax.swing.KeyStroke;
33 import org.openide.util.NbBundle;
34 import org.openide.windows.WindowManager;
35 
39 public final class IngestProgressSnapshotDialog extends JDialog {
40 
41  private static final String TITLE = NbBundle.getMessage(RunIngestModulesDialog.class, "IngestProgressSnapshotDialog.title.text");
42  private static final Dimension DIMENSIONS = new Dimension(500, 300);
43 
48  this((Window) WindowManager.getDefault().getMainWindow(), false);
49  setLocationRelativeTo(WindowManager.getDefault().getMainWindow());
50  }
51 
59  public IngestProgressSnapshotDialog(Container owner, Boolean shouldBeModal) {
60  super((Window) owner, TITLE, ModalityType.MODELESS);
61  if (shouldBeModal && owner instanceof JDialog) { // if called from a modal dialog, manipulate the parent be just under this in z order, and not modal.
62  final JDialog pseudoOwner = (JDialog) owner;
63  final ModalityType originalModality = pseudoOwner.getModalityType();
64  addWindowListener(new WindowAdapter() {
65  @Override
66  public void windowClosed(WindowEvent e) { // Put it back to how it was before we manipulated it.
67  pseudoOwner.setVisible(false);
68  pseudoOwner.setModalityType(originalModality);
69  pseudoOwner.toFront();
70  pseudoOwner.setVisible(true);
71  }
72  });
73  pseudoOwner.setVisible(false);
74  pseudoOwner.setModalityType(Dialog.ModalityType.MODELESS);
75  pseudoOwner.toFront();
76  pseudoOwner.repaint();
77  pseudoOwner.setVisible(true);
78  }
79  setResizable(true);
80  setLayout(new BorderLayout());
81  Dimension screenDimension = Toolkit.getDefaultToolkit().getScreenSize();
82  setSize(DIMENSIONS);
83  int w = this.getSize().width;
84  int h = this.getSize().height;
85  setLocation((screenDimension.width - w) / 2, (screenDimension.height - h) / 2);
86  this.getRootPane().registerKeyboardAction(e -> {
87  this.dispose();
88  }, KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_IN_FOCUSED_WINDOW);
89  add(new IngestProgressSnapshotPanel(this));
90  pack();
91  setResizable(false);
92  if (shouldBeModal) { // if called from a modal dialog, become modal, otherwise don't.
93  setModal(true);
94  }
95  setVisible(true);
96  }
97 }

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.