Autopsy  4.16.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-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().getSize()+2f));
160  newCaseLabel.setText(org.openide.util.NbBundle.getMessage(CueBannerPanel.class, "CueBannerPanel.newCaseLabel.text")); // NOI18N
161 
162  openRecentCaseLabel.setFont(openRecentCaseLabel.getFont().deriveFont(openRecentCaseLabel.getFont().getSize()+2f));
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().getSize()+2f));
179  openCaseLabel.setText(org.openide.util.NbBundle.getMessage(CueBannerPanel.class, "CueBannerPanel.openCaseLabel.text")); // NOI18N
180 
181  closeButton.setText(org.openide.util.NbBundle.getMessage(CueBannerPanel.class, "CueBannerPanel.closeButton.text")); // NOI18N
182 
183  jSeparator1.setOrientation(javax.swing.SwingConstants.VERTICAL);
184 
185  javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
186  this.setLayout(layout);
187  layout.setHorizontalGroup(
188  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
189  .addGroup(layout.createSequentialGroup()
190  .addContainerGap()
191  .addComponent(autopsyLogo)
192  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
193  .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 5, javax.swing.GroupLayout.PREFERRED_SIZE)
194  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
195  .addGroup(layout.createSequentialGroup()
196  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
197  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
198  .addComponent(newCaseButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
199  .addComponent(openRecentCaseButton, javax.swing.GroupLayout.PREFERRED_SIZE, 70, javax.swing.GroupLayout.PREFERRED_SIZE)
200  .addComponent(openCaseButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
201  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
202  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
203  .addComponent(newCaseLabel)
204  .addComponent(openRecentCaseLabel)
205  .addComponent(openCaseLabel))
206  .addGap(18, 18, 18))
207  .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
208  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 139, Short.MAX_VALUE)
209  .addComponent(closeButton, javax.swing.GroupLayout.PREFERRED_SIZE, 73, javax.swing.GroupLayout.PREFERRED_SIZE)
210  .addContainerGap())))
211  );
212  layout.setVerticalGroup(
213  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
214  .addGroup(layout.createSequentialGroup()
215  .addContainerGap()
216  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
217  .addComponent(autopsyLogo, javax.swing.GroupLayout.PREFERRED_SIZE, 257, javax.swing.GroupLayout.PREFERRED_SIZE)
218  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
219  .addGroup(layout.createSequentialGroup()
220  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
221  .addComponent(newCaseButton, javax.swing.GroupLayout.PREFERRED_SIZE, 56, javax.swing.GroupLayout.PREFERRED_SIZE)
222  .addComponent(newCaseLabel))
223  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
224  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
225  .addComponent(openRecentCaseButton, javax.swing.GroupLayout.PREFERRED_SIZE, 70, javax.swing.GroupLayout.PREFERRED_SIZE)
226  .addComponent(openRecentCaseLabel))
227  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
228  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
229  .addComponent(openCaseButton, javax.swing.GroupLayout.PREFERRED_SIZE, 58, javax.swing.GroupLayout.PREFERRED_SIZE)
230  .addComponent(openCaseLabel))
231  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
232  .addComponent(closeButton))
233  .addComponent(jSeparator1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 260, javax.swing.GroupLayout.PREFERRED_SIZE)))
234  .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
235  );
236  }// </editor-fold>//GEN-END:initComponents
237 
238  private void newCaseButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_newCaseButtonActionPerformed
239  Lookup.getDefault().lookup(CaseNewActionInterface.class).actionPerformed(evt);
240  }//GEN-LAST:event_newCaseButtonActionPerformed
241 
242  private void openCaseButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_openCaseButtonActionPerformed
243  setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
244  Lookup.getDefault().lookup(CaseOpenAction.class).actionPerformed(evt);
245  setCursor(null);
246  }//GEN-LAST:event_openCaseButtonActionPerformed
247 
248  private void openRecentCaseButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_openRecentCaseButtonActionPerformed
249  recentCasesWindow.setLocationRelativeTo(this);
250  OpenRecentCasePanel.getInstance(); //refreshes the recent cases table
251  // Workaround to ensure that dialog is not hidden on macOS.
252  recentCasesWindow.setAlwaysOnTop(true);
253  recentCasesWindow.setVisible(true);
254  }//GEN-LAST:event_openRecentCaseButtonActionPerformed
255 
256  // Variables declaration - do not modify//GEN-BEGIN:variables
257  private javax.swing.JLabel autopsyLogo;
258  private javax.swing.JButton closeButton;
259  private javax.swing.JSeparator jSeparator1;
260  private javax.swing.JButton newCaseButton;
261  private javax.swing.JLabel newCaseLabel;
262  private javax.swing.JButton openCaseButton;
263  private javax.swing.JLabel openCaseLabel;
264  private javax.swing.JButton openRecentCaseButton;
265  private javax.swing.JLabel openRecentCaseLabel;
266  // End of variables declaration//GEN-END:variables
267 
268 }
void openRecentCaseButtonActionPerformed(java.awt.event.ActionEvent evt)
void newCaseButtonActionPerformed(java.awt.event.ActionEvent evt)
void openCaseButtonActionPerformed(java.awt.event.ActionEvent evt)

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