001: package org.jacorb.poa.gui.poa;
002:
003: /*
004: * JacORB - a free Java ORB
005: *
006: * Copyright (C) 1997-2004 Gerald Brose.
007: *
008: * This library is free software; you can redistribute it and/or
009: * modify it under the terms of the GNU Library General Public
010: * License as published by the Free Software Foundation; either
011: * version 2 of the License, or (at your option) any later version.
012: *
013: * This library is distributed in the hope that it will be useful,
014: * but WITHOUT ANY WARRANTY; without even the implied warranty of
015: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
016: * Library General Public License for more details.
017: *
018: * You should have received a copy of the GNU Library General Public
019: * License along with this library; if not, write to the Free
020: * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
021: */
022:
023: import org.jacorb.poa.gui.beans.DoubleListDialog;
024:
025: /**
026: * @author Reimo Tiedemann, FU Berlin
027: * @version 1.0, 05/10/99, RT
028: */
029: public class ObjectListItem extends java.awt.Panel implements
030: org.jacorb.poa.gui.beans.DoubleListItem,
031: java.awt.event.ActionListener, java.awt.event.MouseListener {
032: public DoubleListDialog container;
033: private ObjectListItemController controller;
034: private String oidStr;
035: private java.awt.MenuItem ivjDeactivateMenuItem = null;
036: private java.awt.MenuItem ivjInspectionMenuItem = null;
037: private org.jacorb.poa.gui.beans.PopupMenu ivjPopupMenu = null;
038: private java.awt.Panel ivjInnerPanel = null;
039: private java.awt.Label ivjObjectLabel = null;
040: private java.awt.Label ivjServantLabel = null;
041:
042: /**
043: * Comment
044: */
045: private void _actionDeactivateObject() {
046: if (controller != null) {
047: controller._actionDeactivateObject(oidStr);
048: }
049: }
050:
051: /**
052: * Comment
053: */
054: private void _actionInspectServantClass() {
055: if (controller != null) {
056: controller._inspectServantClass(oidStr);
057: }
058: }
059:
060: /**
061: * Comment
062: */
063: private void _actionMousePressed(java.awt.event.MouseEvent e) {
064: if (container != null) {
065: container._setSelectedItem(this );
066: }
067: }
068:
069: /**
070: * Comment
071: */
072: private void _actionMouseReleased(java.awt.event.MouseEvent e) {
073: int mods = e.getModifiers();
074: if ((mods & java.awt.event.MouseEvent.BUTTON3_MASK) != 0) {
075: /* Right Mouse Button pressed */
076: getPopupMenu()._show(e);
077: } else if ((mods & java.awt.event.MouseEvent.BUTTON2_MASK) != 0) {
078: /* Middle Mouse Button pressed */
079: } else {
080: /* Left Mouse Button pressed */
081: if (e.getClickCount() > 1) {
082: /* doubel click */
083: }
084: }
085: }
086:
087: /**
088: * Method to handle events for the ActionListener interface.
089: * @param e java.awt.event.ActionEvent
090: */
091: /* WARNING: THIS METHOD WILL BE REGENERATED. */
092: public void actionPerformed(java.awt.event.ActionEvent e) {
093: // user code begin {1}
094: // user code end
095: if ((e.getSource() == getDeactivateMenuItem())) {
096: connEtoC4(e);
097: }
098: if ((e.getSource() == getInspectionMenuItem())) {
099: connEtoC5(e);
100: }
101: // user code begin {2}
102: // user code end
103: }
104:
105: /**
106: * connEtoC1: (Label2.mouse.mousePressed(java.awt.event.MouseEvent) --> ObjectListItem._actionMousePressed(Ljava.awt.event.MouseEvent;)V)
107: * @param arg1 java.awt.event.MouseEvent
108: */
109: /* WARNING: THIS METHOD WILL BE REGENERATED. */
110: private void connEtoC1(java.awt.event.MouseEvent arg1) {
111: try {
112: // user code begin {1}
113: // user code end
114: this ._actionMousePressed(arg1);
115: // user code begin {2}
116: // user code end
117: } catch (java.lang.Throwable ivjExc) {
118: // user code begin {3}
119: // user code end
120: handleException(ivjExc);
121: }
122: }
123:
124: /**
125: * connEtoC2: (Label1.mouse.mousePressed(java.awt.event.MouseEvent) --> ObjectListItem._actionMousePressed(Ljava.awt.event.MouseEvent;)V)
126: * @param arg1 java.awt.event.MouseEvent
127: */
128: /* WARNING: THIS METHOD WILL BE REGENERATED. */
129: private void connEtoC2(java.awt.event.MouseEvent arg1) {
130: try {
131: // user code begin {1}
132: // user code end
133: this ._actionMousePressed(arg1);
134: // user code begin {2}
135: // user code end
136: } catch (java.lang.Throwable ivjExc) {
137: // user code begin {3}
138: // user code end
139: handleException(ivjExc);
140: }
141: }
142:
143: /**
144: * connEtoC3: (Panel1.mouse.mousePressed(java.awt.event.MouseEvent) --> ObjectListItem._actionMousePressed(Ljava.awt.event.MouseEvent;)V)
145: * @param arg1 java.awt.event.MouseEvent
146: */
147: /* WARNING: THIS METHOD WILL BE REGENERATED. */
148: private void connEtoC3(java.awt.event.MouseEvent arg1) {
149: try {
150: // user code begin {1}
151: // user code end
152: this ._actionMousePressed(arg1);
153: // user code begin {2}
154: // user code end
155: } catch (java.lang.Throwable ivjExc) {
156: // user code begin {3}
157: // user code end
158: handleException(ivjExc);
159: }
160: }
161:
162: /**
163: * connEtoC4: (DeactivateMenuItem.action.actionPerformed(java.awt.event.ActionEvent) --> ObjectListItem._actionDeactivateObject()V)
164: * @param arg1 java.awt.event.ActionEvent
165: */
166: /* WARNING: THIS METHOD WILL BE REGENERATED. */
167: private void connEtoC4(java.awt.event.ActionEvent arg1) {
168: try {
169: // user code begin {1}
170: // user code end
171: this ._actionDeactivateObject();
172: // user code begin {2}
173: // user code end
174: } catch (java.lang.Throwable ivjExc) {
175: // user code begin {3}
176: // user code end
177: handleException(ivjExc);
178: }
179: }
180:
181: /**
182: * connEtoC5: (InspectionMenuItem.action.actionPerformed(java.awt.event.ActionEvent) --> ObjectListItem._actionInspectServantClass()V)
183: * @param arg1 java.awt.event.ActionEvent
184: */
185: /* WARNING: THIS METHOD WILL BE REGENERATED. */
186: private void connEtoC5(java.awt.event.ActionEvent arg1) {
187: try {
188: // user code begin {1}
189: // user code end
190: this ._actionInspectServantClass();
191: // user code begin {2}
192: // user code end
193: } catch (java.lang.Throwable ivjExc) {
194: // user code begin {3}
195: // user code end
196: handleException(ivjExc);
197: }
198: }
199:
200: /**
201: * connEtoC6: (ObjectLabel.mouse.mouseReleased(java.awt.event.MouseEvent) --> ObjectListItem._actionMouseReleased(Ljava.awt.event.MouseEvent;)V)
202: * @param arg1 java.awt.event.MouseEvent
203: */
204: /* WARNING: THIS METHOD WILL BE REGENERATED. */
205: private void connEtoC6(java.awt.event.MouseEvent arg1) {
206: try {
207: // user code begin {1}
208: // user code end
209: this ._actionMouseReleased(arg1);
210: // user code begin {2}
211: // user code end
212: } catch (java.lang.Throwable ivjExc) {
213: // user code begin {3}
214: // user code end
215: handleException(ivjExc);
216: }
217: }
218:
219: /**
220: * connEtoC7: (InnerPanel.mouse.mouseReleased(java.awt.event.MouseEvent) --> ObjectListItem._actionMouseReleased(Ljava.awt.event.MouseEvent;)V)
221: * @param arg1 java.awt.event.MouseEvent
222: */
223: /* WARNING: THIS METHOD WILL BE REGENERATED. */
224: private void connEtoC7(java.awt.event.MouseEvent arg1) {
225: try {
226: // user code begin {1}
227: // user code end
228: this ._actionMouseReleased(arg1);
229: // user code begin {2}
230: // user code end
231: } catch (java.lang.Throwable ivjExc) {
232: // user code begin {3}
233: // user code end
234: handleException(ivjExc);
235: }
236: }
237:
238: /**
239: * connEtoC8: (ServantLabel.mouse.mouseReleased(java.awt.event.MouseEvent) --> ObjectListItem._actionMouseReleased(Ljava.awt.event.MouseEvent;)V)
240: * @param arg1 java.awt.event.MouseEvent
241: */
242: /* WARNING: THIS METHOD WILL BE REGENERATED. */
243: private void connEtoC8(java.awt.event.MouseEvent arg1) {
244: try {
245: // user code begin {1}
246: // user code end
247: this ._actionMouseReleased(arg1);
248: // user code begin {2}
249: // user code end
250: } catch (java.lang.Throwable ivjExc) {
251: // user code begin {3}
252: // user code end
253: handleException(ivjExc);
254: }
255: }
256:
257: public void _correctWidth(int diff_width) {
258: /*
259: if (curr_width + diff_width < init_width) {
260: curr_width = init_width;
261: curr_width2 = init_width2;
262: } else {
263: curr_width = curr_width + diff_width;
264: curr_width2 = curr_width2 + diff_width;
265: }
266: setSize(curr_width, 15);
267: getInnerPanel().setSize(curr_width, 13);
268: getServantLabel().setSize(curr_width2, 13);
269: */
270: }
271:
272: /**
273: * Return the DeactivateMenuItem property value.
274: * @return java.awt.MenuItem
275: */
276: /* WARNING: THIS METHOD WILL BE REGENERATED. */
277: private java.awt.MenuItem getDeactivateMenuItem() {
278: if (ivjDeactivateMenuItem == null) {
279: try {
280: ivjDeactivateMenuItem = new java.awt.MenuItem();
281: ivjDeactivateMenuItem.setLabel("Deactivate Object");
282: // user code begin {1}
283: // user code end
284: } catch (java.lang.Throwable ivjExc) {
285: // user code begin {2}
286: // user code end
287: handleException(ivjExc);
288: }
289: }
290: ;
291: return ivjDeactivateMenuItem;
292: }
293:
294: java.awt.Label _getFirstLabel() {
295: return getObjectLabel();
296: }
297:
298: /**
299: * Return the Panel1 property value.
300: * @return java.awt.Panel
301: */
302: /* WARNING: THIS METHOD WILL BE REGENERATED. */
303: private java.awt.Panel getInnerPanel() {
304: if (ivjInnerPanel == null) {
305: try {
306: ivjInnerPanel = new java.awt.Panel();
307: ivjInnerPanel.setName("InnerPanel");
308: ivjInnerPanel.setLayout(null);
309: ivjInnerPanel.setBackground(java.awt.Color.lightGray);
310: ivjInnerPanel.setBounds(0, 1, 1200, 13);
311: getInnerPanel().add(getObjectLabel(),
312: getObjectLabel().getName());
313: getInnerPanel().add(getServantLabel(),
314: getServantLabel().getName());
315: // user code begin {1}
316: // user code end
317: } catch (java.lang.Throwable ivjExc) {
318: // user code begin {2}
319: // user code end
320: handleException(ivjExc);
321: }
322: }
323: ;
324: return ivjInnerPanel;
325: }
326:
327: /**
328: * Return the InspectionMenuItem property value.
329: * @return java.awt.MenuItem
330: */
331: /* WARNING: THIS METHOD WILL BE REGENERATED. */
332: private java.awt.MenuItem getInspectionMenuItem() {
333: if (ivjInspectionMenuItem == null) {
334: try {
335: ivjInspectionMenuItem = new java.awt.MenuItem();
336: ivjInspectionMenuItem.setEnabled(true);
337: ivjInspectionMenuItem.setLabel("Inspect Servant Class");
338: // user code begin {1}
339: // user code end
340: } catch (java.lang.Throwable ivjExc) {
341: // user code begin {2}
342: // user code end
343: handleException(ivjExc);
344: }
345: }
346: ;
347: return ivjInspectionMenuItem;
348: }
349:
350: /**
351: * Return the Label1 property value.
352: * @return java.awt.Label
353: */
354: /* WARNING: THIS METHOD WILL BE REGENERATED. */
355: private java.awt.Label getObjectLabel() {
356: if (ivjObjectLabel == null) {
357: try {
358: ivjObjectLabel = new java.awt.Label();
359: ivjObjectLabel.setName("ObjectLabel");
360: ivjObjectLabel.setFont(new java.awt.Font("dialog", 0,
361: 10));
362: ivjObjectLabel.setText("Label1");
363: ivjObjectLabel.setBounds(10, 0, 180, 13);
364: // user code begin {1}
365: // user code end
366: } catch (java.lang.Throwable ivjExc) {
367: // user code begin {2}
368: // user code end
369: handleException(ivjExc);
370: }
371: }
372: ;
373: return ivjObjectLabel;
374: }
375:
376: /**
377: * Return the PopupMenu property value.
378: * @return org.jacorb.poa.gui.beans.PopupMenu
379: */
380: /* WARNING: THIS METHOD WILL BE REGENERATED. */
381: private org.jacorb.poa.gui.beans.PopupMenu getPopupMenu() {
382: if (ivjPopupMenu == null) {
383: try {
384: ivjPopupMenu = new org.jacorb.poa.gui.beans.PopupMenu();
385: ivjPopupMenu.setLabel("Object Actions");
386: ivjPopupMenu.add(getDeactivateMenuItem());
387: ivjPopupMenu.add(getInspectionMenuItem());
388: // user code begin {1}
389: // user code end
390: } catch (java.lang.Throwable ivjExc) {
391: // user code begin {2}
392: // user code end
393: handleException(ivjExc);
394: }
395: }
396: ;
397: return ivjPopupMenu;
398: }
399:
400: java.awt.Label _getSecondLabel() {
401: return getServantLabel();
402: }
403:
404: /**
405: * Return the Label2 property value.
406: * @return java.awt.Label
407: */
408: /* WARNING: THIS METHOD WILL BE REGENERATED. */
409: private java.awt.Label getServantLabel() {
410: if (ivjServantLabel == null) {
411: try {
412: ivjServantLabel = new java.awt.Label();
413: ivjServantLabel.setName("ServantLabel");
414: ivjServantLabel.setFont(new java.awt.Font("dialog", 0,
415: 10));
416: ivjServantLabel.setText("Label2");
417: ivjServantLabel.setBounds(200, 0, 990, 13);
418: // user code begin {1}
419: // user code end
420: } catch (java.lang.Throwable ivjExc) {
421: // user code begin {2}
422: // user code end
423: handleException(ivjExc);
424: }
425: }
426: ;
427: return ivjServantLabel;
428: }
429:
430: /**
431: * Called whenever the part throws an exception.
432: * @param exception java.lang.Throwable
433: */
434: private void handleException(Throwable exception) {
435:
436: /* Uncomment the following lines to print uncaught exceptions to stdout */
437: // System.out.println("--------- UNCAUGHT EXCEPTION ---------");
438: // exception.printStackTrace(System.out);
439: }
440:
441: /**
442: * Initializes connections
443: */
444: /* WARNING: THIS METHOD WILL BE REGENERATED. */
445: private void initConnections() {
446: // user code begin {1}
447: // user code end
448: getServantLabel().addMouseListener(this );
449: getObjectLabel().addMouseListener(this );
450: getInnerPanel().addMouseListener(this );
451: getDeactivateMenuItem().addActionListener(this );
452: getInspectionMenuItem().addActionListener(this );
453: }
454:
455: /**
456: * Initialize the class.
457: */
458: /* WARNING: THIS METHOD WILL BE REGENERATED. */
459: private void initialize() {
460: // user code begin {1}
461: // user code end
462: setName("ObjectListItem");
463: setLayout(null);
464: setBackground(java.awt.Color.black);
465: setSize(1200, 15);
466: add(getInnerPanel(), getInnerPanel().getName());
467: initConnections();
468: // user code begin {2}
469: // user code end
470: }
471:
472: void _init(ObjectListItemController _controller, String _oidStr) {
473: controller = _controller;
474: oidStr = _oidStr;
475: }
476:
477: /**
478: * ObjectListItem constructor comment.
479: * @param layout java.awt.LayoutManager
480: */
481: public ObjectListItem(java.awt.LayoutManager layout) {
482: super (layout);
483: }
484:
485: /**
486: * main entrypoint - starts the part when it is run as an application
487: * @param args java.lang.String[]
488: */
489: public static void main(java.lang.String[] args) {
490: try {
491: java.awt.Frame frame;
492: try {
493: Class aFrameClass = Class
494: .forName("com.ibm.uvm.abt.edit.TestFrame");
495: frame = (java.awt.Frame) aFrameClass.newInstance();
496: } catch (java.lang.Throwable ivjExc) {
497: frame = new java.awt.Frame();
498: }
499: ObjectListItem aObjectListItem;
500: aObjectListItem = new ObjectListItem();
501: frame.add("Center", aObjectListItem);
502: frame.setSize(aObjectListItem.getSize());
503: frame.setVisible(true);
504: } catch (Throwable exception) {
505: System.err
506: .println("Exception occurred in main() of java.awt.Panel");
507: exception.printStackTrace(System.out);
508: }
509: }
510:
511: /**
512: * Method to handle events for the MouseListener interface.
513: * @param e java.awt.event.MouseEvent
514: */
515: /* WARNING: THIS METHOD WILL BE REGENERATED. */
516: public void mouseClicked(java.awt.event.MouseEvent e) {
517: // user code begin {1}
518: // user code end
519: // user code begin {2}
520: // user code end
521: }
522:
523: /**
524: * Method to handle events for the MouseListener interface.
525: * @param e java.awt.event.MouseEvent
526: */
527: /* WARNING: THIS METHOD WILL BE REGENERATED. */
528: public void mouseEntered(java.awt.event.MouseEvent e) {
529: // user code begin {1}
530: // user code end
531: // user code begin {2}
532: // user code end
533: }
534:
535: /**
536: * Method to handle events for the MouseListener interface.
537: * @param e java.awt.event.MouseEvent
538: */
539: /* WARNING: THIS METHOD WILL BE REGENERATED. */
540: public void mouseExited(java.awt.event.MouseEvent e) {
541: // user code begin {1}
542: // user code end
543: // user code begin {2}
544: // user code end
545: }
546:
547: /**
548: * Method to handle events for the MouseListener interface.
549: * @param e java.awt.event.MouseEvent
550: */
551: /* WARNING: THIS METHOD WILL BE REGENERATED. */
552: public void mousePressed(java.awt.event.MouseEvent e) {
553: // user code begin {1}
554: // user code end
555: if ((e.getSource() == getServantLabel())) {
556: connEtoC1(e);
557: }
558: if ((e.getSource() == getObjectLabel())) {
559: connEtoC2(e);
560: }
561: if ((e.getSource() == getInnerPanel())) {
562: connEtoC3(e);
563: }
564: // user code begin {2}
565: // user code end
566: }
567:
568: /**
569: * Method to handle events for the MouseListener interface.
570: * @param e java.awt.event.MouseEvent
571: */
572: /* WARNING: THIS METHOD WILL BE REGENERATED. */
573: public void mouseReleased(java.awt.event.MouseEvent e) {
574: // user code begin {1}
575: // user code end
576: if ((e.getSource() == getObjectLabel())) {
577: connEtoC6(e);
578: }
579: if ((e.getSource() == getInnerPanel())) {
580: connEtoC7(e);
581: }
582: if ((e.getSource() == getServantLabel())) {
583: connEtoC8(e);
584: }
585: // user code begin {2}
586: // user code end
587: }
588:
589: public void _setContainer(DoubleListDialog _container) {
590: container = _container;
591: }
592:
593: public void _setSelected(boolean selected) {
594: if (selected) {
595: getInnerPanel().setBackground(java.awt.Color.darkGray);
596: getObjectLabel().setBackground(java.awt.Color.darkGray);
597: getServantLabel().setBackground(java.awt.Color.darkGray);
598: getObjectLabel().setForeground(java.awt.Color.white);
599: getServantLabel().setForeground(java.awt.Color.white);
600:
601: } else {
602: getInnerPanel().setBackground(java.awt.Color.lightGray);
603: getObjectLabel().setBackground(java.awt.Color.lightGray);
604: getServantLabel().setBackground(java.awt.Color.lightGray);
605: getObjectLabel().setForeground(java.awt.Color.black);
606: getServantLabel().setForeground(java.awt.Color.black);
607: }
608: }
609:
610: void _setWidth(int w1, int w2) {
611: getObjectLabel().setSize(w1, 13);
612: getServantLabel().setBounds(20 + w1, 0, 1200 - (w1 + 20), 13);
613: /*
614: init_width2 = curr_width2 = w2;
615: init_width = curr_width = 10+w1+10+w2+10 +500;
616: setSize(init_width, 15);
617: getInnerPanel().setSize(init_width, 13);
618: getObjectLabel().setSize(w1, 13);
619: getServantLabel().setBounds(20+w1, 0, w2 +500, 13);
620: */
621: }
622:
623: /**
624: * Constructor
625: */
626: /* WARNING: THIS METHOD WILL BE REGENERATED. */
627: public ObjectListItem() {
628: super();
629: initialize();
630: }
631: }
|