Autopsy  4.0
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.awt.event.ActionListener;
25 import java.util.Map;
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;
34 
42 final class CasePropertiesAction extends CallableSystemAction {
43 
44  private static JDialog popUpWindow;
45 
49  CasePropertiesAction() {
50  putValue(Action.NAME, NbBundle.getMessage(CasePropertiesAction.class, "CTL_CasePropertiesAction")); // put the action Name
51  this.setEnabled(false);
52  }
53 
58  @Override
59  public void performAction() {
60  try {
61  // create the popUp window for it
62  String title = NbBundle.getMessage(this.getClass(), "CasePropertiesAction.window.title");
63  final JFrame frame = new JFrame(title);
64  popUpWindow = new JDialog(frame, title, true); // to make the popUp Window to be modal
65 
66  // get the information that needed
67  Case currentCase = Case.getCurrentCase();
68  String crDate = currentCase.getCreatedDate();
69  String caseDir = currentCase.getCaseDirectory();
70 
71  // put the image paths information into hashmap
72  Map<Long, String> imgPaths = Case.getImagePaths(currentCase.getSleuthkitCase());
73 
74  // create the case properties form
75  CasePropertiesForm cpf = new CasePropertiesForm(currentCase, crDate, caseDir, imgPaths);
76 
77  // add the command to close the window to the button on the Case Properties form / panel
78  cpf.setOKButtonActionListener(new ActionListener() {
79 
80  @Override
81  public void actionPerformed(ActionEvent e) {
82  popUpWindow.dispose();
83  }
84  });
85 
86  // add the case properties form / panel to the popup window
87  popUpWindow.add(cpf);
88  popUpWindow.pack();
89  popUpWindow.setResizable(false);
90 
91  // set the location of the popUp Window on the center of the screen
92  Dimension screenDimension = Toolkit.getDefaultToolkit().getScreenSize();
93  double w = popUpWindow.getSize().getWidth();
94  double h = popUpWindow.getSize().getHeight();
95  popUpWindow.setLocation((int) ((screenDimension.getWidth() - w) / 2), (int) ((screenDimension.getHeight() - h) / 2));
96 
97  popUpWindow.setVisible(true);
98  } catch (Exception ex) {
99  Logger.getLogger(CasePropertiesAction.class.getName()).log(Level.WARNING, "Error displaying Case Properties window.", ex); //NON-NLS
100  }
101  }
102 
108  @Override
109  public String getName() {
110  return NbBundle.getMessage(CasePropertiesAction.class, "CTL_CasePropertiesAction");
111  }
112 
118  @Override
119  public HelpCtx getHelpCtx() {
120  return HelpCtx.DEFAULT_HELP;
121  }
122 
123  static void closeCasePropertiesWindow() {
124  popUpWindow.dispose();
125  }
126 }

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