Autopsy  4.9.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-2018 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.Cursor;
22 import java.awt.Dialog;
23 import java.awt.Dimension;
24 import java.awt.event.ActionEvent;
25 import java.awt.event.ActionListener;
26 import java.awt.event.KeyEvent;
27 import javax.swing.ImageIcon;
28 import javax.swing.JComponent;
29 import javax.swing.JDialog;
30 import javax.swing.KeyStroke;
31 import org.openide.util.Lookup;
32 import org.openide.util.NbBundle;
33 import org.openide.windows.WindowManager;
34 
35 /*
36  * The panel in the default Autopsy startup window.
37  */
38 @SuppressWarnings("PMD.SingularField") // UI widgets cause lots of false positives
39 public class CueBannerPanel extends javax.swing.JPanel {
40 
41  private static final long serialVersionUID = 1L;
42  /*
43  * This is field is static for the sake of the closeOpenRecentCasesWindow
44  * method.
45  */
46  private static JDialog recentCasesWindow;
47 
48  public static void closeOpenRecentCasesWindow() {
49  if (null != recentCasesWindow) {
50  recentCasesWindow.setVisible(false);
51  }
52  }
53 
54  public CueBannerPanel() {
55  initComponents();
56  initRecentCasesWindow();
57  enableComponents();
58  }
59 
60  public CueBannerPanel(String welcomeLogo) {
61  initComponents();
62  ClassLoader cl = Lookup.getDefault().lookup(ClassLoader.class);
63  if (cl != null) {
64  ImageIcon icon = new ImageIcon(cl.getResource(welcomeLogo));
65  autopsyLogo.setIcon(icon);
66  }
67  initRecentCasesWindow();
68  enableComponents();
69  }
70 
71  public void setCloseButtonActionListener(ActionListener e) {
72  closeButton.addActionListener(e);
73  }
74 
75  public void setCloseButtonText(String text) {
76  closeButton.setText(text);
77  }
78 
79  public void refresh() {
80  enableComponents();
81  }
82 
83  private void initRecentCasesWindow() {
84  recentCasesWindow = new JDialog(
85  WindowManager.getDefault().getMainWindow(),
86  NbBundle.getMessage(CueBannerPanel.class, "CueBannerPanel.title.text"),
87  Dialog.ModalityType.APPLICATION_MODAL);
88  recentCasesWindow.setSize(new Dimension(750, 400));
89  recentCasesWindow.getRootPane().registerKeyboardAction(
90  e -> {
91  recentCasesWindow.setVisible(false);
92  },
93  KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_IN_FOCUSED_WINDOW);
94  OpenRecentCasePanel recentCasesPanel = OpenRecentCasePanel.getInstance();
95  recentCasesPanel.setCloseButtonActionListener(new ActionListener() {
96  @Override
97  public void actionPerformed(ActionEvent e) {
98  recentCasesWindow.setVisible(false);
99  }
100  });
101  recentCasesWindow.add(recentCasesPanel);
102  recentCasesWindow.pack();
103  recentCasesWindow.setResizable(false);
104  }
105 
106  private void enableComponents() {
107  boolean enableOpenRecentCaseButton = (RecentCases.getInstance().getTotalRecentCases() > 0);
108  openRecentCaseButton.setEnabled(enableOpenRecentCaseButton);
109  openRecentCaseLabel.setEnabled(enableOpenRecentCaseButton);
110  }
111 
117  @SuppressWarnings("unchecked")
118  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
119  private void initComponents() {
120 
121  autopsyLogo = new javax.swing.JLabel();
122  this.autopsyLogo.setText("");
123  newCaseButton = new javax.swing.JButton();
124  openRecentCaseButton = new javax.swing.JButton();
125  newCaseLabel = new javax.swing.JLabel();
126  openRecentCaseLabel = new javax.swing.JLabel();
127  openCaseButton = new javax.swing.JButton();
128  openCaseLabel = new javax.swing.JLabel();
129  closeButton = new javax.swing.JButton();
130  jSeparator1 = new javax.swing.JSeparator();
131 
132  autopsyLogo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/casemodule/welcome_logo.png"))); // NOI18N
133  autopsyLogo.setText(org.openide.util.NbBundle.getMessage(CueBannerPanel.class, "CueBannerPanel.autopsyLogo.text")); // NOI18N
134 
135  newCaseButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/casemodule/btn_icon_create_new_case.png"))); // NOI18N
136  newCaseButton.setText(org.openide.util.NbBundle.getMessage(CueBannerPanel.class, "CueBannerPanel.newCaseButton.text")); // NOI18N
137  newCaseButton.setBorder(null);
138  newCaseButton.setBorderPainted(false);
139  newCaseButton.setContentAreaFilled(false);
140  newCaseButton.setPreferredSize(new java.awt.Dimension(64, 64));
141  newCaseButton.addActionListener(new java.awt.event.ActionListener() {
142  public void actionPerformed(java.awt.event.ActionEvent evt) {
143  newCaseButtonActionPerformed(evt);
144  }
145  });
146 
147  openRecentCaseButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/casemodule/btn_icon_open_recent.png"))); // NOI18N
148  openRecentCaseButton.setText(org.openide.util.NbBundle.getMessage(CueBannerPanel.class, "CueBannerPanel.openRecentCaseButton.text")); // NOI18N
149  openRecentCaseButton.setBorder(null);
150  openRecentCaseButton.setBorderPainted(false);
151  openRecentCaseButton.setContentAreaFilled(false);
152  openRecentCaseButton.setPreferredSize(new java.awt.Dimension(64, 64));
153  openRecentCaseButton.addActionListener(new java.awt.event.ActionListener() {
154  public void actionPerformed(java.awt.event.ActionEvent evt) {
155  openRecentCaseButtonActionPerformed(evt);
156  }
157  });
158 
159  newCaseLabel.setFont(newCaseLabel.getFont().deriveFont(newCaseLabel.getFont().getStyle() & ~java.awt.Font.BOLD, 13));
160  newCaseLabel.setText(org.openide.util.NbBundle.getMessage(CueBannerPanel.class, "CueBannerPanel.newCaseLabel.text")); // NOI18N
161 
162  openRecentCaseLabel.setFont(openRecentCaseLabel.getFont().deriveFont(openRecentCaseLabel.getFont().getStyle() & ~java.awt.Font.BOLD, 13));
163  openRecentCaseLabel.setText(org.openide.util.NbBundle.getMessage(CueBannerPanel.class, "CueBannerPanel.openRecentCaseLabel.text")); // NOI18N
164 
165  openCaseButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/casemodule/btn_icon_open_existing.png"))); // NOI18N
166  openCaseButton.setText(org.openide.util.NbBundle.getMessage(CueBannerPanel.class, "CueBannerPanel.openCaseButton.text")); // NOI18N
167  openCaseButton.setBorder(null);
168  openCaseButton.setBorderPainted(false);
169  openCaseButton.setContentAreaFilled(false);
170  openCaseButton.setMargin(new java.awt.Insets(1, 1, 1, 1));
171  openCaseButton.setPreferredSize(new java.awt.Dimension(64, 64));
172  openCaseButton.addActionListener(new java.awt.event.ActionListener() {
173  public void actionPerformed(java.awt.event.ActionEvent evt) {
174  openCaseButtonActionPerformed(evt);
175  }
176  });
177 
178  openCaseLabel.setFont(openCaseLabel.getFont().deriveFont(openCaseLabel.getFont().getStyle() & ~java.awt.Font.BOLD, 13));
179  openCaseLabel.setText(org.openide.util.NbBundle.getMessage(CueBannerPanel.class, "CueBannerPanel.openCaseLabel.text")); // NOI18N
180 
181  closeButton.setFont(closeButton.getFont().deriveFont(closeButton.getFont().getStyle() & ~java.awt.Font.BOLD, 11));
182  closeButton.setText(org.openide.util.NbBundle.getMessage(CueBannerPanel.class, "CueBannerPanel.closeButton.text")); // NOI18N
183 
184  jSeparator1.setOrientation(javax.swing.SwingConstants.VERTICAL);
185 
186  javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
187  this.setLayout(layout);
188  layout.setHorizontalGroup(
189  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
190  .addGroup(layout.createSequentialGroup()
191  .addContainerGap()
192  .addComponent(autopsyLogo)
193  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
194  .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 5, javax.swing.GroupLayout.PREFERRED_SIZE)
195  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
196  .addGroup(layout.createSequentialGroup()
197  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
198  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
199  .addComponent(newCaseButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
200  .addComponent(openRecentCaseButton, javax.swing.GroupLayout.PREFERRED_SIZE, 70, javax.swing.GroupLayout.PREFERRED_SIZE)
201  .addComponent(openCaseButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
202  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
203  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
204  .addComponent(newCaseLabel)
205  .addComponent(openRecentCaseLabel)
206  .addComponent(openCaseLabel))
207  .addGap(18, 18, 18))
208  .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
209  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 139, Short.MAX_VALUE)
210  .addComponent(closeButton, javax.swing.GroupLayout.PREFERRED_SIZE, 73, javax.swing.GroupLayout.PREFERRED_SIZE)
211  .addContainerGap())))
212  );
213  layout.setVerticalGroup(
214  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
215  .addGroup(layout.createSequentialGroup()
216  .addContainerGap()
217  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
218  .addComponent(autopsyLogo, javax.swing.GroupLayout.PREFERRED_SIZE, 257, javax.swing.GroupLayout.PREFERRED_SIZE)
219  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
220  .addGroup(layout.createSequentialGroup()
221  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
222  .addComponent(newCaseButton, javax.swing.GroupLayout.PREFERRED_SIZE, 56, javax.swing.GroupLayout.PREFERRED_SIZE)
223  .addComponent(newCaseLabel))
224  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
225  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
226  .addComponent(openRecentCaseButton, javax.swing.GroupLayout.PREFERRED_SIZE, 70, javax.swing.GroupLayout.PREFERRED_SIZE)
227  .addComponent(openRecentCaseLabel))
228  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
229  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
230  .addComponent(openCaseButton, javax.swing.GroupLayout.PREFERRED_SIZE, 58, javax.swing.GroupLayout.PREFERRED_SIZE)
231  .addComponent(openCaseLabel))
232  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
233  .addComponent(closeButton))
234  .addComponent(jSeparator1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 260, javax.swing.GroupLayout.PREFERRED_SIZE)))
235  .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
236  );
237  }// </editor-fold>//GEN-END:initComponents
238 
239  private void newCaseButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_newCaseButtonActionPerformed
240  Lookup.getDefault().lookup(CaseNewActionInterface.class).actionPerformed(evt);
241  }//GEN-LAST:event_newCaseButtonActionPerformed
242 
243  private void openCaseButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_openCaseButtonActionPerformed
244  setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
245  Lookup.getDefault().lookup(CaseOpenAction.class).actionPerformed(evt);
246  setCursor(null);
247  }//GEN-LAST:event_openCaseButtonActionPerformed
248 
249  private void openRecentCaseButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_openRecentCaseButtonActionPerformed
250  recentCasesWindow.setLocationRelativeTo(this);
251  OpenRecentCasePanel.getInstance(); //refreshes the recent cases table
252  recentCasesWindow.setVisible(true);
253  }//GEN-LAST:event_openRecentCaseButtonActionPerformed
254 
255  // Variables declaration - do not modify//GEN-BEGIN:variables
256  private javax.swing.JLabel autopsyLogo;
257  private javax.swing.JButton closeButton;
258  private javax.swing.JSeparator jSeparator1;
259  private javax.swing.JButton newCaseButton;
260  private javax.swing.JLabel newCaseLabel;
261  private javax.swing.JButton openCaseButton;
262  private javax.swing.JLabel openCaseLabel;
263  private javax.swing.JButton openRecentCaseButton;
264  private javax.swing.JLabel openRecentCaseLabel;
265  // End of variables declaration//GEN-END:variables
266 
267 }
void openRecentCaseButtonActionPerformed(java.awt.event.ActionEvent evt)
void newCaseButtonActionPerformed(java.awt.event.ActionEvent evt)
void openCaseButtonActionPerformed(java.awt.event.ActionEvent evt)

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