Autopsy 4.22.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-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 */
19package org.sleuthkit.autopsy.corecomponents;
20
21import java.awt.Cursor;
22import org.sleuthkit.autopsy.coreutils.Desktop;
23import java.awt.Window;
24import java.io.File;
25import java.io.IOException;
26import java.net.MalformedURLException;
27import java.net.URISyntaxException;
28import java.net.URL;
29import java.text.MessageFormat;
30import java.util.Locale;
31import java.util.logging.Level;
32import javax.swing.Icon;
33import javax.swing.ImageIcon;
34import javax.swing.JPanel;
35import javax.swing.SwingUtilities;
36import javax.swing.event.HyperlinkEvent;
37import javax.swing.event.HyperlinkListener;
38import org.netbeans.core.actions.HTMLViewAction;
39import org.openide.modules.Places;
40import org.openide.util.ImageUtilities;
41import org.openide.util.NbBundle;
42import org.sleuthkit.autopsy.coreutils.Logger;
43import org.sleuthkit.autopsy.coreutils.PlatformUtil;
44import org.sleuthkit.autopsy.coreutils.Version;
45import org.sleuthkit.datamodel.SleuthkitJNI;
46
50@SuppressWarnings("PMD.SingularField") // UI widgets cause lots of false positives
51public 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
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() {
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()) {
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
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.setText("Activate verbose logging");
143 verboseLoggingButton.addActionListener(new java.awt.event.ActionListener() {
144 public void actionPerformed(java.awt.event.ActionEvent evt) {
145 activateVerboseLogging(evt);
146 }
147 });
148
149 jButton2.setText(NbBundle.getMessage(AboutWindowPanel.class, "LBL_Close")); // NOI18N
150 jButton2.addActionListener(new java.awt.event.ActionListener() {
151 public void actionPerformed(java.awt.event.ActionEvent evt) {
152 jButton2ActionPerformed(evt);
153 }
154 });
155
156 javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
157 this.setLayout(layout);
158 layout.setHorizontalGroup(
159 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
160 .addGroup(layout.createSequentialGroup()
161 .addContainerGap()
162 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
163 .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 486, Short.MAX_VALUE)
164 .addComponent(jScrollPane3, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 486, Short.MAX_VALUE)
165 .addComponent(logoLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 486, Short.MAX_VALUE)
166 .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
167 .addGap(0, 0, Short.MAX_VALUE)
168 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
169 .addComponent(verboseLoggingButton, javax.swing.GroupLayout.Alignment.TRAILING)
170 .addComponent(jButton2, javax.swing.GroupLayout.Alignment.TRAILING))))
171 .addContainerGap())
172 );
173 layout.setVerticalGroup(
174 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
175 .addGroup(layout.createSequentialGroup()
176 .addContainerGap()
177 .addComponent(logoLabel)
178 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
179 .addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 184, Short.MAX_VALUE)
180 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
181 .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 130, javax.swing.GroupLayout.PREFERRED_SIZE)
182 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
183 .addComponent(verboseLoggingButton)
184 .addGap(18, 18, 18)
185 .addComponent(jButton2)
186 .addContainerGap())
187 );
188 }// </editor-fold>//GEN-END:initComponents
189
190private void copyrightMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_copyrightMouseClicked
191 showUrl();
192}//GEN-LAST:event_copyrightMouseClicked
193
194private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
195 closeDialog();
196}//GEN-LAST:event_jButton2ActionPerformed
197
198private void logoLabelMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_logoLabelMouseClicked
199 try {
200 url = new URL(NbBundle.getMessage(AboutWindowPanel.class, "URL_ON_IMG")); // NOI18N
201 showUrl();
202 } catch (MalformedURLException ex) {
203 //ignore
204 }
205 url = null;
206}//GEN-LAST:event_logoLabelMouseClicked
207
208 private void activateVerboseLogging(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_activateVerboseLogging
211 }//GEN-LAST:event_activateVerboseLogging
212 // Variables declaration - do not modify//GEN-BEGIN:variables
213 private javax.swing.JTextPane copyright;
214 private javax.swing.JTextPane description;
215 private javax.swing.JButton jButton2;
216 private javax.swing.JScrollPane jScrollPane2;
217 private javax.swing.JScrollPane jScrollPane3;
218 private javax.swing.JLabel logoLabel;
219 private javax.swing.JButton verboseLoggingButton;
220 // End of variables declaration//GEN-END:variables
221
223 this.verboseLoggingButton.setEnabled(false);
224 this.verboseLoggingButton.setText(
225 NbBundle.getMessage(this.getClass(), "ProductInformationPanel.verbLoggingEnabled.text"));
226 }
227
228 private void closeDialog() {
229 Window w = SwingUtilities.getWindowAncestor(this);
230 w.setVisible(false);
231 w.dispose();
232 }
233
234 private void showUrl() {
235 if (url != null) {
236 org.openide.awt.StatusDisplayer.getDefault().setStatusText(
237 NbBundle.getMessage(HTMLViewAction.class, "CTL_OpeningBrowser")); //NON-NLS
238 // Try to display the URL in the user's browswer.
240 try {
241 Desktop.getDesktop().browse(url.toURI());
242 } catch (IOException | URISyntaxException ex) {
243 logger.log(Level.WARNING, "Failed to display URL in external viewer", ex);
244 }
245 }
246 }
247 }
248
249 private static String getSleuthKitVersionValue() {
250 return SleuthkitJNI.getVersion();
251 }
252
253 private static String getProductVersionValue() {
254 return MessageFormat.format(
255 NbBundle.getBundle("org.netbeans.core.startup.Bundle").getString("currentVersion"), //NON-NLS
256 new Object[]{System.getProperty("netbeans.buildnumber")});
257 }
258
259 private static String getOperatingSystemValue() {
260 return NbBundle.getMessage(AboutWindowPanel.class, "Format_OperatingSystem_Value",
261 System.getProperty("os.name", //NON-NLS
262 NbBundle.getMessage(AboutWindowPanel.class,
263 "ProductInformationPanel.propertyUnknown.text")),
264 System.getProperty("os.version", //NON-NLS
265 NbBundle.getMessage(AboutWindowPanel.class,
266 "ProductInformationPanel.propertyUnknown.text")),
267 System.getProperty("os.arch", //NON-NLS
268 NbBundle.getMessage(AboutWindowPanel.class,
269 "ProductInformationPanel.propertyUnknown.text")));
270 }
271
272 private static String getJavaValue() {
273 return System.getProperty("java.version", //NON-NLS
274 NbBundle.getMessage(AboutWindowPanel.class,
275 "ProductInformationPanel.propertyUnknown.text"));
276 }
277
278 private static String getVMValue() {
279 return NbBundle.getMessage(AboutWindowPanel.class,
280 "ProductInformationPanel.getVMValue.text",
281 System.getProperty("java.vm.name", //NON-NLS
282 NbBundle.getMessage(AboutWindowPanel.class,
283 "ProductInformationPanel.propertyUnknown.text")),
284 System.getProperty("java.vm.version", "")); //NON-NLS
285 }
286
287 private static String getSystemLocaleValue() {
288 String branding;
289 return Locale.getDefault().toString() + ((branding = NbBundle.getBranding()) == null ? "" : (" (" + branding + ")")); // NOI18N
290 }
291
292 private String getUserDirValue() {
293 return Places.getUserDirectory().getAbsolutePath();
294 }
295
296 private static String getEncodingValue() {
297 return System.getProperty("file.encoding", //NON-NLS
298 NbBundle.getMessage(AboutWindowPanel.class, "ProductInformationPanel.propertyUnknown.text"));
299 }
300
301 public void setCopyright(String text) {
302 copyright.setText(text);
303 }
304
305 @Override
306 public void hyperlinkUpdate(HyperlinkEvent event) {
307 if (HyperlinkEvent.EventType.ENTERED == event.getEventType()) {
308 url = event.getURL();
309 } else if (HyperlinkEvent.EventType.EXITED == event.getEventType()) {
310 url = null;
311 }
312 }
313
317 public void startVerboseLogging() {
318 verboseLogging = true;
319 String logPath = PlatformUtil.getUserDirectory() + File.separator + "sleuthkit.txt"; //NON-NLS
320
321 SleuthkitJNI.startVerboseLogging(logPath);
322 }
323
329 public boolean verboseLoggingIsSet() {
330 return verboseLogging;
331 }
332}
void copyrightMouseClicked(java.awt.event.MouseEvent evt)
void activateVerboseLogging(java.awt.event.ActionEvent evt)
void jButton2ActionPerformed(java.awt.event.ActionEvent evt)
void logoLabelMouseClicked(java.awt.event.MouseEvent evt)
synchronized static Logger getLogger(String name)
Definition Logger.java:124

Copyright © 2012-2024 Sleuth Kit Labs. Generated on:
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.