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

Copyright © 2012-2016 Basis Technology. Generated on: Tue Oct 25 2016
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.