Autopsy  4.1
Graphical digital forensics platform for The Sleuth Kit and other tools.
CasePropertiesAction.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2011-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.casemodule;
20 
21 import java.awt.Dimension;
22 import java.awt.Toolkit;
23 import java.awt.event.ActionEvent;
24 import java.beans.PropertyChangeEvent;
25 import java.beans.PropertyChangeListener;
26 import java.util.logging.Level;
27 import javax.swing.Action;
28 import javax.swing.JDialog;
29 import javax.swing.JFrame;
30 import org.openide.util.HelpCtx;
31 import org.openide.util.NbBundle;
32 import org.openide.util.actions.CallableSystemAction;
33 import org.openide.windows.WindowManager;
35 
43 final class CasePropertiesAction extends CallableSystemAction {
44 
45  private static JDialog popUpWindow;
46 
50  CasePropertiesAction() {
51  putValue(Action.NAME, NbBundle.getMessage(CasePropertiesAction.class, "CTL_CasePropertiesAction")); // put the action Name
52  this.setEnabled(false);
53  Case.addEventSubscriber(Case.Events.CURRENT_CASE.toString(), new PropertyChangeListener() {
54  @Override
55  public void propertyChange(PropertyChangeEvent evt) {
56  popUpWindow = null;
57  }
58  });
59  }
60 
65  @Override
66  public void performAction() {
67  if (popUpWindow == null) {
68  // create the popUp window for it
69  String title = NbBundle.getMessage(this.getClass(), "CasePropertiesAction.window.title");
70  popUpWindow = new JDialog((JFrame) WindowManager.getDefault().getMainWindow(), title, false);
71  try {
72 
73  CaseInformationPanel caseInformationPanel = new CaseInformationPanel();
74  caseInformationPanel.addCloseButtonAction((ActionEvent e) -> {
75  popUpWindow.dispose();
76  });
77 
78  popUpWindow.add(caseInformationPanel);
79  popUpWindow.setResizable(true);
80  popUpWindow.pack();
81 
82  // set the location of the popUp Window on the center of the screen
83  Dimension screenDimension = Toolkit.getDefaultToolkit().getScreenSize();
84  double w = popUpWindow.getSize().getWidth();
85  double h = popUpWindow.getSize().getHeight();
86  popUpWindow.setLocation((int) ((screenDimension.getWidth() - w) / 2), (int) ((screenDimension.getHeight() - h) / 2));
87 
88  popUpWindow.setVisible(true);
89  } catch (Exception ex) {
90  Logger.getLogger(CasePropertiesAction.class.getName()).log(Level.WARNING, "Error displaying Case Properties window.", ex); //NON-NLS
91  }
92  }
93  popUpWindow.setVisible(true);
94  popUpWindow.toFront();
95  }
96 
102  @Override
103  public String getName() {
104  return NbBundle.getMessage(CasePropertiesAction.class, "CTL_CasePropertiesAction");
105  }
106 
112  @Override
113  public HelpCtx getHelpCtx() {
114  return HelpCtx.DEFAULT_HELP;
115  }
116 
117  static void closeCasePropertiesWindow() {
118  popUpWindow.dispose();
119  }
120 }

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.