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);
66 reportProgressBar.setIndeterminate(
true);
67 reportProgressBar.setMaximum(100);
68 reportLabel.setText(reportName);
69 statusMessageLabel.setText(NbBundle.getMessage(
this.getClass(),
"ReportProgressPanel.progress.queuing"));
71 if (null != reportPath) {
72 pathLabel.setText(
"<html><u>" + shortenPath(reportPath) +
"</u></html>");
73 pathLabel.setToolTipText(reportPath);
74 String linkPath = reportPath;
75 pathLabel.addMouseListener(
new MouseListener() {
78 public void mouseClicked(MouseEvent mouseEvent) {
82 public void mousePressed(MouseEvent mouseEvent) {
86 public void mouseReleased(MouseEvent mouseEvent) {
87 File file =
new File(linkPath);
89 Desktop.getDesktop().open(file);
90 }
catch (IOException ioex) {
91 logger.log(Level.SEVERE,
"Error opening report file", ioex);
92 }
catch (IllegalArgumentException iaEx) {
93 logger.log(Level.SEVERE,
"Error opening report file", iaEx);
95 Desktop.getDesktop().open(file.getParentFile());
96 }
catch (IOException ioEx2) {
97 logger.log(Level.SEVERE,
"Error opening report file parent", ioEx2);
103 public void mouseEntered(MouseEvent e3) {
104 pathLabel.setForeground(Color.DARK_GRAY);
105 setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
109 public void mouseExited(MouseEvent e4) {
110 pathLabel.setForeground(Color.BLACK);
111 setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
115 pathLabel.setText(NbBundle.getMessage(
this.getClass(),
"ReportProgressPanel.initPathLabel.noFile"));
132 EventQueue.invokeLater(() -> {
133 statusMessageLabel.setText(NbBundle.getMessage(
this.getClass(),
"ReportProgressPanel.start.progress.text"));
144 EventQueue.invokeLater(() -> {
146 reportProgressBar.setMaximum(max);
156 EventQueue.invokeLater(() -> {
158 reportProgressBar.setValue(reportProgressBar.getValue() + 1);
169 EventQueue.invokeLater(() -> {
171 reportProgressBar.setValue(value);
184 EventQueue.invokeLater(() -> {
186 reportProgressBar.setIndeterminate(indeterminate);
199 EventQueue.invokeLater(() -> {
201 statusMessageLabel.setText(statusMessage);
213 EventQueue.invokeLater(() -> {
214 reportProgressBar.setIndeterminate(
false);
216 switch (reportStatus) {
220 statusMessageLabel.setForeground(Color.BLACK);
221 statusMessageLabel.setText(NbBundle.getMessage(
this.getClass(),
"ReportProgressPanel.complete.processLbl.text"));
222 reportProgressBar.setValue(reportProgressBar.getMaximum());
223 reportProgressBar.setStringPainted(
true);
224 reportProgressBar.setForeground(GREEN);
225 reportProgressBar.setString(
"Complete");
232 statusMessageLabel.setForeground(RED);
233 statusMessageLabel.setText(NbBundle.getMessage(
this.getClass(),
"ReportProgressPanel.complete.processLb2.text"));
234 reportProgressBar.setValue(reportProgressBar.getMaximum());
235 reportProgressBar.setStringPainted(
true);
236 reportProgressBar.setForeground(RED);
237 reportProgressBar.setString(
"Error");
264 reportProgressBar.setIndeterminate(
false);
265 reportProgressBar.setValue(0);
266 reportProgressBar.setStringPainted(
true);
267 reportProgressBar.setForeground(RED);
268 reportProgressBar.setString(
"Cancelled");
270 statusMessageLabel.setForeground(RED);
271 statusMessageLabel.setText(NbBundle.getMessage(
this.getClass(),
"ReportProgressPanel.cancel.procLbl.text"));
284 if (path.length() > 100) {
285 return path.substring(0, 10 + path.substring(10).indexOf(File.separator) + 1) +
"..."
286 + path.substring((path.length() - 70) + path.substring(path.length() - 70).indexOf(File.separator));
297 @SuppressWarnings(
"unchecked")
299 private
void initComponents() {
301 reportProgressBar =
new javax.swing.JProgressBar();
302 reportLabel =
new javax.swing.JLabel();
303 pathLabel =
new javax.swing.JLabel();
304 separationLabel =
new javax.swing.JLabel();
305 statusMessageLabel =
new javax.swing.JLabel();
307 setFont(getFont().deriveFont(getFont().getStyle() & ~java.awt.Font.BOLD, 11));
308 setMinimumSize(
new java.awt.Dimension(486, 68));
310 reportProgressBar.setFont(reportProgressBar.getFont().deriveFont(reportProgressBar.getFont().getStyle() & ~java.awt.Font.BOLD, 11));
312 reportLabel.setFont(reportLabel.getFont().deriveFont(reportLabel.getFont().getStyle() | java.awt.Font.BOLD, 11));
313 org.openide.awt.Mnemonics.setLocalizedText(reportLabel,
org.openide.util.NbBundle.getMessage(
ReportProgressPanel.class,
"ReportProgressPanel.reportLabel.text"));
315 pathLabel.setFont(pathLabel.getFont().deriveFont(pathLabel.getFont().getStyle() & ~java.awt.Font.BOLD, 11));
316 org.openide.awt.Mnemonics.setLocalizedText(pathLabel,
org.openide.util.NbBundle.getMessage(
ReportProgressPanel.class,
"ReportProgressPanel.pathLabel.text"));
317 pathLabel.setVerticalAlignment(javax.swing.SwingConstants.TOP);
319 separationLabel.setFont(separationLabel.getFont().deriveFont(separationLabel.getFont().getStyle() & ~java.awt.Font.BOLD, 11));
320 org.openide.awt.Mnemonics.setLocalizedText(separationLabel,
org.openide.util.NbBundle.getMessage(
ReportProgressPanel.class,
"ReportProgressPanel.separationLabel.text"));
322 org.openide.awt.Mnemonics.setLocalizedText(statusMessageLabel,
org.openide.util.NbBundle.getMessage(
ReportProgressPanel.class,
"ReportProgressPanel.statusMessageLabel.text"));
324 javax.swing.GroupLayout layout =
new javax.swing.GroupLayout(
this);
325 this.setLayout(layout);
326 layout.setHorizontalGroup(
327 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
328 .addGroup(layout.createSequentialGroup()
330 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
331 .addComponent(statusMessageLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
332 .addComponent(reportProgressBar, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
333 .addGroup(layout.createSequentialGroup()
334 .addComponent(reportLabel)
335 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
336 .addComponent(separationLabel)
337 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
338 .addComponent(pathLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 548, Short.MAX_VALUE)))
341 layout.setVerticalGroup(
342 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
343 .addGroup(layout.createSequentialGroup()
345 .addComponent(reportProgressBar, javax.swing.GroupLayout.PREFERRED_SIZE, 16, javax.swing.GroupLayout.PREFERRED_SIZE)
346 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
347 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
348 .addComponent(reportLabel)
349 .addComponent(pathLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
350 .addComponent(separationLabel))
351 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
352 .addComponent(statusMessageLabel)
ReportProgressPanel(String reportName, String reportPath)
void complete(ReportStatus reportStatus)
javax.swing.JLabel reportLabel
javax.swing.JLabel separationLabel
void setIndeterminate(boolean indeterminate)
javax.swing.JLabel pathLabel
void setMaximumProgress(int max)
volatile ReportStatus status
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