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-2017 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 javax.swing.Action;
27 import javax.swing.JDialog;
28 import javax.swing.SwingUtilities;
29 import org.openide.util.HelpCtx;
30 import org.openide.util.NbBundle;
31 import org.openide.util.actions.CallableSystemAction;
32 import org.openide.windows.WindowManager;
33 
38 final class CasePropertiesAction extends CallableSystemAction {
39 
40  private static final long serialVersionUID = 1L;
41  private static JDialog casePropertiesDialog;
42 
43  CasePropertiesAction() {
44  putValue(Action.NAME, NbBundle.getMessage(CasePropertiesAction.class, "CTL_CasePropertiesAction"));
45  this.setEnabled(false);
46  Case.addEventSubscriber(Case.Events.CURRENT_CASE.toString(), new PropertyChangeListener() {
47  @Override
48  public void propertyChange(PropertyChangeEvent evt) {
49  setEnabled(null != evt.getNewValue());
50  }
51  });
52  }
53 
54  @Override
55  public void performAction() {
56  SwingUtilities.invokeLater(() -> {
57  if (null == casePropertiesDialog) {
58  String title = NbBundle.getMessage(this.getClass(), "CasePropertiesAction.window.title");
59  casePropertiesDialog = new JDialog(WindowManager.getDefault().getMainWindow(), title, false);
60  CaseInformationPanel caseInformationPanel = new CaseInformationPanel();
61  caseInformationPanel.addCloseButtonAction((ActionEvent e) -> {
62  casePropertiesDialog.setVisible(false);
63  });
64  casePropertiesDialog.add(caseInformationPanel);
65  casePropertiesDialog.setResizable(true);
66  casePropertiesDialog.pack();
67 
68  Dimension screenDimension = Toolkit.getDefaultToolkit().getScreenSize();
69  double w = casePropertiesDialog.getSize().getWidth();
70  double h = casePropertiesDialog.getSize().getHeight();
71  casePropertiesDialog.setLocation((int) ((screenDimension.getWidth() - w) / 2), (int) ((screenDimension.getHeight() - h) / 2));
72  casePropertiesDialog.setVisible(true);
73  }
74  casePropertiesDialog.setVisible(true);
75  casePropertiesDialog.toFront();
76  });
77  }
78 
79  @Override
80  public String getName() {
81  return NbBundle.getMessage(CasePropertiesAction.class, "CTL_CasePropertiesAction");
82  }
83 
84  @Override
85  public HelpCtx getHelpCtx() {
86  return HelpCtx.DEFAULT_HELP;
87  }
88 
89  static void closeCasePropertiesWindow() {
90  casePropertiesDialog.setVisible(false);
91  }
92 }

Copyright © 2012-2016 Basis Technology. Generated on: Mon Apr 24 2017
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.