Autopsy  4.1
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-2016 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.Image;
23 import java.awt.Window;
24 import java.io.File;
25 import java.net.MalformedURLException;
26 import java.net.URL;
27 import java.text.MessageFormat;
28 import java.util.Locale;
30 import javax.swing.Icon;
31 import javax.swing.ImageIcon;
32 import javax.swing.JPanel;
33 import javax.swing.SwingUtilities;
34 import javax.swing.event.HyperlinkEvent;
35 import javax.swing.event.HyperlinkListener;
36 import org.netbeans.core.actions.HTMLViewAction;
37 import org.openide.awt.HtmlBrowser;
38 import org.openide.modules.Places;
39 import org.openide.util.ImageUtilities;
40 import org.openide.util.NbBundle;
44 
48 public final class AboutWindowPanel extends JPanel implements HyperlinkListener {
49 
50  private static final long serialVersionUID = 1L;
51  private URL url = null;
52  private final Icon about;
53  private boolean verboseLogging;
54 
55  public AboutWindowPanel() {
56  about = new ImageIcon(ImageUtilities.loadImage("org/sleuthkit/autopsy/images/splash.png"));
57  init();
58  }
59 
60  public AboutWindowPanel(String pathToBrandingImage) {
61  about = new ImageIcon(ImageUtilities.loadImage(pathToBrandingImage));
62  init();
63  }
64 
65  private void init() {
67  logoLabel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
68  description.setText(org.openide.util.NbBundle.getMessage(AboutWindowPanel.class,
69  "LBL_Description", new Object[]{getProductVersionValue(), getJavaValue(), getVMValue(),
70  getOperatingSystemValue(), getEncodingValue(), getSystemLocaleValue(), getUserDirValue(), getSleuthKitVersionValue(), Version.getNetbeansBuild(), Version.getBuildType().toString()}));
71  description.addHyperlinkListener(this);
72  copyright.addHyperlinkListener(this);
73  copyright.setBackground(getBackground());
74  if (verboseLoggingIsSet()) {
76  }
77  }
78 
79  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
80  private void initComponents() {
81 
82  logoLabel = new javax.swing.JLabel();
83  jScrollPane3 = new javax.swing.JScrollPane();
84  copyright = new javax.swing.JTextPane();
85  jScrollPane2 = new javax.swing.JScrollPane();
86  description = new javax.swing.JTextPane();
87  verboseLoggingButton = new javax.swing.JButton();
88  jButton2 = new javax.swing.JButton();
89 
90  setBackground(new java.awt.Color(255, 255, 255));
91 
92  logoLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
93  logoLabel.setIcon(about);
94  logoLabel.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
95  logoLabel.addMouseListener(new java.awt.event.MouseAdapter() {
96  public void mouseClicked(java.awt.event.MouseEvent evt) {
98  }
99  });
100 
101  jScrollPane3.setBorder(null);
102 
103  copyright.setEditable(false);
104  copyright.setBorder(null);
105  copyright.setContentType("text/html"); // NOI18N
106  copyright.setText(org.openide.util.NbBundle.getBundle(AboutWindowPanel.class).getString("LBL_Copyright")); // NOI18N
107  copyright.addMouseListener(new java.awt.event.MouseAdapter() {
108  public void mouseClicked(java.awt.event.MouseEvent evt) {
110  }
111  });
112  jScrollPane3.setViewportView(copyright);
113 
114  description.setEditable(false);
115  description.setContentType("text/html"); // NOI18N
116  jScrollPane2.setViewportView(description);
117 
118  verboseLoggingButton.setBackground(new java.awt.Color(255, 255, 255));
119  verboseLoggingButton.setText(NbBundle.getMessage(this.getClass(), "AboutWindowPanel.actVerboseLogging.text"));
120  verboseLoggingButton.addActionListener(new java.awt.event.ActionListener() {
121  public void actionPerformed(java.awt.event.ActionEvent evt) {
123  }
124  });
125 
126  jButton2.setBackground(new java.awt.Color(255, 255, 255));
127  jButton2.setText(NbBundle.getMessage(AboutWindowPanel.class, "LBL_Close")); // NOI18N
128  jButton2.addActionListener(new java.awt.event.ActionListener() {
129  public void actionPerformed(java.awt.event.ActionEvent evt) {
131  }
132  });
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  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
141  .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 486, Short.MAX_VALUE)
142  .addComponent(jScrollPane3, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 486, Short.MAX_VALUE)
143  .addComponent(logoLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 486, Short.MAX_VALUE)
144  .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
145  .addGap(0, 0, Short.MAX_VALUE)
146  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
147  .addComponent(verboseLoggingButton, javax.swing.GroupLayout.Alignment.TRAILING)
148  .addComponent(jButton2, javax.swing.GroupLayout.Alignment.TRAILING))))
149  .addContainerGap())
150  );
151  layout.setVerticalGroup(
152  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
153  .addGroup(layout.createSequentialGroup()
154  .addContainerGap()
155  .addComponent(logoLabel)
156  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
157  .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 140, javax.swing.GroupLayout.PREFERRED_SIZE)
158  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
159  .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 139, javax.swing.GroupLayout.PREFERRED_SIZE)
160  .addGap(18, 18, Short.MAX_VALUE)
161  .addComponent(verboseLoggingButton)
162  .addGap(18, 18, 18)
163  .addComponent(jButton2)
164  .addContainerGap())
165  );
166  }// </editor-fold>//GEN-END:initComponents
167 
168 private void copyrightMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_copyrightMouseClicked
169  showUrl();
170 }//GEN-LAST:event_copyrightMouseClicked
171 
172 private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
173  closeDialog();
174 }//GEN-LAST:event_jButton2ActionPerformed
175 
176 private void logoLabelMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_logoLabelMouseClicked
177  try {
178  url = new URL(NbBundle.getMessage(AboutWindowPanel.class, "URL_ON_IMG")); // NOI18N
179  showUrl();
180  } catch (MalformedURLException ex) {
181  //ignore
182  }
183  url = null;
184 }//GEN-LAST:event_logoLabelMouseClicked
185 
186  private void activateVerboseLogging(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_activateVerboseLogging
189  }//GEN-LAST:event_activateVerboseLogging
190  // Variables declaration - do not modify//GEN-BEGIN:variables
191  private javax.swing.JTextPane copyright;
192  private javax.swing.JTextPane description;
193  private javax.swing.JButton jButton2;
194  private javax.swing.JScrollPane jScrollPane2;
195  private javax.swing.JScrollPane jScrollPane3;
196  private javax.swing.JLabel logoLabel;
197  private javax.swing.JButton verboseLoggingButton;
198  // End of variables declaration//GEN-END:variables
199 
201  this.verboseLoggingButton.setEnabled(false);
202  this.verboseLoggingButton.setText(
203  NbBundle.getMessage(this.getClass(), "ProductInformationPanel.verbLoggingEnabled.text"));
204  }
205 
206  private void closeDialog() {
207  Window w = SwingUtilities.getWindowAncestor(this);
208  w.setVisible(false);
209  w.dispose();
210  }
211 
212  private void showUrl() {
213  if (url != null) {
214  org.openide.awt.StatusDisplayer.getDefault().setStatusText(
215  NbBundle.getBundle(HTMLViewAction.class).getString("CTL_OpeningBrowser")); //NON-NLS
216  HtmlBrowser.URLDisplayer.getDefault().showURL(url);
217  }
218  }
219 
220  private static String getSleuthKitVersionValue() {
221  return SleuthkitJNI.getVersion();
222  }
223 
224  private static String getProductVersionValue() {
225  return MessageFormat.format(
226  NbBundle.getBundle("org.netbeans.core.startup.Bundle").getString("currentVersion"), //NON-NLS
227  new Object[]{System.getProperty("netbeans.buildnumber")});
228  }
229 
230  private static String getOperatingSystemValue() {
231  return NbBundle.getMessage(AboutWindowPanel.class, "Format_OperatingSystem_Value",
232  System.getProperty("os.name", //NON-NLS
233  NbBundle.getMessage(AboutWindowPanel.class,
234  "ProductInformationPanel.propertyUnknown.text")),
235  System.getProperty("os.version", //NON-NLS
236  NbBundle.getMessage(AboutWindowPanel.class,
237  "ProductInformationPanel.propertyUnknown.text")),
238  System.getProperty("os.arch", //NON-NLS
239  NbBundle.getMessage(AboutWindowPanel.class,
240  "ProductInformationPanel.propertyUnknown.text")));
241  }
242 
243  private static String getJavaValue() {
244  return System.getProperty("java.version", //NON-NLS
245  NbBundle.getMessage(AboutWindowPanel.class,
246  "ProductInformationPanel.propertyUnknown.text"));
247  }
248 
249  private static String getVMValue() {
250  return NbBundle.getMessage(AboutWindowPanel.class,
251  "ProductInformationPanel.getVMValue.text",
252  System.getProperty("java.vm.name", //NON-NLS
253  NbBundle.getMessage(AboutWindowPanel.class,
254  "ProductInformationPanel.propertyUnknown.text")),
255  System.getProperty("java.vm.version", "")); //NON-NLS
256  }
257 
258  private static String getSystemLocaleValue() {
259  String branding;
260  return Locale.getDefault().toString() + ((branding = NbBundle.getBranding()) == null ? "" : (" (" + branding + ")")); // NOI18N
261  }
262 
263  private String getUserDirValue() {
264  return Places.getUserDirectory().getAbsolutePath();
265  }
266 
267  private static String getEncodingValue() {
268  return System.getProperty("file.encoding", //NON-NLS
269  NbBundle.getMessage(AboutWindowPanel.class, "ProductInformationPanel.propertyUnknown.text"));
270  }
271 
272  public void setCopyright(String text) {
273  copyright.setText(text);
274  }
275 
276  @Override
277  public void hyperlinkUpdate(HyperlinkEvent event) {
278  if (HyperlinkEvent.EventType.ENTERED == event.getEventType()) {
279  url = event.getURL();
280  } else if (HyperlinkEvent.EventType.EXITED == event.getEventType()) {
281  url = null;
282  }
283  }
284 
288  public void startVerboseLogging() {
289  verboseLogging = true;
290  String logPath = PlatformUtil.getUserDirectory() + File.separator + "sleuthkit.txt"; //NON-NLS
291 
293  }
294 
300  public boolean verboseLoggingIsSet() {
301  return verboseLogging;
302  }
303 }
void logoLabelMouseClicked(java.awt.event.MouseEvent evt)
void activateVerboseLogging(java.awt.event.ActionEvent evt)
void copyrightMouseClicked(java.awt.event.MouseEvent evt)
void jButton2ActionPerformed(java.awt.event.ActionEvent evt)
static void startVerboseLogging(String logPath)

Copyright © 2012-2016 Basis Technology. Generated on: Mon Apr 24 2017
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.