Autopsy  3.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 
20 package org.sleuthkit.autopsy.casemodule;
21 
22 import java.awt.Dimension;
23 import java.awt.Toolkit;
24 import java.awt.event.ActionEvent;
25 import java.awt.event.ActionListener;
26 import java.util.Map;
27 import java.util.logging.Level;
28 import javax.swing.Action;
29 import javax.swing.JDialog;
30 import javax.swing.JFrame;
31 import org.openide.util.HelpCtx;
32 import org.openide.util.NbBundle;
33 import org.openide.util.actions.CallableSystemAction;
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  }
54 
59  @Override
60  public void performAction() {
61  try {
62  // create the popUp window for it
63  String title = NbBundle.getMessage(this.getClass(), "CasePropertiesAction.window.title");
64  final JFrame frame = new JFrame(title);
65  popUpWindow = new JDialog(frame, title, true); // to make the popUp Window to be modal
66 
67 
68  // get the information that needed
69  Case currentCase = Case.getCurrentCase();
70  String crDate = currentCase.getCreatedDate();
71  String caseDir = currentCase.getCaseDirectory();
72 
73  // put the image paths information into hashmap
74  Map<Long, String> imgPaths = Case.getImagePaths(currentCase.getSleuthkitCase());
75 
76  // create the case properties form
77  CasePropertiesForm cpf = new CasePropertiesForm(currentCase, crDate, caseDir, imgPaths);
78 
79  // add the command to close the window to the button on the Case Properties form / panel
80  cpf.setOKButtonActionListener(new ActionListener() {
81 
82  @Override
83  public void actionPerformed(ActionEvent e) {
84  popUpWindow.dispose();
85  }
86  });
87 
88  // add the case properties form / panel to the popup window
89  popUpWindow.add(cpf);
90  popUpWindow.pack();
91  popUpWindow.setResizable(false);
92 
93  // set the location of the popUp Window on the center of the screen
94  Dimension screenDimension = Toolkit.getDefaultToolkit().getScreenSize();
95  double w = popUpWindow.getSize().getWidth();
96  double h = popUpWindow.getSize().getHeight();
97  popUpWindow.setLocation((int) ((screenDimension.getWidth() - w) / 2), (int) ((screenDimension.getHeight() - h) / 2));
98 
99  popUpWindow.setVisible(true);
100  } catch (Exception ex) {
101  Logger.getLogger(CasePropertiesAction.class.getName()).log(Level.WARNING, "Error displaying Case Properties window.", ex); //NON-NLS
102  }
103  }
104 
109  @Override
110  public String getName() {
111  return NbBundle.getMessage(CasePropertiesAction.class, "CTL_CasePropertiesAction");
112  }
113 
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: Mon Oct 19 2015
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.