blob: 0f71c642f689fb180c69fd44053cd1fc5e2a0a80 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
|
/*
* Jitsi, the OpenSource Java VoIP and Instant Messaging client.
*
* Distributable under LGPL license. See terms of license at gnu.org.
*/
package net.java.sip.communicator.plugin.dictaccregwizz;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import net.java.sip.communicator.plugin.desktoputil.*;
/**
* Panel showing the current status of the search of the strategies
*
* @author ROTH Damien
*/
public class ProgressPanel
extends TransparentPanel
implements ActionListener
{
/**
* Serial version UID.
*/
private static final long serialVersionUID = 0L;
private JPanel rightPanel;
private JLabel messageLabel;
private JLabel progressLabel;
private JButton cancelButton;
private int currentStep;
private int totalSteps;
private boolean isBuild;
private ThreadManager searchThread;
/**
* Create an instance of <tt>ProgressPanel</tt>
* @param searchThread The thread manager
*/
public ProgressPanel(ThreadManager searchThread)
{
super(new BorderLayout());
// Element creation
this.messageLabel = new JLabel(" ");
this.progressLabel = new JLabel(" ");
this.cancelButton
= new JButton(Resources.getString("service.gui.CANCEL"));
this.cancelButton.addActionListener(this);
// Right panel init
this.rightPanel = new TransparentPanel(new FlowLayout(FlowLayout.RIGHT));
this.rightPanel.add(this.progressLabel);
this.rightPanel.add(this.cancelButton);
this.searchThread = searchThread;
init();
this.totalSteps = ThreadManager.NB_STEPS;
}
/**
* Init the values
*/
private void init()
{
this.isBuild = false;
this.currentStep = 1;
this.add(this.messageLabel, BorderLayout.CENTER);
}
/**
* Build the UI
*/
private void build()
{
if (this.isBuild)
{
return;
}
this.add(this.messageLabel, BorderLayout.CENTER);
this.add(this.rightPanel, BorderLayout.EAST);
this.isBuild = true;
}
/**
* Move to the next step without updating the message
*/
public void nextStep()
{
nextStep(this.messageLabel.getText());
}
/**
* Mode to the next step with a new message
* @param message Message
*/
public void nextStep(String message)
{
if (this.currentStep > this.totalSteps)
{
finish();
}
build();
this.messageLabel.setText(message);
this.progressLabel.setText(currentStep + "/" + totalSteps);
this.currentStep++;
}
/**
* Informs the end of the progress. Remove all the components and
* reset the values
*/
public void finish()
{
// Remove all elements
this.removeAll();
// Re-init the panel
this.messageLabel.setText(" ");
this.progressLabel.setText(" ");
init();
this.repaint();
this.validate();
}
public void actionPerformed(ActionEvent arg0)
{
this.searchThread.cancel();
this.finish();
}
}
|