Autopsy  4.14.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 @SuppressWarnings("PMD.SingularField") // UI widgets cause lots of false positives
39 public final class IngestProgressSnapshotDialog extends JDialog {
40 
41  private static final String TITLE = NbBundle.getMessage(IngestProgressSnapshotDialog.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 
61  public IngestProgressSnapshotDialog(Container owner, Boolean shouldBeModal, IngestProgressSnapshotProvider provider) {
62  super((Window) owner, TITLE, ModalityType.MODELESS);
63  if (shouldBeModal && owner instanceof JDialog) { // if called from a modal dialog, manipulate the parent be just under this in z order, and not modal.
64  final JDialog pseudoOwner = (JDialog) owner;
65  final ModalityType originalModality = pseudoOwner.getModalityType();
66  addWindowListener(new WindowAdapter() {
67  @Override
68  public void windowClosed(WindowEvent e) { // Put it back to how it was before we manipulated it.
69  pseudoOwner.setVisible(false);
70  pseudoOwner.setModalityType(originalModality);
71  pseudoOwner.toFront();
72  pseudoOwner.setVisible(true);
73  }
74  });
75  pseudoOwner.setVisible(false);
76  pseudoOwner.setModalityType(Dialog.ModalityType.MODELESS);
77  pseudoOwner.toFront();
78  pseudoOwner.repaint();
79  pseudoOwner.setVisible(true);
80  }
81  setResizable(true);
82  setLayout(new BorderLayout());
83  setSize(DIMENSIONS);
84  setLocationRelativeTo(owner);
85  this.getRootPane().registerKeyboardAction(e -> {
86  this.dispose();
87  }, KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_IN_FOCUSED_WINDOW);
88  add(new IngestProgressSnapshotPanel(this, provider));
89  pack();
90  setResizable(false);
91  if (shouldBeModal) { // if called from a modal dialog, become modal, otherwise don't.
92  setModal(true);
93  }
94  setVisible(true);
95  }
96 
106  public IngestProgressSnapshotDialog(Container owner, Boolean shouldBeModal) {
107  this(owner, shouldBeModal, IngestManager.getInstance());
108  }
109 }
static synchronized IngestManager getInstance()
IngestProgressSnapshotDialog(Container owner, Boolean shouldBeModal, IngestProgressSnapshotProvider provider)

Copyright © 2012-2020 Basis Technology. Generated on: Wed Apr 8 2020
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.