1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.jadira.dependencynavigator.gui;
19
20 import java.io.File;
21
22 import javax.swing.JLabel;
23 import javax.swing.SwingUtilities;
24
25 import org.jadira.dependencynavigator.implementations.IProgressMeter;
26 import org.jadira.dependencynavigator.model.Artifact;
27
28 public class ProgressMeter implements IProgressMeter {
29
30 private final JLabel label;
31
32 public ProgressMeter(JLabel label) {
33 this.label = label;
34 }
35
36 public JLabel getLabel() {
37 return this.label;
38 }
39
40 private void report(String message) {
41 SwingUtilities.invokeLater(new ProgressUpdateThread(message));
42 }
43
44 public void resolving(Artifact artifact) {
45 report("resolving: " + artifact.getId());
46 }
47
48 public void scanning(File pomFile) {
49 report("scanning: " + pomFile.getPath());
50 }
51
52 public void adding(File pomFile) {
53 report("adding: " + pomFile.getPath());
54 }
55
56 public void error(Exception e) {
57 report("error [" + e.getClass().getName() + "] " + e.getMessage());
58 }
59
60 public void ready() {
61 report("ready");
62 }
63
64 public void snapshotComplete() {
65 report("snapshot complete");
66 }
67
68 private class ProgressUpdateThread implements Runnable {
69
70 private String message;
71
72 public ProgressUpdateThread(String message) {
73 this.message = message;
74 }
75
76 public void run() {
77 label.setText(message);
78 }
79
80 }
81 }