Autopsy  4.19.3
Graphical digital forensics platform for The Sleuth Kit and other tools.
AboutWindowPanel.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.corecomponents;
20 
21 import java.awt.Cursor;
22 import java.awt.Desktop;
23 import java.awt.Window;
24 import java.io.File;
25 import java.io.IOException;
26 import java.net.MalformedURLException;
27 import java.net.URISyntaxException;
28 import java.net.URL;
29 import java.text.MessageFormat;
30 import java.util.Locale;
31 import java.util.logging.Level;
32 import javax.swing.Icon;
33 import javax.swing.ImageIcon;
34 import javax.swing.JPanel;
35 import javax.swing.SwingUtilities;
36 import javax.swing.event.HyperlinkEvent;
37 import javax.swing.event.HyperlinkListener;
38 import org.netbeans.core.actions.HTMLViewAction;
39 import org.openide.modules.Places;
40 import org.openide.util.ImageUtilities;
41 import org.openide.util.NbBundle;
45 import org.sleuthkit.datamodel.SleuthkitJNI;
46 
50 @SuppressWarnings("PMD.SingularField") // UI widgets cause lots of false positives
51 public final class AboutWindowPanel extends JPanel implements HyperlinkListener {
52 
53  private static final long serialVersionUID = 1L;
54  private static final Logger logger = Logger.getLogger(AboutWindowPanel.class.getName());
55  private URL url = null;
56  private final Icon about;
57  private boolean verboseLogging;
58 
59  public AboutWindowPanel() {
60  about = new ImageIcon(ImageUtilities.loadImage("org/sleuthkit/autopsy/images/splash.png"));
61  init();
62  }
63 
64  public AboutWindowPanel(String pathToBrandingImage) {
65  about = new ImageIcon(ImageUtilities.loadImage(pathToBrandingImage));
66  init();
67  }
68 
69  private void init() {
70  initComponents();
71  logoLabel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
72  description.setText(org.openide.util.NbBundle.getMessage(AboutWindowPanel.class,
73  "LBL_Description", new Object[]{getProductVersionValue(), getJavaValue(), getVMValue(),
74  getOperatingSystemValue(), getEncodingValue(), getSystemLocaleValue(), getUserDirValue(), getSleuthKitVersionValue(), Version.getNetbeansBuild(), Version.getBuildType().toString()}));
75  copyright.setBackground(getBackground());
76  if (verboseLoggingIsSet()) {
77  disableVerboseLoggingButton();
78  }
79 
81  copyright.addHyperlinkListener(hyperlinkListener);
82  description.addHyperlinkListener(hyperlinkListener);
83  }
84 
88  private class AboutPanelHyperlinkListener implements HyperlinkListener {
89  @Override
90  public void hyperlinkUpdate(HyperlinkEvent e) {
91  if(e.getEventType() == HyperlinkEvent.EventType.ACTIVATED
92  && Desktop.isDesktopSupported()) {
93  // Try to display the URL in the user's browswer.
94  try {
95  Desktop.getDesktop().browse(e.getURL().toURI());
96  } catch (IOException | URISyntaxException ex) {
97  logger.log(Level.WARNING, "Failed to display URL in external viewer", ex);
98  }
99  }
100  }
101  }
102 
103  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
104  private void initComponents() {
105 
106  logoLabel = new javax.swing.JLabel();
107  jScrollPane3 = new javax.swing.JScrollPane();
108  copyright = new javax.swing.JTextPane();
109  jScrollPane2 = new javax.swing.JScrollPane();
110  description = new javax.swing.JTextPane();
111  verboseLoggingButton = new javax.swing.JButton();
112  jButton2 = new javax.swing.JButton();
113 
114  setBackground(new java.awt.Color(255, 255, 255));
115 
116  logoLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
117  logoLabel.setIcon(about);
118  logoLabel.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
119  logoLabel.addMouseListener(new java.awt.event.MouseAdapter() {
120  public void mouseClicked(java.awt.event.MouseEvent evt) {
121  logoLabelMouseClicked(evt);
122  }
123  });
124 
125  jScrollPane3.setBorder(null);
126 
127  copyright.setEditable(false);
128  copyright.setBorder(null);
129  copyright.setContentType("text/html"); // NOI18N
130  copyright.setText(org.openide.util.NbBundle.getBundle(AboutWindowPanel.class).getString("LBL_Copyright")); // NOI18N
131  copyright.addMouseListener(new java.awt.event.MouseAdapter() {
132  public void mouseClicked(java.awt.event.MouseEvent evt) {
133  copyrightMouseClicked(evt);
134  }
135  });
136  jScrollPane3.setViewportView(copyright);
137 
138  description.setEditable(false);
139  description.setContentType("text/html"); // NOI18N
140  jScrollPane2.setViewportView(description);
141 
142  verboseLoggingButton.setBackground(new java.awt.Color(255, 255, 255));
143  verboseLoggingButton.setText("Activate verbose logging");
144  verboseLoggingButton.addActionListener(new java.awt.event.ActionListener() {
145  public void actionPerformed(java.awt.event.ActionEvent evt) {
146  activateVerboseLogging(evt);
147  }
148  });
149 
150  jButton2.setBackground(new java.awt.Color(255, 255, 255));
151  jButton2.setText(NbBundle.getMessage(AboutWindowPanel.class, "LBL_Close")); // NOI18N
152  jButton2.addActionListener(new java.awt.event.ActionListener() {
153  public void actionPerformed(java.awt.event.ActionEvent evt) {
154  jButton2ActionPerformed(evt);
155  }
156  });
157 
158  javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
159  this.setLayout(layout);
160  layout.setHorizontalGroup(
161  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
162  .addGroup(layout.createSequentialGroup()
163  .addContainerGap()
164  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
165  .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 486, Short.MAX_VALUE)
166  .addComponent(jScrollPane3, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 486, Short.MAX_VALUE)
167  .addComponent(logoLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 486, Short.MAX_VALUE)
168  .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
169  .addGap(0, 0, Short.MAX_VALUE)
170  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
171  .addComponent(verboseLoggingButton, javax.swing.GroupLayout.Alignment.TRAILING)
172  .addComponent(jButton2, javax.swing.GroupLayout.Alignment.TRAILING))))
173  .addContainerGap())
174  );
175  layout.setVerticalGroup(
176  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
177  .addGroup(layout.createSequentialGroup()
178  .addContainerGap()
179  .addComponent(logoLabel)
180  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
181  .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 140, javax.swing.GroupLayout.PREFERRED_SIZE)
182  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
183  .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 139, javax.swing.GroupLayout.PREFERRED_SIZE)
184  .addGap(18, 18, Short.MAX_VALUE)
185  .addComponent(verboseLoggingButton)
186  .addGap(18, 18, 18)
187  .addComponent(jButton2)
188  .addContainerGap())
189  );
190  }// </editor-fold>//GEN-END:initComponents
191 
192 private void copyrightMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_copyrightMouseClicked
193  showUrl();
194 }//GEN-LAST:event_copyrightMouseClicked
195 
196 private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
197  closeDialog();
198 }//GEN-LAST:event_jButton2ActionPerformed
199 
200 private void logoLabelMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_logoLabelMouseClicked
201  try {
202  url = new URL(NbBundle.getMessage(AboutWindowPanel.class, "URL_ON_IMG")); // NOI18N
203  showUrl();
204  } catch (MalformedURLException ex) {
205  //ignore
206  }
207  url = null;
208 }//GEN-LAST:event_logoLabelMouseClicked
209 
210  private void activateVerboseLogging(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_activateVerboseLogging
211  startVerboseLogging();
212  disableVerboseLoggingButton();
213  }//GEN-LAST:event_activateVerboseLogging
214  // Variables declaration - do not modify//GEN-BEGIN:variables
215  private javax.swing.JTextPane copyright;
216  private javax.swing.JTextPane description;
217  private javax.swing.JButton jButton2;
218  private javax.swing.JScrollPane jScrollPane2;
219  private javax.swing.JScrollPane jScrollPane3;
220  private javax.swing.JLabel logoLabel;
221  private javax.swing.JButton verboseLoggingButton;
222  // End of variables declaration//GEN-END:variables
223 
225  this.verboseLoggingButton.setEnabled(false);
226  this.verboseLoggingButton.setText(
227  NbBundle.getMessage(this.getClass(), "ProductInformationPanel.verbLoggingEnabled.text"));
228  }
229 
230  private void closeDialog() {
231  Window w = SwingUtilities.getWindowAncestor(this);
232  w.setVisible(false);
233  w.dispose();
234  }
235 
236  private void showUrl() {
237  if (url != null) {
238  org.openide.awt.StatusDisplayer.getDefault().setStatusText(
239  NbBundle.getMessage(HTMLViewAction.class, "CTL_OpeningBrowser")); //NON-NLS
240  // Try to display the URL in the user's browswer.
241  if(Desktop.isDesktopSupported()) {
242  try {
243  Desktop.getDesktop().browse(url.toURI());
244  } catch (IOException | URISyntaxException ex) {
245  logger.log(Level.WARNING, "Failed to display URL in external viewer", ex);
246  }
247  }
248  }
249  }
250 
251  private static String getSleuthKitVersionValue() {
252  return SleuthkitJNI.getVersion();
253  }
254 
255  private static String getProductVersionValue() {
256  return MessageFormat.format(
257  NbBundle.getBundle("org.netbeans.core.startup.Bundle").getString("currentVersion"), //NON-NLS
258  new Object[]{System.getProperty("netbeans.buildnumber")});
259  }
260 
261  private static String getOperatingSystemValue() {
262  return NbBundle.getMessage(AboutWindowPanel.class, "Format_OperatingSystem_Value",
263  System.getProperty("os.name", //NON-NLS
264  NbBundle.getMessage(AboutWindowPanel.class,
265  "ProductInformationPanel.propertyUnknown.text")),
266  System.getProperty("os.version", //NON-NLS
267  NbBundle.getMessage(AboutWindowPanel.class,
268  "ProductInformationPanel.propertyUnknown.text")),
269  System.getProperty("os.arch", //NON-NLS
270  NbBundle.getMessage(AboutWindowPanel.class,
271  "ProductInformationPanel.propertyUnknown.text")));
272  }
273 
274  private static String getJavaValue() {
275  return System.getProperty("java.version", //NON-NLS
276  NbBundle.getMessage(AboutWindowPanel.class,
277  "ProductInformationPanel.propertyUnknown.text"));
278  }
279 
280  private static String getVMValue() {
281  return NbBundle.getMessage(AboutWindowPanel.class,
282  "ProductInformationPanel.getVMValue.text",
283  System.getProperty("java.vm.name", //NON-NLS
284  NbBundle.getMessage(AboutWindowPanel.class,
285  "ProductInformationPanel.propertyUnknown.text")),
286  System.getProperty("java.vm.version", "")); //NON-NLS
287  }
288 
289  private static String getSystemLocaleValue() {
290  String branding;
291  return Locale.getDefault().toString() + ((branding = NbBundle.getBranding()) == null ? "" : (" (" + branding + ")")); // NOI18N
292  }
293 
294  private String getUserDirValue() {
295  return Places.getUserDirectory().getAbsolutePath();
296  }
297 
298  private static String getEncodingValue() {
299  return System.getProperty("file.encoding", //NON-NLS
300  NbBundle.getMessage(AboutWindowPanel.class, "ProductInformationPanel.propertyUnknown.text"));
301  }
302 
303  public void setCopyright(String text) {
304  copyright.setText(text);
305  }
306 
307  @Override
308  public void hyperlinkUpdate(HyperlinkEvent event) {
309  if (HyperlinkEvent.EventType.ENTERED == event.getEventType()) {
310  url = event.getURL();
311  } else if (HyperlinkEvent.EventType.EXITED == event.getEventType()) {
312  url = null;
313  }
314  }
315 
319  public void startVerboseLogging() {
320  verboseLogging = true;
321  String logPath = PlatformUtil.getUserDirectory() + File.separator + "sleuthkit.txt"; //NON-NLS
322 
323  SleuthkitJNI.startVerboseLogging(logPath);
324  }
325 
331  public boolean verboseLoggingIsSet() {
332  return verboseLogging;
333  }
334 }
void logoLabelMouseClicked(java.awt.event.MouseEvent evt)
void activateVerboseLogging(java.awt.event.ActionEvent evt)
void copyrightMouseClicked(java.awt.event.MouseEvent evt)
synchronized static Logger getLogger(String name)
Definition: Logger.java:124
void jButton2ActionPerformed(java.awt.event.ActionEvent evt)

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