Autopsy  4.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
CueBannerPanel.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2011-2015 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.*;
22 import java.awt.event.ActionEvent;
23 import java.awt.event.ActionListener;
24 import java.awt.event.KeyEvent;
25 import javax.swing.ImageIcon;
26 import javax.swing.JComponent;
27 import javax.swing.JDialog;
28 import javax.swing.JFrame;
29 import javax.swing.JPanel;
30 import javax.swing.KeyStroke;
31 import org.openide.util.Lookup;
32 import org.openide.util.NbBundle;
33 
37 public class CueBannerPanel extends javax.swing.JPanel {
38 
39  final private static String title = NbBundle.getMessage(CueBannerPanel.class, "CueBannerPanel.title.text");
40  final private static JFrame frame = new JFrame(title);
41  final static JDialog recentCasesWindow = new JDialog(frame, title, true); // to make the popUp Window to be modal
42 
43  // for error handling
44  private static JPanel caller = new JPanel();
45 
46  public CueBannerPanel() {
48  refresh();
49  }
50 
51  public CueBannerPanel(String welcomeLogo) {
53  ClassLoader cl = Lookup.getDefault().lookup(ClassLoader.class);
54  if (cl != null) {
55  ImageIcon icon = new ImageIcon(cl.getResource(welcomeLogo));
56  autopsyLogo.setIcon(icon);
57  }
58  }
59 
65  @SuppressWarnings("unchecked")
66  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
67  private void initComponents() {
68 
69  autopsyLogo = new javax.swing.JLabel();
70  this.autopsyLogo.setText("");
71  newCaseButton = new javax.swing.JButton();
72  openRecentButton = new javax.swing.JButton();
73  createNewLabel = new javax.swing.JLabel();
74  openRecentLabel = new javax.swing.JLabel();
75  openCaseButton = new javax.swing.JButton();
76  openLabel = new javax.swing.JLabel();
77  closeButton = new javax.swing.JButton();
78  jSeparator1 = new javax.swing.JSeparator();
79 
80  autopsyLogo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/casemodule/welcome_logo.png"))); // NOI18N
81  autopsyLogo.setText(org.openide.util.NbBundle.getMessage(CueBannerPanel.class, "CueBannerPanel.autopsyLogo.text")); // NOI18N
82 
83  newCaseButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/casemodule/btn_icon_create_new_case.png"))); // NOI18N
84  newCaseButton.setText(org.openide.util.NbBundle.getMessage(CueBannerPanel.class, "CueBannerPanel.newCaseButton.text")); // NOI18N
85  newCaseButton.setBorder(null);
86  newCaseButton.setBorderPainted(false);
87  newCaseButton.setContentAreaFilled(false);
88  newCaseButton.setPreferredSize(new java.awt.Dimension(64, 64));
89  newCaseButton.addActionListener(new java.awt.event.ActionListener() {
90  public void actionPerformed(java.awt.event.ActionEvent evt) {
92  }
93  });
94 
95  openRecentButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/casemodule/btn_icon_open_recent.png"))); // NOI18N
96  openRecentButton.setText(org.openide.util.NbBundle.getMessage(CueBannerPanel.class, "CueBannerPanel.openRecentButton.text")); // NOI18N
97  openRecentButton.setBorder(null);
98  openRecentButton.setBorderPainted(false);
99  openRecentButton.setContentAreaFilled(false);
100  openRecentButton.setPreferredSize(new java.awt.Dimension(64, 64));
101  openRecentButton.addActionListener(new java.awt.event.ActionListener() {
102  public void actionPerformed(java.awt.event.ActionEvent evt) {
104  }
105  });
106 
107  createNewLabel.setFont(createNewLabel.getFont().deriveFont(createNewLabel.getFont().getStyle() & ~java.awt.Font.BOLD, 13));
108  createNewLabel.setText(org.openide.util.NbBundle.getMessage(CueBannerPanel.class, "CueBannerPanel.createNewLabel.text")); // NOI18N
109 
110  openRecentLabel.setFont(openRecentLabel.getFont().deriveFont(openRecentLabel.getFont().getStyle() & ~java.awt.Font.BOLD, 13));
111  openRecentLabel.setText(org.openide.util.NbBundle.getMessage(CueBannerPanel.class, "CueBannerPanel.openRecentLabel.text")); // NOI18N
112 
113  openCaseButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/casemodule/btn_icon_open_existing.png"))); // NOI18N
114  openCaseButton.setText(org.openide.util.NbBundle.getMessage(CueBannerPanel.class, "CueBannerPanel.openCaseButton.text")); // NOI18N
115  openCaseButton.setBorder(null);
116  openCaseButton.setBorderPainted(false);
117  openCaseButton.setContentAreaFilled(false);
118  openCaseButton.setMargin(new java.awt.Insets(1, 1, 1, 1));
119  openCaseButton.setPreferredSize(new java.awt.Dimension(64, 64));
120  openCaseButton.addActionListener(new java.awt.event.ActionListener() {
121  public void actionPerformed(java.awt.event.ActionEvent evt) {
123  }
124  });
125 
126  openLabel.setFont(openLabel.getFont().deriveFont(openLabel.getFont().getStyle() & ~java.awt.Font.BOLD, 13));
127  openLabel.setText(org.openide.util.NbBundle.getMessage(CueBannerPanel.class, "CueBannerPanel.openLabel.text")); // NOI18N
128 
129  closeButton.setFont(closeButton.getFont().deriveFont(closeButton.getFont().getStyle() & ~java.awt.Font.BOLD, 11));
130  closeButton.setText(org.openide.util.NbBundle.getMessage(CueBannerPanel.class, "CueBannerPanel.closeButton.text")); // NOI18N
131 
132  jSeparator1.setOrientation(javax.swing.SwingConstants.VERTICAL);
133 
134  javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
135  this.setLayout(layout);
136  layout.setHorizontalGroup(
137  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
138  .addGroup(layout.createSequentialGroup()
139  .addContainerGap()
140  .addComponent(autopsyLogo)
141  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
142  .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 5, javax.swing.GroupLayout.PREFERRED_SIZE)
143  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
144  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
145  .addComponent(newCaseButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
146  .addComponent(openRecentButton, javax.swing.GroupLayout.PREFERRED_SIZE, 70, javax.swing.GroupLayout.PREFERRED_SIZE)
147  .addComponent(openCaseButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
148  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
149  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
150  .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
151  .addComponent(createNewLabel)
152  .addComponent(openRecentLabel)
153  .addComponent(openLabel))
154  .addComponent(closeButton, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 73, javax.swing.GroupLayout.PREFERRED_SIZE))
155  .addContainerGap())
156  );
157  layout.setVerticalGroup(
158  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
159  .addGroup(layout.createSequentialGroup()
160  .addContainerGap()
161  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
162  .addGroup(layout.createSequentialGroup()
163  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
164  .addComponent(newCaseButton, javax.swing.GroupLayout.PREFERRED_SIZE, 56, javax.swing.GroupLayout.PREFERRED_SIZE)
165  .addComponent(createNewLabel))
166  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
167  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
168  .addComponent(openRecentButton, javax.swing.GroupLayout.PREFERRED_SIZE, 70, javax.swing.GroupLayout.PREFERRED_SIZE)
169  .addComponent(openRecentLabel))
170  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
171  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
172  .addComponent(openCaseButton, javax.swing.GroupLayout.PREFERRED_SIZE, 58, javax.swing.GroupLayout.PREFERRED_SIZE)
173  .addComponent(openLabel))
174  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
175  .addComponent(closeButton))
176  .addComponent(jSeparator1)
177  .addComponent(autopsyLogo, javax.swing.GroupLayout.PREFERRED_SIZE, 257, javax.swing.GroupLayout.PREFERRED_SIZE))
178  .addContainerGap())
179  );
180  }// </editor-fold>//GEN-END:initComponents
181 
182  public void refresh() {
183  if (RecentCases.getInstance().getTotalRecentCases() == 0) {
184  openRecentButton.setEnabled(false);
185  openRecentLabel.setEnabled(false);
186  } else {
187  openRecentButton.setEnabled(true);
188  openRecentLabel.setEnabled(true);
189  }
190  }
191  private void newCaseButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_newCaseButtonActionPerformed
192  Lookup.getDefault().lookup(CaseNewActionInterface.class).actionPerformed(evt);
193  }//GEN-LAST:event_newCaseButtonActionPerformed
194 
195  private void openCaseButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_openCaseButtonActionPerformed
196  Lookup.getDefault().lookup(CaseOpenAction.class).actionPerformed(evt);
197  }//GEN-LAST:event_openCaseButtonActionPerformed
198 
199  private void openRecentButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_openRecentButtonActionPerformed
200 
201  // open the recent cases dialog
202  Dimension screenDimension = Toolkit.getDefaultToolkit().getScreenSize();
203 
204  // set the popUp window / JFrame
205  recentCasesWindow.setSize(750, 400);
206 
207  int w = recentCasesWindow.getSize().width;
208  int h = recentCasesWindow.getSize().height;
209 
210  // set the location of the popUp Window on the center of the screen
211  recentCasesWindow.setLocation((screenDimension.width - w) / 2, (screenDimension.height - h) / 2);
212  recentCasesWindow.setLocationRelativeTo(this);
213  recentCasesWindow.getRootPane().registerKeyboardAction(e -> {
214  recentCasesWindow.dispose();
215  }, KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_IN_FOCUSED_WINDOW);
216 
217  OpenRecentCasePanel welcomeWindow = OpenRecentCasePanel.getInstance();
218 
219  // add the command to close the window to the button on the Volume Detail Panel
220  welcomeWindow.setCloseButtonActionListener(new ActionListener() {
221  @Override
222  public void actionPerformed(ActionEvent e) {
223  recentCasesWindow.dispose();
224  }
225  });
226 
227  recentCasesWindow.add(welcomeWindow);
228  recentCasesWindow.pack();
229  recentCasesWindow.setResizable(false);
230  recentCasesWindow.setModalityType(Dialog.ModalityType.APPLICATION_MODAL);
231  recentCasesWindow.setVisible(true);
232  }//GEN-LAST:event_openRecentButtonActionPerformed
233 
234  // Variables declaration - do not modify//GEN-BEGIN:variables
235  private javax.swing.JLabel autopsyLogo;
236  private javax.swing.JButton closeButton;
237  private javax.swing.JLabel createNewLabel;
238  private javax.swing.JSeparator jSeparator1;
239  private javax.swing.JButton newCaseButton;
240  private javax.swing.JButton openCaseButton;
241  private javax.swing.JLabel openLabel;
242  private javax.swing.JButton openRecentButton;
243  private javax.swing.JLabel openRecentLabel;
244  // End of variables declaration//GEN-END:variables
245 
251  public void setCloseButtonActionListener(ActionListener e) {
252  closeButton.addActionListener(e);
253  }
254 
260  public void setCloseButtonText(String text) {
261  closeButton.setText(text);
262  }
263 
267  public static void closeOpenRecentCasesWindow() {
268  //startupWindow.setVisible(false);
269  recentCasesWindow.dispose();
270  }
271 }
void openRecentButtonActionPerformed(java.awt.event.ActionEvent evt)
void newCaseButtonActionPerformed(java.awt.event.ActionEvent evt)
void openCaseButtonActionPerformed(java.awt.event.ActionEvent evt)

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.