Autopsy  4.6.0
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 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.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.Window;
26 import java.awt.event.KeyEvent;
27 import java.awt.event.WindowAdapter;
28 import java.awt.event.WindowEvent;
29 import javax.swing.JComponent;
30 import javax.swing.JDialog;
31 import javax.swing.KeyStroke;
32 import org.openide.util.NbBundle;
33 import org.openide.windows.WindowManager;
34 
38 public final class IngestProgressSnapshotDialog extends JDialog {
39 
40  private static final String TITLE = NbBundle.getMessage(IngestProgressSnapshotDialog.class, "IngestProgressSnapshotDialog.title.text");
41  private static final Dimension DIMENSIONS = new Dimension(500, 300);
42 
47  this((Window) WindowManager.getDefault().getMainWindow(), false);
48  setLocationRelativeTo(WindowManager.getDefault().getMainWindow());
49  }
50 
58  public IngestProgressSnapshotDialog(Container owner, Boolean shouldBeModal) {
59  super((Window) owner, TITLE, ModalityType.MODELESS);
60  if (shouldBeModal && owner instanceof JDialog) { // if called from a modal dialog, manipulate the parent be just under this in z order, and not modal.
61  final JDialog pseudoOwner = (JDialog) owner;
62  final ModalityType originalModality = pseudoOwner.getModalityType();
63  addWindowListener(new WindowAdapter() {
64  @Override
65  public void windowClosed(WindowEvent e) { // Put it back to how it was before we manipulated it.
66  pseudoOwner.setVisible(false);
67  pseudoOwner.setModalityType(originalModality);
68  pseudoOwner.toFront();
69  pseudoOwner.setVisible(true);
70  }
71  });
72  pseudoOwner.setVisible(false);
73  pseudoOwner.setModalityType(Dialog.ModalityType.MODELESS);
74  pseudoOwner.toFront();
75  pseudoOwner.repaint();
76  pseudoOwner.setVisible(true);
77  }
78  setResizable(true);
79  setLayout(new BorderLayout());
80  setSize(DIMENSIONS);
81  setLocationRelativeTo(owner);
82  this.getRootPane().registerKeyboardAction(e -> {
83  this.dispose();
84  }, KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_IN_FOCUSED_WINDOW);
85  add(new IngestProgressSnapshotPanel(this));
86  pack();
87  setResizable(false);
88  if (shouldBeModal) { // if called from a modal dialog, become modal, otherwise don't.
89  setModal(true);
90  }
91  setVisible(true);
92  }
93 }

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.