KickJava   Java API By Example, From Geeks To Geeks.

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


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 /**
24  * @author Reimo Tiedemann, FU Berlin
25  * @version 1.02, 05/31/99, RT
26  */

27 public class RegisterPanel extends java.awt.Panel JavaDoc implements java.awt.event.ActionListener JavaDoc, java.awt.event.MouseListener JavaDoc {
28     private RegisterPanelController controller;
29     private java.awt.List JavaDoc ivjPOAList = null;
30     private java.awt.Label JavaDoc ivjRegisterLabel = null;
31     private java.awt.BorderLayout JavaDoc ivjRegisterPanelBorderLayout = null;
32     private java.awt.MenuItem JavaDoc ivjCloseMenuItem = null;
33     private java.awt.MenuItem JavaDoc ivjDestroyMenuItem = null;
34     private java.awt.MenuItem JavaDoc ivjOpenMenuItem = null;
35     private org.jacorb.poa.gui.beans.PopupMenu ivjPopupMenu = null;
36 /**
37  * Constructor
38  */

39 /* WARNING: THIS METHOD WILL BE REGENERATED. */
40 public RegisterPanel() {
41     super();
42     initialize();
43 }
44 /**
45  * RegisterPanel constructor comment.
46  * @param layout java.awt.LayoutManager
47  */

48 public RegisterPanel(java.awt.LayoutManager JavaDoc layout) {
49     super(layout);
50 }
51 /**
52  * Comment
53  */

54 private void _actionClosePOAMonitor(String JavaDoc item) {
55     if (controller != null) {
56         controller._actionClosePOAMonitor(item);
57     }
58 }
59 /**
60  * Comment
61  */

62 private void _actionDestroyPOA(String JavaDoc item) {
63     if (controller != null) {
64         controller._actionDestroyPOA(item);
65     }
66 }
67 /**
68  * Comment
69  */

70 private void _actionMousePressed(java.awt.event.MouseEvent JavaDoc e) {
71     if (getPOAList().getSelectedItem() != null) {
72         int mods = e.getModifiers();
73         if ((mods & java.awt.event.MouseEvent.BUTTON3_MASK) != 0) {
74             /* Right Mouse Button pressed */
75             getPopupMenu()._show(this, getBounds().width, e.getY()+10);
76         } else if ((mods & java.awt.event.MouseEvent.BUTTON2_MASK) != 0) {
77             /* Middle Mouse Button pressed */
78         } else {
79             /* Left Mouse Button pressed */
80             if (e.getClickCount() > 1) {
81                 /* doubel click */
82                 _actionOpenPOAMonitor(getPOAList().getSelectedItem());
83             }
84         }
85     }
86 }
87 /**
88  * Comment
89  */

90 private void _actionOpenPOAMonitor(String JavaDoc item) {
91     if (controller != null) {
92         controller._actionOpenPOAMonitor(item);
93     }
94 }
95 java.awt.List JavaDoc _getPOAList() {
96     return getPOAList();
97 }
98 void _init(RegisterPanelController _controller) {
99     controller = _controller;
100 }
101 /**
102  * Method to handle events for the ActionListener interface.
103  * @param e java.awt.event.ActionEvent
104  */

105 /* WARNING: THIS METHOD WILL BE REGENERATED. */
106 public void actionPerformed(java.awt.event.ActionEvent JavaDoc e) {
107     // user code begin {1}
108
// user code end
109
if ((e.getSource() == getOpenMenuItem()) ) {
110         connEtoC2(e);
111     }
112     if ((e.getSource() == getCloseMenuItem()) ) {
113         connEtoC3(e);
114     }
115     if ((e.getSource() == getDestroyMenuItem()) ) {
116         connEtoC4(e);
117     }
118     // user code begin {2}
119
// user code end
120
}
121 /**
122  * connEtoC1: (POAList.mouse.mousePressed(java.awt.event.MouseEvent) --> RegisterPanel._actionMousePressed(Ljava.awt.event.MouseEvent;)V)
123  * @param arg1 java.awt.event.MouseEvent
124  */

125 /* WARNING: THIS METHOD WILL BE REGENERATED. */
126 private void connEtoC1(java.awt.event.MouseEvent JavaDoc arg1) {
127     try {
128         // user code begin {1}
129
// user code end
130
this._actionMousePressed(arg1);
131         // user code begin {2}
132
// user code end
133
} catch (java.lang.Throwable JavaDoc ivjExc) {
134         // user code begin {3}
135
// user code end
136
handleException(ivjExc);
137     }
138 }
139 /**
140  * connEtoC2: (OpenMenuItem.action.actionPerformed(java.awt.event.ActionEvent) --> RegisterPanel._actionOpenPOAMonitor(Ljava.lang.String;)V)
141  * @param arg1 java.awt.event.ActionEvent
142  */

143 /* WARNING: THIS METHOD WILL BE REGENERATED. */
144 private void connEtoC2(java.awt.event.ActionEvent JavaDoc arg1) {
145     try {
146         // user code begin {1}
147
// user code end
148
this._actionOpenPOAMonitor(getPOAList().getSelectedItem());
149         // user code begin {2}
150
// user code end
151
} catch (java.lang.Throwable JavaDoc ivjExc) {
152         // user code begin {3}
153
// user code end
154
handleException(ivjExc);
155     }
156 }
157 /**
158  * connEtoC3: (CloseMenuItem.action.actionPerformed(java.awt.event.ActionEvent) --> RegisterPanel._actionClosePOAMonitor(Ljava.lang.String;)V)
159  * @param arg1 java.awt.event.ActionEvent
160  */

161 /* WARNING: THIS METHOD WILL BE REGENERATED. */
162 private void connEtoC3(java.awt.event.ActionEvent JavaDoc arg1) {
163     try {
164         // user code begin {1}
165
// user code end
166
this._actionClosePOAMonitor(getPOAList().getSelectedItem());
167         // user code begin {2}
168
// user code end
169
} catch (java.lang.Throwable JavaDoc ivjExc) {
170         // user code begin {3}
171
// user code end
172
handleException(ivjExc);
173     }
174 }
175 /**
176  * connEtoC4: (DestroyMenuItem.action.actionPerformed(java.awt.event.ActionEvent) --> RegisterPanel._actionDestroyPOA(Ljava.lang.String;)V)
177  * @param arg1 java.awt.event.ActionEvent
178  */

179 /* WARNING: THIS METHOD WILL BE REGENERATED. */
180 private void connEtoC4(java.awt.event.ActionEvent JavaDoc arg1) {
181     try {
182         // user code begin {1}
183
// user code end
184
this._actionDestroyPOA(getPOAList().getSelectedItem());
185         // user code begin {2}
186
// user code end
187
} catch (java.lang.Throwable JavaDoc ivjExc) {
188         // user code begin {3}
189
// user code end
190
handleException(ivjExc);
191     }
192 }
193 /**
194  * Return the CloseMenuItem property value.
195  * @return java.awt.MenuItem
196  */

197 /* WARNING: THIS METHOD WILL BE REGENERATED. */
198 private java.awt.MenuItem JavaDoc getCloseMenuItem() {
199     if (ivjCloseMenuItem == null) {
200         try {
201             ivjCloseMenuItem = new java.awt.MenuItem JavaDoc();
202             ivjCloseMenuItem.setLabel("Close Monitor");
203             // user code begin {1}
204
// user code end
205
} catch (java.lang.Throwable JavaDoc ivjExc) {
206             // user code begin {2}
207
// user code end
208
handleException(ivjExc);
209         }
210     };
211     return ivjCloseMenuItem;
212 }
213 /**
214  * Return the DestroyMenuItem property value.
215  * @return java.awt.MenuItem
216  */

217 /* WARNING: THIS METHOD WILL BE REGENERATED. */
218 private java.awt.MenuItem JavaDoc getDestroyMenuItem() {
219     if (ivjDestroyMenuItem == null) {
220         try {
221             ivjDestroyMenuItem = new java.awt.MenuItem JavaDoc();
222             ivjDestroyMenuItem.setLabel("Destroy POA");
223             // user code begin {1}
224
// user code end
225
} catch (java.lang.Throwable JavaDoc ivjExc) {
226             // user code begin {2}
227
// user code end
228
handleException(ivjExc);
229         }
230     };
231     return ivjDestroyMenuItem;
232 }
233 /**
234  * Return the OpenMenuItem property value.
235  * @return java.awt.MenuItem
236  */

237 /* WARNING: THIS METHOD WILL BE REGENERATED. */
238 private java.awt.MenuItem JavaDoc getOpenMenuItem() {
239     if (ivjOpenMenuItem == null) {
240         try {
241             ivjOpenMenuItem = new java.awt.MenuItem JavaDoc();
242             ivjOpenMenuItem.setLabel("Open Monitor");
243             // user code begin {1}
244
// user code end
245
} catch (java.lang.Throwable JavaDoc ivjExc) {
246             // user code begin {2}
247
// user code end
248
handleException(ivjExc);
249         }
250     };
251     return ivjOpenMenuItem;
252 }
253 /**
254  * Return the POAList property value.
255  * @return java.awt.List
256  */

257 /* WARNING: THIS METHOD WILL BE REGENERATED. */
258 private java.awt.List JavaDoc getPOAList() {
259     if (ivjPOAList == null) {
260         try {
261             ivjPOAList = new java.awt.List JavaDoc();
262             ivjPOAList.setName("POAList");
263             ivjPOAList.setFont(new java.awt.Font JavaDoc("dialog", 0, 10));
264             ivjPOAList.setBackground(java.awt.SystemColor.activeCaptionText);
265             // user code begin {1}
266
// user code end
267
} catch (java.lang.Throwable JavaDoc ivjExc) {
268             // user code begin {2}
269
// user code end
270
handleException(ivjExc);
271         }
272     };
273     return ivjPOAList;
274 }
275 /**
276  * Return the PopupMenu property value.
277  * @return org.jacorb.poa.gui.beans.PopupMenu
278  */

279 /* WARNING: THIS METHOD WILL BE REGENERATED. */
280 private org.jacorb.poa.gui.beans.PopupMenu getPopupMenu() {
281     if (ivjPopupMenu == null) {
282         try {
283             ivjPopupMenu = new org.jacorb.poa.gui.beans.PopupMenu();
284             ivjPopupMenu.setLabel("POA Actions");
285             ivjPopupMenu.add(getOpenMenuItem());
286             ivjPopupMenu.add(getCloseMenuItem());
287             ivjPopupMenu.add(getDestroyMenuItem());
288             // user code begin {1}
289
// user code end
290
} catch (java.lang.Throwable JavaDoc ivjExc) {
291             // user code begin {2}
292
// user code end
293
handleException(ivjExc);
294         }
295     };
296     return ivjPopupMenu;
297 }
298 /**
299  * Return the Label1 property value.
300  * @return java.awt.Label
301  */

302 /* WARNING: THIS METHOD WILL BE REGENERATED. */
303 private java.awt.Label JavaDoc getRegisterLabel() {
304     if (ivjRegisterLabel == null) {
305         try {
306             ivjRegisterLabel = new java.awt.Label JavaDoc();
307             ivjRegisterLabel.setName("RegisterLabel");
308             ivjRegisterLabel.setText("Registered POA's:");
309             ivjRegisterLabel.setBackground(java.awt.SystemColor.control);
310             ivjRegisterLabel.setForeground(java.awt.Color.black);
311             // user code begin {1}
312
// user code end
313
} catch (java.lang.Throwable JavaDoc ivjExc) {
314             // user code begin {2}
315
// user code end
316
handleException(ivjExc);
317         }
318     };
319     return ivjRegisterLabel;
320 }
321 /**
322  * Return the RegisterPanelBorderLayout property value.
323  * @return java.awt.BorderLayout
324  */

325 /* WARNING: THIS METHOD WILL BE REGENERATED. */
326 private java.awt.BorderLayout JavaDoc getRegisterPanelBorderLayout() {
327     java.awt.BorderLayout JavaDoc ivjRegisterPanelBorderLayout = null;
328     try {
329         /* Create part */
330         ivjRegisterPanelBorderLayout = new java.awt.BorderLayout JavaDoc();
331         ivjRegisterPanelBorderLayout.setVgap(0);
332         ivjRegisterPanelBorderLayout.setHgap(0);
333     } catch (java.lang.Throwable JavaDoc ivjExc) {
334         handleException(ivjExc);
335     };
336     return ivjRegisterPanelBorderLayout;
337 }
338 /**
339  * Called whenever the part throws an exception.
340  * @param exception java.lang.Throwable
341  */

342 private void handleException(Throwable JavaDoc exception) {
343
344     /* Uncomment the following lines to print uncaught exceptions to stdout */
345     // System.out.println("--------- UNCAUGHT EXCEPTION ---------");
346
// exception.printStackTrace(System.out);
347
}
348 /**
349  * Initializes connections
350  */

351 /* WARNING: THIS METHOD WILL BE REGENERATED. */
352 private void initConnections() {
353     // user code begin {1}
354
// user code end
355
getPOAList().addMouseListener(this);
356     getOpenMenuItem().addActionListener(this);
357     getCloseMenuItem().addActionListener(this);
358     getDestroyMenuItem().addActionListener(this);
359 }
360 /**
361  * Initialize the class.
362  */

363 /* WARNING: THIS METHOD WILL BE REGENERATED. */
364 private void initialize() {
365     // user code begin {1}
366
// user code end
367
setName("RegisterPanel");
368     setLayout(getRegisterPanelBorderLayout());
369     setBackground(java.awt.SystemColor.control);
370     setSize(150, 90);
371     add(getRegisterLabel(), "North");
372     add(getPOAList(), "Center");
373     initConnections();
374     // user code begin {2}
375
// user code end
376
}
377 /**
378  * main entrypoint - starts the part when it is run as an application
379  * @param args java.lang.String[]
380  */

381 public static void main(java.lang.String JavaDoc[] args) {
382     try {
383         java.awt.Frame JavaDoc frame;
384         try {
385             Class JavaDoc aFrameClass = Class.forName("com.ibm.uvm.abt.edit.TestFrame");
386             frame = (java.awt.Frame JavaDoc)aFrameClass.newInstance();
387         } catch (java.lang.Throwable JavaDoc ivjExc) {
388             frame = new java.awt.Frame JavaDoc();
389         }
390         RegisterPanel aRegisterPanel;
391         aRegisterPanel = new RegisterPanel();
392         frame.add("Center", aRegisterPanel);
393         frame.setSize(aRegisterPanel.getSize());
394         frame.setVisible(true);
395     } catch (Throwable JavaDoc exception) {
396         System.err.println("Exception occurred in main() of java.awt.Panel");
397         exception.printStackTrace(System.out);
398     }
399 }
400 /**
401  * Method to handle events for the MouseListener interface.
402  * @param e java.awt.event.MouseEvent
403  */

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

415 /* WARNING: THIS METHOD WILL BE REGENERATED. */
416 public void mouseEntered(java.awt.event.MouseEvent JavaDoc e) {
417     // user code begin {1}
418
// user code end
419
// user code begin {2}
420
// user code end
421
}
422 /**
423  * Method to handle events for the MouseListener interface.
424  * @param e java.awt.event.MouseEvent
425  */

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

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

448 /* WARNING: THIS METHOD WILL BE REGENERATED. */
449 public void mouseReleased(java.awt.event.MouseEvent JavaDoc e) {
450     // user code begin {1}
451
// user code end
452
if ((e.getSource() == getPOAList()) ) {
453         connEtoC1(e);
454     }
455     // user code begin {2}
456
// user code end
457
}
458
459 }
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
Popular Tags