KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > columba > core > gui > statusbar > WorkerItem


1 //The contents of this file are subject to the Mozilla Public License Version 1.1
2
//(the "License"); you may not use this file except in compliance with the
3
//License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
4
//
5
//Software distributed under the License is distributed on an "AS IS" basis,
6
//WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
7
//for the specific language governing rights and
8
//limitations under the License.
9
//
10
//The Original Code is "The Columba Project"
11
//
12
//The Initial Developers of the Original Code are Frederik Dietz and Timo Stich.
13
//Portions created by Frederik Dietz and Timo Stich are Copyright (C) 2003.
14
//
15
//All Rights Reserved.
16
package org.columba.core.gui.statusbar;
17
18 import java.awt.event.ActionEvent JavaDoc;
19 import java.awt.event.ActionListener JavaDoc;
20
21 import javax.swing.Timer JavaDoc;
22
23 import org.columba.core.base.SwingWorker;
24
25
26 class WorkerItem {
27     private final static int TWO_SECONDS = 2000;
28     private SwingWorker worker;
29     private int number;
30     private String JavaDoc text;
31     private int maximum;
32     private int value;
33     private boolean allowed;
34     private int priority;
35
36     public WorkerItem(SwingWorker w, int i, int priority) {
37         worker = w;
38         number = i;
39         this.priority = priority;
40
41         allowed = false;
42
43         new Timer JavaDoc(TWO_SECONDS,
44                 new ActionListener JavaDoc() {
45                     public void actionPerformed(ActionEvent JavaDoc e) {
46                         allowed = true;
47                     }
48                 });
49     }
50
51     public int getPriority() {
52         return priority;
53     }
54
55     public boolean isAllowed() {
56         return allowed;
57     }
58
59     public void setAllowed(boolean b) {
60         allowed = b;
61     }
62
63     public void setWorker(SwingWorker w) {
64         worker = w;
65     }
66
67     public void setCancel(boolean b) {
68         worker.setCancel(b);
69     }
70
71     public boolean getCancel() {
72         return worker.getCancel();
73     }
74
75     public void setNumber(int i) {
76         number = i;
77     }
78
79     public int getNumber() {
80         return number;
81     }
82
83     public Thread JavaDoc getThread() {
84         return worker.getThread();
85     }
86
87     public void setText(String JavaDoc s) {
88         this.text = s;
89     }
90
91     public String JavaDoc getText() {
92         return text;
93     }
94
95     public void setProgressBarMaximum(int m) {
96         maximum = m;
97     }
98
99     public int getProgressBarMaximum() {
100         return maximum;
101     }
102
103     public void setProgressBarValue(int v) {
104         if (v <= getProgressBarMaximum()) {
105             value = v;
106         }
107     }
108
109     public int getProgressBarValue() {
110         return value;
111     }
112 }
113
Popular Tags