KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jacorb > poa > gui > pm > POAManagerFrame


1 package org.jacorb.poa.gui.pm;
2
3 /*
4  * JacORB - a free Java ORB
5  *
6  * Copyright (C) 1997-2004 Gerald Brose.
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Library General Public
10  * License as published by the Free Software Foundation; either
11  * version 2 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Library General Public License for more details.
17  *
18  * You should have received a copy of the GNU Library General Public
19  * License along with this library; if not, write to the Free
20  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21  */

22  
23 import org.jacorb.poa.gui.POAManagerMonitorController;
24
25 import java.awt.List JavaDoc;
26 import java.awt.Checkbox JavaDoc;
27 import java.awt.Choice JavaDoc;
28
29 /**
30  * Implements the org.jacorb.poa.gui.POAManagerView interface
31  *
32  * @author Reimo Tiedemann, FU Berlin
33  * @version 1.03, 06/11/99, RT
34  */

35 public class POAManagerFrame extends java.awt.Frame JavaDoc implements org.jacorb.poa.gui.beans.CloseButtonPanelController, RegisterPanelController, StatePanelController, org.jacorb.poa.gui.POAManagerMonitorView, java.awt.event.WindowListener JavaDoc {
36     private POAManagerMonitorController controller;
37     private String JavaDoc [] stateChoiceItems = { "Active", "Holding", "Discarding", "Inactive"};
38     private String JavaDoc currentStateItem = stateChoiceItems[1];
39     private List JavaDoc poaList = null;
40     private Choice JavaDoc stateChoice = null;
41     private Checkbox JavaDoc waitCheckbox = null;
42     private Checkbox JavaDoc etherializeCheckbox = null;
43     private java.awt.Panel JavaDoc ivjContentsPane = null;
44     private org.jacorb.poa.gui.beans.CloseButtonPanel ivjButtonPanel = null;
45     private POAManagerStatePanel ivjPOAManagerStatePanel = null;
46     private java.awt.BorderLayout JavaDoc ivjContentsPaneBorderLayout = null;
47     private org.jacorb.poa.gui.beans.ConsolePanel ivjConsolePanel = null;
48     private java.awt.BorderLayout JavaDoc ivjPOAManagerFrameBorderLayout = null;
49 /**
50  * Constructor
51  */

52 /* WARNING: THIS METHOD WILL BE REGENERATED. */
53 public POAManagerFrame() {
54     super();
55     initialize();
56 }
57 /**
58  * This method was created in VisualAge.
59  * @param _model org.jacorb.poa.POAManagerMonitorController
60  */

61 public POAManagerFrame(POAManagerMonitorController _controller) {
62     super();
63     controller = _controller;
64     initialize();
65 }
66 /**
67  * POAManagerFrame constructor comment.
68  * @param title java.lang.String
69  */

70 public POAManagerFrame(String JavaDoc title) {
71     super(title);
72 }
73 public void _actionCloseButtonPressed() {
74     if (controller != null) {
75         controller.actionCloseView();
76     }
77 }
78 public void _actionClosePOAMonitor(String JavaDoc name) {
79     if (controller != null) {
80         controller.actionClosePOAMonitor(name);
81     }
82 }
83 public void _actionDestroyPOA(String JavaDoc name) {
84     if (controller != null) {
85         controller.actionDestroyPOA(name);
86     }
87 }
88 public void _actionOpenPOAMonitor(String JavaDoc name) {
89     if (controller != null) {
90         controller.actionOpenPOAMonitor(name);
91     }
92 }
93 public void _addPOA(String JavaDoc name) {
94     _getPOAList().add(name);
95 }
96 public void _destroy() {
97     dispose();
98 }
99 private Checkbox JavaDoc _getEtherializeCheckbox() {
100     if (etherializeCheckbox == null) {
101         etherializeCheckbox = getPOAManagerStatePanel()._getStatePanel()._getEtherializeCheckbox();
102     }
103     return etherializeCheckbox;
104 }
105 private List JavaDoc _getPOAList() {
106     if (poaList == null) {
107         poaList = getPOAManagerStatePanel()._getRegisterPanel()._getPOAList();
108     }
109     return poaList;
110 }
111 private Choice JavaDoc _getStateChoice() {
112     if (stateChoice == null) {
113         stateChoice = getPOAManagerStatePanel()._getStatePanel()._getStateChoice();
114     }
115     return stateChoice;
116 }
117 private Checkbox JavaDoc _getWaitCheckbox() {
118     if (waitCheckbox == null) {
119         waitCheckbox = getPOAManagerStatePanel()._getStatePanel()._getWaitCheckbox();
120     }
121     return waitCheckbox;
122 }
123 public void _printMessage(String JavaDoc str) {
124     getConsolePanel()._printMessage(str);
125 }
126 public void _removePOA(String JavaDoc name) {
127     _getPOAList().remove(name);
128 }
129 public void _resetState() {
130     _getStateChoice().select(currentStateItem);
131 }
132 public void _setToActive() {
133     currentStateItem = stateChoiceItems[0];
134     _getStateChoice().select(currentStateItem);
135     _getWaitCheckbox().setState(false);
136     _getEtherializeCheckbox().setState(false);
137 }
138 public void _setToDiscarding(boolean wait) {
139     currentStateItem = stateChoiceItems[2];
140     _getStateChoice().select(currentStateItem);
141     _getWaitCheckbox().setState(wait);
142     _getEtherializeCheckbox().setState(false);
143 }
144 public void _setToHolding(boolean wait) {
145     currentStateItem = stateChoiceItems[1];
146     _getStateChoice().select(currentStateItem);
147     _getWaitCheckbox().setState(wait);
148     _getEtherializeCheckbox().setState(false);
149 }
150 public void _setToInactive(boolean wait, boolean etherialize) {
151     currentStateItem = stateChoiceItems[3];
152     _getStateChoice().select(currentStateItem);
153     _getWaitCheckbox().setState(wait);
154     _getEtherializeCheckbox().setState(etherialize);
155 }
156 public void _setVisible(boolean visible) {
157     setVisible(visible);
158 }
159 public void _stateItemChanged(String JavaDoc item, boolean wait, boolean etherialize) {
160     
161     if (item.equals(currentStateItem)) return;
162
163     if (controller != null) {
164         
165         if (item.equals(stateChoiceItems[0])) {
166             controller.actionSetToActive();
167         
168         } else if (item.equals(stateChoiceItems[1])) {
169             controller.actionSetToHolding(wait);
170
171         } else if (item.equals(stateChoiceItems[2])) {
172             controller.actionSetToDiscarding(wait);
173
174         } else if (item.equals(stateChoiceItems[3])) {
175             controller.actionSetToInactive(wait, etherialize);
176         
177         }
178     }
179 }
180 /**
181  * connEtoC1: (POAManagerFrame.window.windowClosing(java.awt.event.WindowEvent) --> POAManagerFrame._closeButtonPressed()V)
182  * @param arg1 java.awt.event.WindowEvent
183  */

184 /* WARNING: THIS METHOD WILL BE REGENERATED. */
185 private void connEtoC1(java.awt.event.WindowEvent JavaDoc arg1) {
186     try {
187         // user code begin {1}
188
// user code end
189
this.dispose();
190         // user code begin {2}
191
// user code end
192
} catch (java.lang.Throwable JavaDoc ivjExc) {
193         // user code begin {3}
194
// user code end
195
handleException(ivjExc);
196     }
197 }
198 /**
199  * Return the ButtonPanel property value.
200  * @return org.jacorb.poa.gui.beans.CloseButtonPanel
201  */

202 /* WARNING: THIS METHOD WILL BE REGENERATED. */
203 private org.jacorb.poa.gui.beans.CloseButtonPanel getButtonPanel() {
204     if (ivjButtonPanel == null) {
205         try {
206             ivjButtonPanel = new org.jacorb.poa.gui.beans.CloseButtonPanel();
207             ivjButtonPanel.setName("ButtonPanel");
208             ivjButtonPanel.setBackground(java.awt.SystemColor.control);
209             ivjButtonPanel.setSize(427, 34);
210             // user code begin {1}
211
// user code end
212
} catch (java.lang.Throwable JavaDoc ivjExc) {
213             // user code begin {2}
214
// user code end
215
handleException(ivjExc);
216         }
217     };
218     return ivjButtonPanel;
219 }
220 /**
221  * Return the Console property value.
222  * @return org.jacorb.poa.gui.beans.ConsolePanel
223  */

224 /* WARNING: THIS METHOD WILL BE REGENERATED. */
225 private org.jacorb.poa.gui.beans.ConsolePanel getConsolePanel() {
226     if (ivjConsolePanel == null) {
227         try {
228             ivjConsolePanel = new org.jacorb.poa.gui.beans.ConsolePanel();
229             ivjConsolePanel.setName("ConsolePanel");
230             ivjConsolePanel.setBackground(java.awt.SystemColor.control);
231             ivjConsolePanel.setSize(426, 240);
232             // user code begin {1}
233
// user code end
234
} catch (java.lang.Throwable JavaDoc ivjExc) {
235             // user code begin {2}
236
// user code end
237
handleException(ivjExc);
238         }
239     };
240     return ivjConsolePanel;
241 }
242 /**
243  * Return the ContentsPane property value.
244  * @return java.awt.Panel
245  */

246 /* WARNING: THIS METHOD WILL BE REGENERATED. */
247 private java.awt.Panel JavaDoc getContentsPane() {
248     if (ivjContentsPane == null) {
249         try {
250             ivjContentsPane = new java.awt.Panel JavaDoc();
251             ivjContentsPane.setName("ContentsPane");
252             ivjContentsPane.setLayout(getContentsPaneBorderLayout());
253             ivjContentsPane.setBackground(java.awt.SystemColor.control);
254             getContentsPane().add(getButtonPanel(), "South");
255             getContentsPane().add(getConsolePanel(), "Center");
256             getContentsPane().add(getPOAManagerStatePanel(), "North");
257             // user code begin {1}
258
// user code end
259
} catch (java.lang.Throwable JavaDoc ivjExc) {
260             // user code begin {2}
261
// user code end
262
handleException(ivjExc);
263         }
264     };
265     return ivjContentsPane;
266 }
267 /**
268  * Return the ContentsPaneBorderLayout property value.
269  * @return java.awt.BorderLayout
270  */

271 /* WARNING: THIS METHOD WILL BE REGENERATED. */
272 private java.awt.BorderLayout JavaDoc getContentsPaneBorderLayout() {
273     java.awt.BorderLayout JavaDoc ivjContentsPaneBorderLayout = null;
274     try {
275         /* Create part */
276         ivjContentsPaneBorderLayout = new java.awt.BorderLayout JavaDoc();
277         ivjContentsPaneBorderLayout.setVgap(0);
278         ivjContentsPaneBorderLayout.setHgap(0);
279     } catch (java.lang.Throwable JavaDoc ivjExc) {
280         handleException(ivjExc);
281     };
282     return ivjContentsPaneBorderLayout;
283 }
284 /**
285  * Return the POAManagerFrameBorderLayout property value.
286  * @return java.awt.BorderLayout
287  */

288 /* WARNING: THIS METHOD WILL BE REGENERATED. */
289 private java.awt.BorderLayout JavaDoc getPOAManagerFrameBorderLayout() {
290     java.awt.BorderLayout JavaDoc ivjPOAManagerFrameBorderLayout = null;
291     try {
292         /* Create part */
293         ivjPOAManagerFrameBorderLayout = new java.awt.BorderLayout JavaDoc();
294         ivjPOAManagerFrameBorderLayout.setVgap(0);
295         ivjPOAManagerFrameBorderLayout.setHgap(0);
296     } catch (java.lang.Throwable JavaDoc ivjExc) {
297         handleException(ivjExc);
298     };
299     return ivjPOAManagerFrameBorderLayout;
300 }
301 /**
302  * Return the POAManagerStatePanel property value.
303  * @return org.jacorb.poa.gui.pm.POAManagerStatePanel
304  */

305 /* WARNING: THIS METHOD WILL BE REGENERATED. */
306 private POAManagerStatePanel getPOAManagerStatePanel() {
307     if (ivjPOAManagerStatePanel == null) {
308         try {
309             ivjPOAManagerStatePanel = new org.jacorb.poa.gui.pm.POAManagerStatePanel();
310             ivjPOAManagerStatePanel.setName("POAManagerStatePanel");
311             ivjPOAManagerStatePanel.setBackground(java.awt.SystemColor.control);
312             ivjPOAManagerStatePanel.setSize(310, 100);
313             // user code begin {1}
314
// user code end
315
} catch (java.lang.Throwable JavaDoc ivjExc) {
316             // user code begin {2}
317
// user code end
318
handleException(ivjExc);
319         }
320     };
321     return ivjPOAManagerStatePanel;
322 }
323 /**
324  * Called whenever the part throws an exception.
325  * @param exception java.lang.Throwable
326  */

327 private void handleException(Throwable JavaDoc exception) {
328
329     /* Uncomment the following lines to print uncaught exceptions to stdout */
330     // System.out.println("--------- UNCAUGHT EXCEPTION ---------");
331
// exception.printStackTrace(System.out);
332
}
333 /**
334  * Initializes connections
335  */

336 /* WARNING: THIS METHOD WILL BE REGENERATED. */
337 private void initConnections() {
338     // user code begin {1}
339
// user code end
340
this.addWindowListener(this);
341 }
342 /**
343  * Initialize the class.
344  */

345 /* WARNING: THIS METHOD WILL BE REGENERATED. */
346 private void initialize() {
347     // user code begin {1}
348
// user code end
349
setName("POAManagerFrame");
350     setLayout(getPOAManagerFrameBorderLayout());
351     setBackground(java.awt.SystemColor.control);
352     setSize(318, 210);
353     setTitle("POAManager Monitor");
354     add(getContentsPane(), "Center");
355     initConnections();
356     // user code begin {2}
357
for (int i=0; i<stateChoiceItems.length; i++) {
358         _getStateChoice().addItem(stateChoiceItems[i]);
359     }
360     _getStateChoice().select(stateChoiceItems[1]);
361     getPOAManagerStatePanel()._getStatePanel()._init(this);
362     getPOAManagerStatePanel()._getRegisterPanel()._init(this);
363     getButtonPanel()._init(this, "Close");
364     // user code end
365
}
366 /**
367  * main entrypoint - starts the part when it is run as an application
368  * @param args java.lang.String[]
369  */

370 public static void main(java.lang.String JavaDoc[] args) {
371     try {
372         POAManagerFrame aPOAManagerFrame;
373         aPOAManagerFrame = new POAManagerFrame();
374         try {
375             Class JavaDoc aCloserClass = Class.forName("com.ibm.uvm.abt.edit.WindowCloser");
376             Class JavaDoc parmTypes[] = { java.awt.Window JavaDoc.class };
377             Object JavaDoc parms[] = { aPOAManagerFrame };
378             java.lang.reflect.Constructor JavaDoc aCtor = aCloserClass.getConstructor(parmTypes);
379             aCtor.newInstance(parms);
380         } catch (java.lang.Throwable JavaDoc exc) {};
381         aPOAManagerFrame.setVisible(true);
382     } catch (Throwable JavaDoc exception) {
383         System.err.println("Exception occurred in main() of java.awt.Frame");
384         exception.printStackTrace(System.out);
385     }
386 }
387 /**
388  * Method to handle events for the WindowListener interface.
389  * @param e java.awt.event.WindowEvent
390  */

391 /* WARNING: THIS METHOD WILL BE REGENERATED. */
392 public void windowActivated(java.awt.event.WindowEvent JavaDoc e) {
393     // user code begin {1}
394
// user code end
395
// user code begin {2}
396
// user code end
397
}
398 /**
399  * Method to handle events for the WindowListener interface.
400  * @param e java.awt.event.WindowEvent
401  */

402 /* WARNING: THIS METHOD WILL BE REGENERATED. */
403 public void windowClosed(java.awt.event.WindowEvent JavaDoc e) {
404     // user code begin {1}
405
// user code end
406
// user code begin {2}
407
// user code end
408
}
409 /**
410  * Method to handle events for the WindowListener interface.
411  * @param e java.awt.event.WindowEvent
412  */

413 /* WARNING: THIS METHOD WILL BE REGENERATED. */
414 public void windowClosing(java.awt.event.WindowEvent JavaDoc e) {
415     // user code begin {1}
416
// user code end
417
if ((e.getSource() == this) ) {
418         connEtoC1(e);
419     }
420     // user code begin {2}
421
// user code end
422
}
423 /**
424  * Method to handle events for the WindowListener interface.
425  * @param e java.awt.event.WindowEvent
426  */

427 /* WARNING: THIS METHOD WILL BE REGENERATED. */
428 public void windowDeactivated(java.awt.event.WindowEvent JavaDoc e) {
429     // user code begin {1}
430
// user code end
431
// user code begin {2}
432
// user code end
433
}
434 /**
435  * Method to handle events for the WindowListener interface.
436  * @param e java.awt.event.WindowEvent
437  */

438 /* WARNING: THIS METHOD WILL BE REGENERATED. */
439 public void windowDeiconified(java.awt.event.WindowEvent JavaDoc e) {
440     // user code begin {1}
441
// user code end
442
// user code begin {2}
443
// user code end
444
}
445 /**
446  * Method to handle events for the WindowListener interface.
447  * @param e java.awt.event.WindowEvent
448  */

449 /* WARNING: THIS METHOD WILL BE REGENERATED. */
450 public void windowIconified(java.awt.event.WindowEvent JavaDoc e) {
451     // user code begin {1}
452
// user code end
453
// user code begin {2}
454
// user code end
455
}
456 /**
457  * Method to handle events for the WindowListener interface.
458  * @param e java.awt.event.WindowEvent
459  */

460 /* WARNING: THIS METHOD WILL BE REGENERATED. */
461 public void windowOpened(java.awt.event.WindowEvent JavaDoc e) {
462     // user code begin {1}
463
// user code end
464
// user code begin {2}
465
// user code end
466
}
467
468 }
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
Popular Tags