Autopsy  3.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.WindowAdapter;
28 import java.awt.event.WindowEvent;
29 import javax.swing.JDialog;
30 import org.openide.util.NbBundle;
31 import org.openide.windows.WindowManager;
32 
36 public final class IngestProgressSnapshotDialog extends JDialog {
37 
38  private static final String TITLE = NbBundle.getMessage(RunIngestModulesDialog.class, "IngestProgressSnapshotDialog.title.text");
39  private static final Dimension DIMENSIONS = new Dimension(500, 300);
40 
45  this((Window) WindowManager.getDefault().getMainWindow(), false);
46  }
47 
54  public IngestProgressSnapshotDialog(Container owner, Boolean shouldBeModal) {
55  super((Window) owner, TITLE, ModalityType.MODELESS);
56  if (shouldBeModal && owner instanceof JDialog) { // if called from a modal dialog, manipulate the parent be just under this in z order, and not modal.
57  final JDialog pseudoOwner = (JDialog) owner;
58  addWindowListener(new WindowAdapter() {
59  @Override
60  public void windowClosed(WindowEvent e) { // Put it back to how it was before we manipulated it.
61  pseudoOwner.setVisible(false);
62  pseudoOwner.setModalityType(Dialog.ModalityType.APPLICATION_MODAL);
63  pseudoOwner.toFront();
64  pseudoOwner.setVisible(true);
65  }
66  });
67  pseudoOwner.setVisible(false);
68  pseudoOwner.setModalityType(Dialog.ModalityType.MODELESS);
69  pseudoOwner.toFront();
70  pseudoOwner.repaint();
71  pseudoOwner.setVisible(true);
72  }
73  setResizable(true);
74  setLayout(new BorderLayout());
75  Dimension screenDimension = Toolkit.getDefaultToolkit().getScreenSize();
76  setSize(DIMENSIONS);
77  int w = this.getSize().width;
78  int h = this.getSize().height;
79  setLocation((screenDimension.width - w) / 2, (screenDimension.height - h) / 2);
80  add(new IngestProgressSnapshotPanel(this));
81  pack();
82  setResizable(false);
83  if (shouldBeModal) { // if called from a modal dialog, become modal, otherwise don't.
84  setModal(true);
85  }
86  setVisible(true);
87  }
88 }

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.