8 |
|
import java.util.Set; |
9 |
|
import java.util.Collections; |
10 |
|
import java.util.Iterator; |
11 |
– |
import java.awt.BorderLayout; |
11 |
|
import javax.swing.BoxLayout; |
12 |
|
import javax.swing.JPanel; |
13 |
|
import javax.swing.JProgressBar; |
16 |
|
import javax.swing.JFrame; |
17 |
|
import javax.swing.Box; |
18 |
|
import java.awt.event.*; |
19 |
< |
import java.awt.Container; |
19 |
> |
import java.awt.*; |
20 |
|
import javax.swing.SwingUtilities; |
21 |
|
import javax.swing.ImageIcon; |
22 |
|
|
59 |
|
_extraData = true; |
60 |
|
} |
61 |
|
|
62 |
+ |
GridBagLayout gridbag = new GridBagLayout(); |
63 |
+ |
GridBagConstraints c = new GridBagConstraints(); |
64 |
+ |
c.fill = GridBagConstraints.HORIZONTAL; |
65 |
+ |
c.anchor = GridBagConstraints.NORTH; |
66 |
+ |
c.weighty = 1.0; |
67 |
+ |
_center.setLayout(gridbag); |
68 |
+ |
|
69 |
|
add(_center, "Center"); |
70 |
|
add(_north, "North"); |
71 |
|
|
133 |
|
|
134 |
|
JPanel date = new JPanel(); |
135 |
|
addVisibleDataComponent(date, new DateDataComponent("Host Time", "packet.attributes.date")); |
136 |
+ |
c.gridy = 0; |
137 |
+ |
gridbag.setConstraints(date, c); |
138 |
|
_center.add(date); |
139 |
|
|
140 |
< |
_center.add(new javax.swing.JLabel("--- CPU ---")); |
140 |
> |
// holder for labels |
141 |
> |
JLabel label; |
142 |
> |
|
143 |
> |
label = new javax.swing.JLabel("--- CPU ---", JLabel.CENTER); |
144 |
> |
c.gridy = 1; |
145 |
> |
gridbag.setConstraints(label, c); |
146 |
> |
_center.add(label); |
147 |
|
|
148 |
|
// add all the DataComponents that we know about |
149 |
|
JPanel cpu = new JPanel(); |
153 |
|
addVisibleDataComponent(cpu, new CPUDataComponent("CPU Kernel", "packet.cpu.kernel")); |
154 |
|
addVisibleDataComponent(cpu, new CPUDataComponent("CPU i/o wait", "packet.cpu.iowait")); |
155 |
|
addVisibleDataComponent(cpu, new CPUDataComponent("CPU swapping", "packet.cpu.swap")); |
156 |
+ |
c.gridy = 2; |
157 |
+ |
gridbag.setConstraints(cpu, c); |
158 |
|
_center.add(cpu); |
159 |
|
|
160 |
< |
_center.add(new javax.swing.JLabel("--- Load ---")); |
160 |
> |
label = new javax.swing.JLabel("--- Load ---", JLabel.CENTER); |
161 |
> |
c.gridy = 3; |
162 |
> |
gridbag.setConstraints(label, c); |
163 |
> |
_center.add(label); |
164 |
|
|
165 |
|
Box loadData = Box.createHorizontalBox(); |
147 |
– |
loadData.add(Box.createGlue()); |
166 |
|
addVisibleDataComponent(loadData, new ProcessesDataComponent("1 minute", "packet.load.load1")); |
167 |
|
addVisibleDataComponent(loadData, new ProcessesDataComponent("5 minutes", "packet.load.load5")); |
168 |
|
addVisibleDataComponent(loadData, new ProcessesDataComponent("15 minutes", "packet.load.load15")); |
169 |
< |
loadData.add(Box.createGlue()); |
169 |
> |
|
170 |
> |
c.gridy = 4; |
171 |
> |
gridbag.setConstraints(loadData, c); |
172 |
|
_center.add(loadData); |
173 |
|
|
174 |
< |
_center.add(new javax.swing.JLabel("--- Processes ---")); |
174 |
> |
label = new javax.swing.JLabel("--- Processes ---", JLabel.CENTER); |
175 |
> |
c.gridy = 5; |
176 |
> |
gridbag.setConstraints(label, c); |
177 |
> |
_center.add(label); |
178 |
|
|
179 |
|
Box processesData = Box.createHorizontalBox(); |
157 |
– |
processesData.add(Box.createGlue()); |
180 |
|
addVisibleDataComponent(processesData, new ProcessesDataComponent("Total", "packet.processes.total")); |
181 |
|
addVisibleDataComponent(processesData, new ProcessesDataComponent("Running", "packet.processes.cpu")); |
182 |
|
addVisibleDataComponent(processesData, new ProcessesDataComponent("Sleeping", "packet.processes.sleeping")); |
183 |
|
addVisibleDataComponent(processesData, new ProcessesDataComponent("Stopped", "packet.processes.stopped")); |
184 |
|
addVisibleDataComponent(processesData, new ProcessesDataComponent("Zombie", "packet.processes.zombie")); |
185 |
< |
processesData.add(Box.createGlue()); |
185 |
> |
c.gridy = 6; |
186 |
> |
gridbag.setConstraints(processesData, c); |
187 |
|
_center.add(processesData); |
188 |
|
|
189 |
< |
_center.add(new javax.swing.JLabel("--- Memory ---")); |
189 |
> |
label = new javax.swing.JLabel("--- Memory ---", JLabel.CENTER); |
190 |
> |
c.gridy = 7; |
191 |
> |
gridbag.setConstraints(label, c); |
192 |
> |
_center.add(label); |
193 |
|
|
194 |
|
// these next two are passed the non-visible datacomponents |
195 |
|
JPanel memory = new JPanel(); |
201 |
|
// just so we ignore the data, because the StorageDataComponent handles it |
202 |
|
addDataComponent(new StringDataComponent("packet.memory.total", "packet.memory.total")); |
203 |
|
addDataComponent(new StringDataComponent("packet.swap.total", "packet.swap.total")); |
204 |
< |
|
204 |
> |
c.gridy = 8; |
205 |
> |
gridbag.setConstraints(memory, c); |
206 |
|
_center.add(memory); |
207 |
|
|
208 |
< |
_center.add(new javax.swing.JLabel("--- Users ---")); |
208 |
> |
label = new javax.swing.JLabel("--- Users ---", JLabel.CENTER); |
209 |
> |
c.gridy = 9; |
210 |
> |
gridbag.setConstraints(label, c); |
211 |
> |
_center.add(label); |
212 |
> |
|
213 |
|
JPanel users = new JPanel(); |
214 |
+ |
users.setLayout(new BoxLayout(users, BoxLayout.Y_AXIS)); |
215 |
|
addVisibleDataComponent(users, new StringDataComponent("Number of users", "packet.users.count")); |
216 |
|
UsersDataComponent userList = new UsersDataComponent("User List", "packet.users.list"); |
217 |
|
addVisibleDataComponent(users, userList); |
218 |
+ |
c.gridy = 10; |
219 |
+ |
gridbag.setConstraints(users, c); |
220 |
|
_center.add(users); |
221 |
< |
|
222 |
< |
_center.add(new javax.swing.JLabel("--- Disks ---")); |
221 |
> |
|
222 |
> |
label = new javax.swing.JLabel("--- Disks ---", JLabel.CENTER); |
223 |
> |
c.gridy = 11; |
224 |
> |
gridbag.setConstraints(label, c); |
225 |
> |
_center.add(label); |
226 |
> |
c.gridy = 12; |
227 |
> |
gridbag.setConstraints(_disks, c); |
228 |
|
_center.add(_disks); |
229 |
|
|
230 |
< |
_center.add(new javax.swing.JLabel("--- System Services ---")); |
230 |
> |
label = new javax.swing.JLabel("--- System Services ---", JLabel.CENTER); |
231 |
> |
c.gridy = 13; |
232 |
> |
gridbag.setConstraints(label, c); |
233 |
> |
_center.add(label); |
234 |
> |
c.gridy = 14; |
235 |
> |
gridbag.setConstraints(_services, c); |
236 |
|
_center.add(_services); |
237 |
|
|
238 |
|
// everything else we get is "extra", but we may still want to display it |
239 |
|
if (_extraData) { |
240 |
< |
_center.add(new javax.swing.JLabel("--- Extra Data ---")); |
240 |
> |
label = new javax.swing.JLabel("--- Extra Data ---", JLabel.CENTER); |
241 |
> |
c.gridy = 15; |
242 |
> |
gridbag.setConstraints(label, c); |
243 |
> |
_center.add(label); |
244 |
> |
c.gridy = 16; |
245 |
> |
gridbag.setConstraints(_extra, c); |
246 |
|
_center.add(_extra); |
247 |
|
} |
199 |
– |
_center.add(Box.createGlue()); |
248 |
|
} |
249 |
|
|
250 |
|
//---PUBLIC METHODS--- |
455 |
|
* The centre panel, where all the data is displayed. |
456 |
|
*/ |
457 |
|
private final JPanel _center = new JPanel(); |
410 |
– |
{ |
411 |
– |
_center.setLayout(new BoxLayout(_center, BoxLayout.Y_AXIS)); |
412 |
– |
} |
458 |
|
|
459 |
|
/** |
460 |
|
* The countdown timer for heartbeats |