Source code: evt/gui/JspmEvtStatusPanel.java
1 /*-----------------------------------------------------------------------------------------------------*/
2 /* */
3 /* Copyright (C) */
4 /* */
5 /* This program is free software; you can redistribute it and/or modify it under the terms of the GNU */
6 /* General Public License as published by the Free Software Foundation; either version 2 of the */
7 /* License, or (at your option) any later version. */
8 /* */
9 /* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; */
10 /* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR */
11 /* PURPOSE. See the GNU General Public License for more details. */
12 /* */
13 /* You should have received a copy of the GNU General Public License along with this program; if */
14 /* not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA */
15 /* 02111-1307 USA */
16 /* */
17 /*-----------------------------------------------------------------------------------------------------*/
18 /* */
19 /* $Author: strand01 $ $Revision: 1.3 $ $Date: 2001/12/20 14:23:03 $ */
20 /* */
21 /*-----------------------------------------------------------------------------------------------------*/
22
23 package evt.gui;
24
25 // Java classes
26 import java.awt.*;
27 import java.text.*;
28 import java.util.*;
29
30 // Swing classes
31 import javax.swing.*;
32
33 // JSPM classes
34 import com.jdk.*;
35
36 /**
37 * This class provides the status panel, which consits of a progress bar on the right side and a
38 * status line on the left side.
39 *
40 * @author Steve Randall (strand012001@yahoo.com)
41 * @version 0.0.8
42 * @date 31/10/2001
43 */
44 public class JspmEvtStatusPanel extends JPanel
45 {
46 /**
47 * The progress bar.
48 */
49 private JProgressBar progress;
50
51 /**
52 * The status text field.
53 */
54 private JTextField statusText, dateText, timeText, serverText, busyText;
55
56 /**
57 * Constructor.
58 */
59 public JspmEvtStatusPanel() {
60
61 setLayout(new FlowLayout(FlowLayout.LEFT));
62 setFont(JspmConstants.DEFAULT_FONT);
63 setToolTipText("JSPM Event Console Status Panel");
64 // setPreferredSize(new Dimension(1020, 30));
65
66 progress = new JProgressBar();
67 progress.setPreferredSize(new Dimension(100, 20));
68
69 statusText = new JTextField("JSPM "+JspmConstants.VERSION);
70 statusText.setFont(JspmConstants.DEFAULT_FONT);
71 statusText.setEditable(false);
72 statusText.setBackground(Color.lightGray);
73 statusText.setPreferredSize(new Dimension(780, 20));
74 statusText.setToolTipText("JSPM-Manager status line");
75
76 dateText = new JTextField("Date");
77 dateText.setFont(JspmConstants.DEFAULT_FONT);
78 dateText.setEditable(false);
79 dateText.setBackground(Color.lightGray);
80 dateText.setPreferredSize(new Dimension(80, 20));
81 dateText.setToolTipText("Current date");
82
83 timeText = new JTextField("Date");
84 timeText.setFont(JspmConstants.DEFAULT_FONT);
85 timeText.setEditable(false);
86 timeText.setBackground(Color.lightGray);
87 timeText.setPreferredSize(new Dimension(80, 20));
88 timeText.setToolTipText("Current time");
89
90 serverText = new JTextField("Server:");
91 serverText.setFont(JspmConstants.DEFAULT_FONT);
92 serverText.setEditable(false);
93 serverText.setBackground(Color.lightGray);
94 serverText.setPreferredSize(new Dimension(160, 20));
95 serverText.setToolTipText("Server");
96
97 busyText = new JTextField();
98 busyText.setEditable(false);
99 busyText.setBackground(Color.green);
100 busyText.setPreferredSize(new Dimension(30, 20));
101 busyText.setToolTipText("Busy");
102
103 add(statusText);
104 add(busyText);
105 add(dateText);
106 add(timeText);
107 add(serverText);
108 add(progress);
109 }
110
111 /**
112 * Sets the status text and displays it immediately.
113 *
114 * @param text - Text to display.
115 */
116 public void setStatusText(String t) {
117 statusText.setText(" "+t);
118
119 Calendar c = Calendar.getInstance();
120 dateText.setText(" "+c.get(Calendar.DATE)+"/"+(c.get(Calendar.MONTH)+1)+"/"+
121 c.get(Calendar.YEAR));
122 timeText.setText(" "+c.get(Calendar.HOUR)+":"+c.get(Calendar.MINUTE)+":"+
123 c.get(Calendar.SECOND));
124 }
125
126 /**
127 * This rolls back (amount negative) , or forward (amount positive)
128 *
129 * @param amount - the amount of time to roll backwards/forwards
130 */
131 public void roll(int amount)
132 {
133 Calendar c = Calendar.getInstance();
134 c.roll(Calendar.DATE, amount);
135 dateText.setText(" "+c.get(Calendar.DATE)+"/"+(c.get(Calendar.MONTH)+1)+"/"+
136 c.get(Calendar.YEAR));
137 }
138
139 /**
140 * Sets maximum for the progress bar.
141 *
142 * @param max - Maximum for the progress bar.
143 */
144 public void setProgressMax(int max) {
145 progress.setMaximum(max);
146 }
147
148 /**
149 * Returns maximum for the progress bar.
150 *
151 * @return max - Maximum for the progress bar.
152 */
153 public int getProgressMax() {
154 return(progress.getMaximum());
155 }
156
157 /**
158 * Sets maximum for the progress bar.
159 *
160 * @param val - Current value for the progress bar.
161 */
162 public void setProgress(int val) {
163 progress.setValue(val);
164 }
165
166 /**
167 * Sets busy field. The busy field is red whenever the JspmEvtGui is busy with
168 * database accesses, otherwise it's green.
169 *
170 * @param val - Current value for the progress bar.
171 */
172 public void setBusy(boolean busy) {
173 if(busy)
174 busyText.setBackground(Color.red);
175 else
176 busyText.setBackground(Color.green);
177 }
178
179 /**
180 * Sets the server field.
181 *
182 * @param server - Server name.
183 */
184 public void setServer( String server ) {
185 serverText.setText( server );
186 }
187 }
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216