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

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