19 package org.sleuthkit.autopsy.report;
21 import org.openide.util.NbBundle;
22 import java.awt.Color;
23 import java.awt.Cursor;
24 import java.awt.Desktop;
25 import java.awt.EventQueue;
26 import java.awt.event.MouseEvent;
27 import java.awt.event.MouseListener;
29 import java.io.IOException;
30 import java.util.logging.Level;
36 @SuppressWarnings(
"PMD.SingularField")
39 private static final long serialVersionUID = 1L;
41 private static final Color GREEN =
new Color(50, 205, 50);
42 private static final Color RED =
new Color(178, 34, 34);
50 "ReportProgressPanel.progress.queuing=Queuing...",
51 "ReportProgressPanel.progress.running=Running...",
52 "ReportProgressPanel.progress.complete=Complete",
53 "ReportProgressPanel.progress.canceled=Canceled",
54 "ReportProgressPanel.progress.error=Error",})
57 QUEUING(Bundle.ReportProgressPanel_progress_queuing()),
58 RUNNING(Bundle.ReportProgressPanel_progress_running()),
59 COMPLETE(Bundle.ReportProgressPanel_progress_complete()),
60 CANCELED(Bundle.ReportProgressPanel_progress_canceled()),
61 ERROR(Bundle.ReportProgressPanel_progress_error());
66 this.displayName = displayName;
84 reportProgressBar.setIndeterminate(
true);
85 reportProgressBar.setMaximum(100);
86 statusMessageLabel.setText(Bundle.ReportProgressPanel_progress_queuing());
88 reportLabel.setText(
"");
89 pathLabel.setText(
"");
98 public final void setLabels(String reportName, String reportPath) {
99 reportLabel.setText(reportName);
100 if (null != reportPath) {
101 pathLabel.setText(
"<html><u>" + shortenPath(reportPath) +
"</u></html>");
102 pathLabel.setToolTipText(reportPath);
103 String linkPath = reportPath;
104 pathLabel.addMouseListener(
new MouseListener() {
107 public void mouseClicked(MouseEvent mouseEvent) {
114 public void mousePressed(MouseEvent mouseEvent) {
121 public void mouseReleased(MouseEvent mouseEvent) {
122 File file =
new File(linkPath);
124 Desktop.getDesktop().open(file);
125 }
catch (IOException ioex) {
126 logger.log(Level.SEVERE,
"Error opening report file", ioex);
127 }
catch (IllegalArgumentException iaEx) {
128 logger.log(Level.SEVERE,
"Error opening report file", iaEx);
130 Desktop.getDesktop().open(file.getParentFile());
131 }
catch (IOException ioEx2) {
132 logger.log(Level.SEVERE,
"Error opening report file parent", ioEx2);
138 public void mouseEntered(MouseEvent e3) {
139 pathLabel.setForeground(Color.DARK_GRAY);
140 setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
144 public void mouseExited(MouseEvent e4) {
145 pathLabel.setForeground(Color.BLACK);
146 setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
150 pathLabel.setText(NbBundle.getMessage(
this.getClass(),
"ReportProgressPanel.initPathLabel.noFile"));
169 this.status = status;
176 EventQueue.invokeLater(() -> {
177 statusMessageLabel.setText(NbBundle.getMessage(
this.getClass(),
"ReportProgressPanel.start.progress.text"));
188 EventQueue.invokeLater(() -> {
190 reportProgressBar.setMaximum(max);
200 EventQueue.invokeLater(() -> {
202 reportProgressBar.setValue(reportProgressBar.getValue() + 1);
213 EventQueue.invokeLater(() -> {
215 reportProgressBar.setValue(value);
228 EventQueue.invokeLater(() -> {
230 reportProgressBar.setIndeterminate(indeterminate);
243 EventQueue.invokeLater(() -> {
245 statusMessageLabel.setText(statusMessage);
258 switch (reportStatus) {
260 complete(reportStatus, NbBundle.getMessage(
this.getClass(),
"ReportProgressPanel.complete.processLbl.text"));
263 complete(reportStatus, NbBundle.getMessage(
this.getClass(),
"ReportProgressPanel.complete.processLb2.text"));
266 complete(reportStatus,
"");
279 EventQueue.invokeLater(() -> {
280 reportProgressBar.setIndeterminate(
false);
282 switch (reportStatus) {
286 statusMessageLabel.setForeground(Color.BLACK);
287 statusMessageLabel.setText(statusMessage);
288 reportProgressBar.setValue(reportProgressBar.getMaximum());
289 reportProgressBar.setStringPainted(
true);
290 reportProgressBar.setForeground(GREEN);
298 statusMessageLabel.setForeground(RED);
299 statusMessageLabel.setText(statusMessage);
300 reportProgressBar.setValue(reportProgressBar.getMaximum());
301 reportProgressBar.setStringPainted(
true);
302 reportProgressBar.setForeground(RED);
330 reportProgressBar.setIndeterminate(
false);
331 reportProgressBar.setValue(0);
332 reportProgressBar.setStringPainted(
true);
333 reportProgressBar.setForeground(RED);
336 statusMessageLabel.setForeground(RED);
337 statusMessageLabel.setText(NbBundle.getMessage(
this.getClass(),
"ReportProgressPanel.cancel.procLbl.text"));
350 if (path.length() > 100) {
351 return path.substring(0, 10 + path.substring(10).indexOf(File.separator) + 1) +
"..."
352 + path.substring((path.length() - 70) + path.substring(path.length() - 70).indexOf(File.separator));
363 @SuppressWarnings(
"unchecked")
365 private
void initComponents() {
367 reportProgressBar =
new javax.swing.JProgressBar();
368 reportLabel =
new javax.swing.JLabel();
369 pathLabel =
new javax.swing.JLabel();
370 separationLabel =
new javax.swing.JLabel();
371 statusMessageLabel =
new javax.swing.JLabel();
373 setMinimumSize(
new java.awt.Dimension(486, 68));
375 reportLabel.setFont(reportLabel.getFont().deriveFont(reportLabel.getFont().getStyle() | java.awt.Font.BOLD));
376 org.openide.awt.Mnemonics.setLocalizedText(reportLabel,
org.openide.util.NbBundle.getMessage(
ReportProgressPanel.class,
"ReportProgressPanel.reportLabel.text"));
378 org.openide.awt.Mnemonics.setLocalizedText(pathLabel,
org.openide.util.NbBundle.getMessage(
ReportProgressPanel.class,
"ReportProgressPanel.pathLabel.text"));
379 pathLabel.setVerticalAlignment(javax.swing.SwingConstants.TOP);
381 org.openide.awt.Mnemonics.setLocalizedText(separationLabel,
org.openide.util.NbBundle.getMessage(
ReportProgressPanel.class,
"ReportProgressPanel.separationLabel.text"));
383 org.openide.awt.Mnemonics.setLocalizedText(statusMessageLabel,
org.openide.util.NbBundle.getMessage(
ReportProgressPanel.class,
"ReportProgressPanel.statusMessageLabel.text"));
385 javax.swing.GroupLayout layout =
new javax.swing.GroupLayout(
this);
386 this.setLayout(layout);
387 layout.setHorizontalGroup(
388 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
389 .addGroup(layout.createSequentialGroup()
391 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
392 .addComponent(statusMessageLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
393 .addComponent(reportProgressBar, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
394 .addGroup(layout.createSequentialGroup()
395 .addComponent(reportLabel)
396 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
397 .addComponent(separationLabel)
398 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
399 .addComponent(pathLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 548, Short.MAX_VALUE)))
402 layout.setVerticalGroup(
403 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
404 .addGroup(layout.createSequentialGroup()
406 .addComponent(reportProgressBar, javax.swing.GroupLayout.PREFERRED_SIZE, 16, javax.swing.GroupLayout.PREFERRED_SIZE)
407 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
408 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
409 .addComponent(reportLabel)
410 .addComponent(pathLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
411 .addComponent(separationLabel))
412 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
413 .addComponent(statusMessageLabel)
439 setLabels(reportName, reportPath);
final void setLabels(String reportName, String reportPath)
ReportProgressPanel(String reportName, String reportPath)
void setStatus(ReportStatus status)
void complete(ReportStatus reportStatus)
javax.swing.JLabel reportLabel
javax.swing.JLabel separationLabel
void setIndeterminate(boolean indeterminate)
javax.swing.JLabel pathLabel
void setMaximumProgress(int max)
void complete(ReportStatus reportStatus, String statusMessage)
volatile ReportStatus status
ReportStatus(String displayName)
synchronized static Logger getLogger(String name)
void updateStatusLabel(String statusMessage)
String shortenPath(String path)
javax.swing.JProgressBar reportProgressBar
void setProgress(int value)
javax.swing.JLabel statusMessageLabel