KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jacorb > poa > gui > poa > ObjectListItem


1 package org.jacorb.poa.gui.poa;
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.beans.DoubleListDialog;
24
25 /**
26  * @author Reimo Tiedemann, FU Berlin
27  * @version 1.0, 05/10/99, RT
28  */

29 public class ObjectListItem
30     extends java.awt.Panel JavaDoc
31     implements org.jacorb.poa.gui.beans.DoubleListItem, java.awt.event.ActionListener JavaDoc, java.awt.event.MouseListener JavaDoc
32 {
33     public DoubleListDialog container;
34     private ObjectListItemController controller;
35     private String JavaDoc oidStr;
36     private java.awt.MenuItem JavaDoc ivjDeactivateMenuItem = null;
37     private java.awt.MenuItem JavaDoc ivjInspectionMenuItem = null;
38     private org.jacorb.poa.gui.beans.PopupMenu ivjPopupMenu = null;
39     private java.awt.Panel JavaDoc ivjInnerPanel = null;
40     private java.awt.Label JavaDoc ivjObjectLabel = null;
41     private java.awt.Label JavaDoc ivjServantLabel = null;
42     /**
43      * Comment
44      */

45     private void _actionDeactivateObject() {
46     if (controller != null) {
47             controller._actionDeactivateObject(oidStr);
48     }
49     }
50     /**
51      * Comment
52      */

53     private void _actionInspectServantClass() {
54     if (controller != null) {
55             controller._inspectServantClass(oidStr);
56     }
57     }
58     /**
59      * Comment
60      */

61     private void _actionMousePressed(java.awt.event.MouseEvent JavaDoc e) {
62     if (container != null) {
63             container._setSelectedItem(this);
64     }
65     }
66     /**
67      * Comment
68      */

69     private void _actionMouseReleased(java.awt.event.MouseEvent JavaDoc e) {
70     int mods = e.getModifiers();
71     if ((mods & java.awt.event.MouseEvent.BUTTON3_MASK) != 0) {
72             /* Right Mouse Button pressed */
73             getPopupMenu()._show(e);
74     } else if ((mods & java.awt.event.MouseEvent.BUTTON2_MASK) != 0) {
75             /* Middle Mouse Button pressed */
76     } else {
77             /* Left Mouse Button pressed */
78             if (e.getClickCount() > 1) {
79                 /* doubel click */
80             }
81     }
82     }
83     /**
84      * Method to handle events for the ActionListener interface.
85      * @param e java.awt.event.ActionEvent
86      */

87     /* WARNING: THIS METHOD WILL BE REGENERATED. */
88     public void actionPerformed(java.awt.event.ActionEvent JavaDoc e) {
89     // user code begin {1}
90
// user code end
91
if ((e.getSource() == getDeactivateMenuItem()) ) {
92             connEtoC4(e);
93     }
94     if ((e.getSource() == getInspectionMenuItem()) ) {
95             connEtoC5(e);
96     }
97     // user code begin {2}
98
// user code end
99
}
100     /**
101      * connEtoC1: (Label2.mouse.mousePressed(java.awt.event.MouseEvent) --> ObjectListItem._actionMousePressed(Ljava.awt.event.MouseEvent;)V)
102      * @param arg1 java.awt.event.MouseEvent
103      */

104     /* WARNING: THIS METHOD WILL BE REGENERATED. */
105     private void connEtoC1(java.awt.event.MouseEvent JavaDoc arg1) {
106     try {
107             // user code begin {1}
108
// user code end
109
this._actionMousePressed(arg1);
110             // user code begin {2}
111
// user code end
112
} catch (java.lang.Throwable JavaDoc ivjExc) {
113             // user code begin {3}
114
// user code end
115
handleException(ivjExc);
116     }
117     }
118     /**
119      * connEtoC2: (Label1.mouse.mousePressed(java.awt.event.MouseEvent) --> ObjectListItem._actionMousePressed(Ljava.awt.event.MouseEvent;)V)
120      * @param arg1 java.awt.event.MouseEvent
121      */

122     /* WARNING: THIS METHOD WILL BE REGENERATED. */
123     private void connEtoC2(java.awt.event.MouseEvent JavaDoc arg1) {
124     try {
125             // user code begin {1}
126
// user code end
127
this._actionMousePressed(arg1);
128             // user code begin {2}
129
// user code end
130
} catch (java.lang.Throwable JavaDoc ivjExc) {
131             // user code begin {3}
132
// user code end
133
handleException(ivjExc);
134     }
135     }
136     /**
137      * connEtoC3: (Panel1.mouse.mousePressed(java.awt.event.MouseEvent) --> ObjectListItem._actionMousePressed(Ljava.awt.event.MouseEvent;)V)
138      * @param arg1 java.awt.event.MouseEvent
139      */

140     /* WARNING: THIS METHOD WILL BE REGENERATED. */
141     private void connEtoC3(java.awt.event.MouseEvent JavaDoc arg1) {
142     try {
143             // user code begin {1}
144
// user code end
145
this._actionMousePressed(arg1);
146             // user code begin {2}
147
// user code end
148
} catch (java.lang.Throwable JavaDoc ivjExc) {
149             // user code begin {3}
150
// user code end
151
handleException(ivjExc);
152     }
153     }
154     /**
155      * connEtoC4: (DeactivateMenuItem.action.actionPerformed(java.awt.event.ActionEvent) --> ObjectListItem._actionDeactivateObject()V)
156      * @param arg1 java.awt.event.ActionEvent
157      */

158     /* WARNING: THIS METHOD WILL BE REGENERATED. */
159     private void connEtoC4(java.awt.event.ActionEvent JavaDoc arg1) {
160     try {
161             // user code begin {1}
162
// user code end
163
this._actionDeactivateObject();
164             // user code begin {2}
165
// user code end
166
} catch (java.lang.Throwable JavaDoc ivjExc) {
167             // user code begin {3}
168
// user code end
169
handleException(ivjExc);
170     }
171     }
172     /**
173      * connEtoC5: (InspectionMenuItem.action.actionPerformed(java.awt.event.ActionEvent) --> ObjectListItem._actionInspectServantClass()V)
174      * @param arg1 java.awt.event.ActionEvent
175      */

176     /* WARNING: THIS METHOD WILL BE REGENERATED. */
177     private void connEtoC5(java.awt.event.ActionEvent JavaDoc arg1) {
178     try {
179             // user code begin {1}
180
// user code end
181
this._actionInspectServantClass();
182             // user code begin {2}
183
// user code end
184
} catch (java.lang.Throwable JavaDoc ivjExc) {
185             // user code begin {3}
186
// user code end
187
handleException(ivjExc);
188     }
189     }
190     /**
191      * connEtoC6: (ObjectLabel.mouse.mouseReleased(java.awt.event.MouseEvent) --> ObjectListItem._actionMouseReleased(Ljava.awt.event.MouseEvent;)V)
192      * @param arg1 java.awt.event.MouseEvent
193      */

194     /* WARNING: THIS METHOD WILL BE REGENERATED. */
195     private void connEtoC6(java.awt.event.MouseEvent JavaDoc arg1) {
196     try {
197             // user code begin {1}
198
// user code end
199
this._actionMouseReleased(arg1);
200             // user code begin {2}
201
// user code end
202
} catch (java.lang.Throwable JavaDoc ivjExc) {
203             // user code begin {3}
204
// user code end
205
handleException(ivjExc);
206     }
207     }
208     /**
209      * connEtoC7: (InnerPanel.mouse.mouseReleased(java.awt.event.MouseEvent) --> ObjectListItem._actionMouseReleased(Ljava.awt.event.MouseEvent;)V)
210      * @param arg1 java.awt.event.MouseEvent
211      */

212     /* WARNING: THIS METHOD WILL BE REGENERATED. */
213     private void connEtoC7(java.awt.event.MouseEvent JavaDoc arg1) {
214     try {
215             // user code begin {1}
216
// user code end
217
this._actionMouseReleased(arg1);
218             // user code begin {2}
219
// user code end
220
} catch (java.lang.Throwable JavaDoc ivjExc) {
221             // user code begin {3}
222
// user code end
223
handleException(ivjExc);
224     }
225     }
226     /**
227      * connEtoC8: (ServantLabel.mouse.mouseReleased(java.awt.event.MouseEvent) --> ObjectListItem._actionMouseReleased(Ljava.awt.event.MouseEvent;)V)
228      * @param arg1 java.awt.event.MouseEvent
229      */

230     /* WARNING: THIS METHOD WILL BE REGENERATED. */
231     private void connEtoC8(java.awt.event.MouseEvent JavaDoc arg1) {
232     try {
233             // user code begin {1}
234
// user code end
235
this._actionMouseReleased(arg1);
236             // user code begin {2}
237
// user code end
238
} catch (java.lang.Throwable JavaDoc ivjExc) {
239             // user code begin {3}
240
// user code end
241
handleException(ivjExc);
242     }
243     }
244     public void _correctWidth(int diff_width) {
245         /*
246                 if (curr_width + diff_width < init_width) {
247         curr_width = init_width;
248         curr_width2 = init_width2;
249                 } else {
250         curr_width = curr_width + diff_width;
251         curr_width2 = curr_width2 + diff_width;
252                 }
253                 setSize(curr_width, 15);
254                 getInnerPanel().setSize(curr_width, 13);
255                 getServantLabel().setSize(curr_width2, 13);
256         */

257     }
258     /**
259      * Return the DeactivateMenuItem property value.
260      * @return java.awt.MenuItem
261      */

262     /* WARNING: THIS METHOD WILL BE REGENERATED. */
263     private java.awt.MenuItem JavaDoc getDeactivateMenuItem() {
264     if (ivjDeactivateMenuItem == null) {
265             try {
266                 ivjDeactivateMenuItem = new java.awt.MenuItem JavaDoc();
267                 ivjDeactivateMenuItem.setLabel("Deactivate Object");
268                 // user code begin {1}
269
// user code end
270
} catch (java.lang.Throwable JavaDoc ivjExc) {
271                 // user code begin {2}
272
// user code end
273
handleException(ivjExc);
274             }
275     };
276     return ivjDeactivateMenuItem;
277     }
278     java.awt.Label JavaDoc _getFirstLabel() {
279     return getObjectLabel();
280     }
281     /**
282      * Return the Panel1 property value.
283      * @return java.awt.Panel
284      */

285     /* WARNING: THIS METHOD WILL BE REGENERATED. */
286     private java.awt.Panel JavaDoc getInnerPanel() {
287     if (ivjInnerPanel == null) {
288             try {
289                 ivjInnerPanel = new java.awt.Panel JavaDoc();
290                 ivjInnerPanel.setName("InnerPanel");
291                 ivjInnerPanel.setLayout(null);
292                 ivjInnerPanel.setBackground(java.awt.Color.lightGray);
293                 ivjInnerPanel.setBounds(0, 1, 1200, 13);
294                 getInnerPanel().add(getObjectLabel(), getObjectLabel().getName());
295                 getInnerPanel().add(getServantLabel(), getServantLabel().getName());
296                 // user code begin {1}
297
// user code end
298
} catch (java.lang.Throwable JavaDoc ivjExc) {
299                 // user code begin {2}
300
// user code end
301
handleException(ivjExc);
302             }
303     };
304     return ivjInnerPanel;
305     }
306     /**
307      * Return the InspectionMenuItem property value.
308      * @return java.awt.MenuItem
309      */

310     /* WARNING: THIS METHOD WILL BE REGENERATED. */
311     private java.awt.MenuItem JavaDoc getInspectionMenuItem() {
312     if (ivjInspectionMenuItem == null) {
313             try {
314                 ivjInspectionMenuItem = new java.awt.MenuItem JavaDoc();
315                 ivjInspectionMenuItem.setEnabled(true);
316                 ivjInspectionMenuItem.setLabel("Inspect Servant Class");
317                 // user code begin {1}
318
// user code end
319
} catch (java.lang.Throwable JavaDoc ivjExc) {
320                 // user code begin {2}
321
// user code end
322
handleException(ivjExc);
323             }
324     };
325     return ivjInspectionMenuItem;
326     }
327     /**
328      * Return the Label1 property value.
329      * @return java.awt.Label
330      */

331     /* WARNING: THIS METHOD WILL BE REGENERATED. */
332     private java.awt.Label JavaDoc getObjectLabel() {
333     if (ivjObjectLabel == null) {
334             try {
335                 ivjObjectLabel = new java.awt.Label JavaDoc();
336                 ivjObjectLabel.setName("ObjectLabel");
337                 ivjObjectLabel.setFont(new java.awt.Font JavaDoc("dialog", 0, 10));
338                 ivjObjectLabel.setText("Label1");
339                 ivjObjectLabel.setBounds(10, 0, 180, 13);
340                 // user code begin {1}
341
// user code end
342
} catch (java.lang.Throwable JavaDoc ivjExc) {
343                 // user code begin {2}
344
// user code end
345
handleException(ivjExc);
346             }
347     };
348     return ivjObjectLabel;
349     }
350     /**
351      * Return the PopupMenu property value.
352      * @return org.jacorb.poa.gui.beans.PopupMenu
353      */

354     /* WARNING: THIS METHOD WILL BE REGENERATED. */
355     private org.jacorb.poa.gui.beans.PopupMenu getPopupMenu() {
356     if (ivjPopupMenu == null) {
357             try {
358                 ivjPopupMenu = new org.jacorb.poa.gui.beans.PopupMenu();
359                 ivjPopupMenu.setLabel("Object Actions");
360                 ivjPopupMenu.add(getDeactivateMenuItem());
361                 ivjPopupMenu.add(getInspectionMenuItem());
362                 // user code begin {1}
363
// user code end
364
} catch (java.lang.Throwable JavaDoc ivjExc) {
365                 // user code begin {2}
366
// user code end
367
handleException(ivjExc);
368             }
369     };
370     return ivjPopupMenu;
371     }
372     java.awt.Label JavaDoc _getSecondLabel() {
373     return getServantLabel();
374     }
375     /**
376      * Return the Label2 property value.
377      * @return java.awt.Label
378      */

379     /* WARNING: THIS METHOD WILL BE REGENERATED. */
380     private java.awt.Label JavaDoc getServantLabel() {
381     if (ivjServantLabel == null) {
382             try {
383                 ivjServantLabel = new java.awt.Label JavaDoc();
384                 ivjServantLabel.setName("ServantLabel");
385                 ivjServantLabel.setFont(new java.awt.Font JavaDoc("dialog", 0, 10));
386                 ivjServantLabel.setText("Label2");
387                 ivjServantLabel.setBounds(200, 0, 990, 13);
388                 // user code begin {1}
389
// user code end
390
} catch (java.lang.Throwable JavaDoc ivjExc) {
391                 // user code begin {2}
392
// user code end
393
handleException(ivjExc);
394             }
395     };
396     return ivjServantLabel;
397     }
398     /**
399      * Called whenever the part throws an exception.
400      * @param exception java.lang.Throwable
401      */

402     private void handleException(Throwable JavaDoc exception) {
403
404     /* Uncomment the following lines to print uncaught exceptions to stdout */
405     // System.out.println("--------- UNCAUGHT EXCEPTION ---------");
406
// exception.printStackTrace(System.out);
407
}
408     /**
409      * Initializes connections
410      */

411     /* WARNING: THIS METHOD WILL BE REGENERATED. */
412     private void initConnections() {
413     // user code begin {1}
414
// user code end
415
getServantLabel().addMouseListener(this);
416     getObjectLabel().addMouseListener(this);
417     getInnerPanel().addMouseListener(this);
418     getDeactivateMenuItem().addActionListener(this);
419     getInspectionMenuItem().addActionListener(this);
420     }
421     /**
422      * Initialize the class.
423      */

424     /* WARNING: THIS METHOD WILL BE REGENERATED. */
425     private void initialize() {
426     // user code begin {1}
427
// user code end
428
setName("ObjectListItem");
429     setLayout(null);
430     setBackground(java.awt.Color.black);
431     setSize(1200, 15);
432     add(getInnerPanel(), getInnerPanel().getName());
433     initConnections();
434     // user code begin {2}
435
// user code end
436
}
437     void _init(ObjectListItemController _controller, String JavaDoc _oidStr) {
438     controller = _controller;
439     oidStr = _oidStr;
440     }
441     /**
442      * ObjectListItem constructor comment.
443      * @param layout java.awt.LayoutManager
444      */

445     public ObjectListItem(java.awt.LayoutManager JavaDoc layout) {
446     super(layout);
447     }
448     /**
449      * main entrypoint - starts the part when it is run as an application
450      * @param args java.lang.String[]
451      */

452     public static void main(java.lang.String JavaDoc[] args) {
453     try {
454             java.awt.Frame JavaDoc frame;
455             try {
456                 Class JavaDoc aFrameClass = Class.forName("com.ibm.uvm.abt.edit.TestFrame");
457                 frame = (java.awt.Frame JavaDoc)aFrameClass.newInstance();
458             } catch (java.lang.Throwable JavaDoc ivjExc) {
459                 frame = new java.awt.Frame JavaDoc();
460             }
461             ObjectListItem aObjectListItem;
462             aObjectListItem = new ObjectListItem();
463             frame.add("Center", aObjectListItem);
464             frame.setSize(aObjectListItem.getSize());
465             frame.setVisible(true);
466     } catch (Throwable JavaDoc exception) {
467             System.err.println("Exception occurred in main() of java.awt.Panel");
468             exception.printStackTrace(System.out);
469     }
470     }
471     /**
472      * Method to handle events for the MouseListener interface.
473      * @param e java.awt.event.MouseEvent
474      */

475     /* WARNING: THIS METHOD WILL BE REGENERATED. */
476     public void mouseClicked(java.awt.event.MouseEvent JavaDoc e) {
477     // user code begin {1}
478
// user code end
479
// user code begin {2}
480
// user code end
481
}
482     /**
483      * Method to handle events for the MouseListener interface.
484      * @param e java.awt.event.MouseEvent
485      */

486     /* WARNING: THIS METHOD WILL BE REGENERATED. */
487     public void mouseEntered(java.awt.event.MouseEvent JavaDoc e) {
488     // user code begin {1}
489
// user code end
490
// user code begin {2}
491
// user code end
492
}
493     /**
494      * Method to handle events for the MouseListener interface.
495      * @param e java.awt.event.MouseEvent
496      */

497     /* WARNING: THIS METHOD WILL BE REGENERATED. */
498     public void mouseExited(java.awt.event.MouseEvent JavaDoc e) {
499     // user code begin {1}
500
// user code end
501
// user code begin {2}
502
// user code end
503
}
504     /**
505      * Method to handle events for the MouseListener interface.
506      * @param e java.awt.event.MouseEvent
507      */

508     /* WARNING: THIS METHOD WILL BE REGENERATED. */
509     public void mousePressed(java.awt.event.MouseEvent JavaDoc e) {
510     // user code begin {1}
511
// user code end
512
if ((e.getSource() == getServantLabel()) ) {
513             connEtoC1(e);
514     }
515     if ((e.getSource() == getObjectLabel()) ) {
516             connEtoC2(e);
517     }
518     if ((e.getSource() == getInnerPanel()) ) {
519             connEtoC3(e);
520     }
521     // user code begin {2}
522
// user code end
523
}
524     /**
525      * Method to handle events for the MouseListener interface.
526      * @param e java.awt.event.MouseEvent
527      */

528     /* WARNING: THIS METHOD WILL BE REGENERATED. */
529     public void mouseReleased(java.awt.event.MouseEvent JavaDoc e) {
530     // user code begin {1}
531
// user code end
532
if ((e.getSource() == getObjectLabel()) ) {
533             connEtoC6(e);
534     }
535     if ((e.getSource() == getInnerPanel()) ) {
536             connEtoC7(e);
537     }
538     if ((e.getSource() == getServantLabel()) ) {
539             connEtoC8(e);
540     }
541     // user code begin {2}
542
// user code end
543
}
544     public void _setContainer(DoubleListDialog _container) {
545     container = _container;
546     }
547     public void _setSelected(boolean selected) {
548     if (selected) {
549             getInnerPanel().setBackground(java.awt.Color.darkGray);
550             getObjectLabel().setBackground(java.awt.Color.darkGray);
551             getServantLabel().setBackground(java.awt.Color.darkGray);
552             getObjectLabel().setForeground(java.awt.Color.white);
553             getServantLabel().setForeground(java.awt.Color.white);
554
555     } else {
556             getInnerPanel().setBackground(java.awt.Color.lightGray);
557             getObjectLabel().setBackground(java.awt.Color.lightGray);
558             getServantLabel().setBackground(java.awt.Color.lightGray);
559             getObjectLabel().setForeground(java.awt.Color.black);
560             getServantLabel().setForeground(java.awt.Color.black);
561     }
562     }
563     void _setWidth(int w1, int w2) {
564     getObjectLabel().setSize(w1, 13);
565     getServantLabel().setBounds(20+w1, 0, 1200-(w1+20), 13);
566         /*
567                 init_width2 = curr_width2 = w2;
568                 init_width = curr_width = 10+w1+10+w2+10 +500;
569                 setSize(init_width, 15);
570                 getInnerPanel().setSize(init_width, 13);
571                 getObjectLabel().setSize(w1, 13);
572                 getServantLabel().setBounds(20+w1, 0, w2 +500, 13);
573         */

574     }
575     /**
576      * Constructor
577      */

578     /* WARNING: THIS METHOD WILL BE REGENERATED. */
579     public ObjectListItem() {
580     super();
581     initialize();
582     }
583 }
584
585
586
587
588
589
590
591
592
593
594
595
596
597
Popular Tags