KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jacorb > poa > gui > beans > DoubleListDialog


1 package org.jacorb.poa.gui.beans;
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  * Provides the functionality of a double list dialog.
25  *
26  * @author Reimo Tiedemann, FU Berlin
27  * @version 1.0, 05/10/99
28  * @see org.jacorb.poa.gui.beans.DoubleListItem
29  */

30 public class DoubleListDialog extends java.awt.Dialog JavaDoc implements CloseButtonPanelController, java.awt.event.ComponentListener JavaDoc, java.awt.event.MouseListener JavaDoc, java.awt.event.WindowListener JavaDoc {
31     private DoubleListItem selectedItem = null;
32     private int curr_width = 0;
33     private int init_width = 0;
34     private int curr_width_wp = 0;
35     private int init_width_wp = 0;
36     private int itemCount = 0;
37     private CloseButtonPanel ivjButtonPanel = null;
38     private java.awt.Panel JavaDoc ivjContentsPane = null;
39     private java.awt.Panel JavaDoc ivjInnerPanel = null;
40     private java.awt.ScrollPane JavaDoc ivjScrollPane = null;
41     private java.awt.Panel JavaDoc ivjWorkPanel = null;
42     private DoubleListHeaderPanel ivjHeaderPanel = null;
43 /**
44  * Constructor
45  * @param parent Symbol
46  */

47 /* WARNING: THIS METHOD WILL BE REGENERATED. */
48 public DoubleListDialog(java.awt.Frame JavaDoc parent) {
49     super(parent);
50     initialize();
51 }
52 /**
53  * DoubleListDialog constructor comment.
54  * @param parent java.awt.Frame
55  * @param title java.lang.String
56  */

57 public DoubleListDialog(java.awt.Frame JavaDoc parent, String JavaDoc title) {
58     super(parent, title);
59     initialize();
60 }
61 /**
62  * DoubleListDialog constructor comment.
63  * @param parent java.awt.Frame
64  * @param title java.lang.String
65  * @param modal boolean
66  */

67 public DoubleListDialog(java.awt.Frame JavaDoc parent, String JavaDoc title, boolean modal) {
68     super(parent, title, modal);
69     initialize();
70 }
71 /**
72  * DoubleListDialog constructor comment.
73  * @param parent java.awt.Frame
74  * @param modal boolean
75  */

76 public DoubleListDialog(java.awt.Frame JavaDoc parent, boolean modal) {
77     super(parent, modal);
78     initialize();
79 }
80 public void _actionCloseButtonPressed() {
81     dispose();
82 }
83 /**
84  * Comment
85  */

86 public void _actionMousePressed(java.awt.event.MouseEvent JavaDoc mouseEvent) {
87     _setSelectedItem(null);
88 }
89 /**
90  * Comment
91  */

92 private void _actionWindowResized(java.awt.event.ComponentEvent JavaDoc componentEvent) {
93     int width = getBounds().width;
94         
95     int diff = (width-12) - curr_width_wp;
96
97     if (width > init_width) {
98         curr_width_wp = curr_width_wp + diff;
99     } else {
100         curr_width_wp = init_width_wp;
101     }
102     
103     getWorkPanel().setSize(curr_width_wp, getWorkPanel().getComponentCount()*14);
104
105 /*
106     if (width > init_width || curr_width > init_width) {
107         
108         java.awt.Component[] components = getWorkPanel().getComponents();
109         System.out.println("Have got all components");
110         for (int i=0; i<components.length; i++) {
111             ((DoubleListItem) components[i])._correctWidth(diff);
112         }
113     }
114 */

115     getScrollPane().validate();
116 }
117 public void _addItem(DoubleListItem item) {
118     java.awt.Component JavaDoc c = (java.awt.Component JavaDoc) item;
119     c.setLocation(0, itemCount*14);
120     getWorkPanel().add(c);
121     item._setContainer(this);
122     itemCount++;
123 }
124 public void _setHeaderLabel1(String JavaDoc str) {
125     getHeaderPanel()._getHeaderLabel1().setText(str);
126 }
127 public void _setHeaderLabel2(String JavaDoc str) {
128     getHeaderPanel()._getHeaderLabel2().setText(str);
129 }
130 public void _setSelectedItem(DoubleListItem item) {
131     if (selectedItem != null) selectedItem._setSelected(false);
132     selectedItem = item;
133     if (selectedItem != null) selectedItem._setSelected(true);
134 }
135 public void _setSize(int w1, int w2) {
136     int width1 = w1 < 100 ? 100 : w1;
137     int width2 = w2 < 100 ? 100 : w2;
138     
139     init_width_wp = curr_width_wp = 10+width1+10+width2+10;
140     init_width = curr_width = init_width_wp +12;
141     
142     setSize(init_width, 400);
143     getWorkPanel().setSize(init_width - 12, 0);
144     getHeaderPanel()._getHeaderLabel1().setSize(width1, 20);
145     getHeaderPanel()._getHeaderLabel2().setBounds(20+width1, 0, width2, 20);
146 }
147 /**
148  * Method to handle events for the ComponentListener interface.
149  * @param e java.awt.event.ComponentEvent
150  */

151 /* WARNING: THIS METHOD WILL BE REGENERATED. */
152 public void componentHidden(java.awt.event.ComponentEvent JavaDoc e) {
153     // user code begin {1}
154
// user code end
155
// user code begin {2}
156
// user code end
157
}
158 /**
159  * Method to handle events for the ComponentListener interface.
160  * @param e java.awt.event.ComponentEvent
161  */

162 /* WARNING: THIS METHOD WILL BE REGENERATED. */
163 public void componentMoved(java.awt.event.ComponentEvent JavaDoc e) {
164     // user code begin {1}
165
// user code end
166
// user code begin {2}
167
// user code end
168
}
169 /**
170  * Method to handle events for the ComponentListener interface.
171  * @param e java.awt.event.ComponentEvent
172  */

173 /* WARNING: THIS METHOD WILL BE REGENERATED. */
174 public void componentResized(java.awt.event.ComponentEvent JavaDoc e) {
175     // user code begin {1}
176
// user code end
177
if ((e.getSource() == this) ) {
178         connEtoC2(e);
179     }
180     // user code begin {2}
181
// user code end
182
}
183 /**
184  * Method to handle events for the ComponentListener interface.
185  * @param e java.awt.event.ComponentEvent
186  */

187 /* WARNING: THIS METHOD WILL BE REGENERATED. */
188 public void componentShown(java.awt.event.ComponentEvent JavaDoc e) {
189     // user code begin {1}
190
// user code end
191
// user code begin {2}
192
// user code end
193
}
194 /**
195  * connEtoC1: (DoubleListDialog.window.windowClosing(java.awt.event.WindowEvent) --> DoubleListDialog.dispose()V)
196  * @param arg1 java.awt.event.WindowEvent
197  */

198 /* WARNING: THIS METHOD WILL BE REGENERATED. */
199 private void connEtoC1(java.awt.event.WindowEvent JavaDoc arg1) {
200     try {
201         // user code begin {1}
202
// user code end
203
this.dispose();
204         // user code begin {2}
205
// user code end
206
} catch (java.lang.Throwable JavaDoc ivjExc) {
207         // user code begin {3}
208
// user code end
209
handleException(ivjExc);
210     }
211 }
212 /**
213  * connEtoC2: (DoubleListDialog.component.componentResized(java.awt.event.ComponentEvent) --> DoubleListDialog._actionWindowResized(Ljava.awt.event.ComponentEvent;)V)
214  * @param arg1 java.awt.event.ComponentEvent
215  */

216 /* WARNING: THIS METHOD WILL BE REGENERATED. */
217 private void connEtoC2(java.awt.event.ComponentEvent JavaDoc arg1) {
218     try {
219         // user code begin {1}
220
// user code end
221
this._actionWindowResized(arg1);
222         // user code begin {2}
223
// user code end
224
} catch (java.lang.Throwable JavaDoc ivjExc) {
225         // user code begin {3}
226
// user code end
227
handleException(ivjExc);
228     }
229 }
230 /**
231  * connEtoC3: (WorkPanel.mouse.mousePressed(java.awt.event.MouseEvent) --> DoubleListDialog._actionMousePressed(Ljava.awt.event.MouseEvent;)V)
232  * @param arg1 java.awt.event.MouseEvent
233  */

234 /* WARNING: THIS METHOD WILL BE REGENERATED. */
235 private void connEtoC3(java.awt.event.MouseEvent JavaDoc arg1) {
236     try {
237         // user code begin {1}
238
// user code end
239
this._actionMousePressed(arg1);
240         // user code begin {2}
241
// user code end
242
} catch (java.lang.Throwable JavaDoc ivjExc) {
243         // user code begin {3}
244
// user code end
245
handleException(ivjExc);
246     }
247 }
248 /**
249  * Return the ButtonPanel property value.
250  * @return org.jacorb.poa.gui.beans.CloseButtonPanel
251  */

252 /* WARNING: THIS METHOD WILL BE REGENERATED. */
253 private CloseButtonPanel getButtonPanel() {
254     if (ivjButtonPanel == null) {
255         try {
256             ivjButtonPanel = new org.jacorb.poa.gui.beans.CloseButtonPanel();
257             ivjButtonPanel.setName("ButtonPanel");
258             // user code begin {1}
259
// user code end
260
} catch (java.lang.Throwable JavaDoc ivjExc) {
261             // user code begin {2}
262
// user code end
263
handleException(ivjExc);
264         }
265     };
266     return ivjButtonPanel;
267 }
268 /**
269  * Return the ContentsPane property value.
270  * @return java.awt.Panel
271  */

272 /* WARNING: THIS METHOD WILL BE REGENERATED. */
273 private java.awt.Panel JavaDoc getContentsPane() {
274     if (ivjContentsPane == null) {
275         try {
276             ivjContentsPane = new java.awt.Panel JavaDoc();
277             ivjContentsPane.setName("ContentsPane");
278             ivjContentsPane.setLayout(new java.awt.BorderLayout JavaDoc());
279             ivjContentsPane.setBackground(java.awt.SystemColor.control);
280             getContentsPane().add(getButtonPanel(), "South");
281             getContentsPane().add(getInnerPanel(), "Center");
282             // user code begin {1}
283
// user code end
284
} catch (java.lang.Throwable JavaDoc ivjExc) {
285             // user code begin {2}
286
// user code end
287
handleException(ivjExc);
288         }
289     };
290     return ivjContentsPane;
291 }
292 /**
293  * Return the TitlePanel property value.
294  * @return org.jacorb.poa.gui.beans.DoubleListHeaderPanel
295  */

296 /* WARNING: THIS METHOD WILL BE REGENERATED. */
297 private DoubleListHeaderPanel getHeaderPanel() {
298     if (ivjHeaderPanel == null) {
299         try {
300             ivjHeaderPanel = new org.jacorb.poa.gui.beans.DoubleListHeaderPanel();
301             ivjHeaderPanel.setName("HeaderPanel");
302             // user code begin {1}
303
// user code end
304
} catch (java.lang.Throwable JavaDoc ivjExc) {
305             // user code begin {2}
306
// user code end
307
handleException(ivjExc);
308         }
309     };
310     return ivjHeaderPanel;
311 }
312 /**
313  * Return the InnerPanel property value.
314  * @return java.awt.Panel
315  */

316 /* WARNING: THIS METHOD WILL BE REGENERATED. */
317 private java.awt.Panel JavaDoc getInnerPanel() {
318     if (ivjInnerPanel == null) {
319         try {
320             ivjInnerPanel = new java.awt.Panel JavaDoc();
321             ivjInnerPanel.setName("InnerPanel");
322             ivjInnerPanel.setLayout(new java.awt.BorderLayout JavaDoc());
323             ivjInnerPanel.setBackground(java.awt.SystemColor.control);
324             getInnerPanel().add(getHeaderPanel(), "North");
325             getInnerPanel().add(getScrollPane(), "Center");
326             // user code begin {1}
327
// user code end
328
} catch (java.lang.Throwable JavaDoc ivjExc) {
329             // user code begin {2}
330
// user code end
331
handleException(ivjExc);
332         }
333     };
334     return ivjInnerPanel;
335 }
336 /**
337  * Return the ScrollPane property value.
338  * @return java.awt.ScrollPane
339  */

340 /* WARNING: THIS METHOD WILL BE REGENERATED. */
341 private java.awt.ScrollPane JavaDoc getScrollPane() {
342     if (ivjScrollPane == null) {
343         try {
344             ivjScrollPane = new java.awt.ScrollPane JavaDoc();
345             ivjScrollPane.setName("ScrollPane");
346             getScrollPane().add(getWorkPanel(), getWorkPanel().getName());
347             // user code begin {1}
348
// user code end
349
} catch (java.lang.Throwable JavaDoc ivjExc) {
350             // user code begin {2}
351
// user code end
352
handleException(ivjExc);
353         }
354     };
355     return ivjScrollPane;
356 }
357 /**
358  * Return the WorkPanel property value.
359  * @return java.awt.Panel
360  */

361 /* WARNING: THIS METHOD WILL BE REGENERATED. */
362 private java.awt.Panel JavaDoc getWorkPanel() {
363     if (ivjWorkPanel == null) {
364         try {
365             ivjWorkPanel = new java.awt.Panel JavaDoc();
366             ivjWorkPanel.setName("WorkPanel");
367             ivjWorkPanel.setLayout(null);
368             ivjWorkPanel.setBackground(java.awt.Color.lightGray);
369             ivjWorkPanel.setLocation(0, 0);
370             // user code begin {1}
371
// user code end
372
} catch (java.lang.Throwable JavaDoc ivjExc) {
373             // user code begin {2}
374
// user code end
375
handleException(ivjExc);
376         }
377     };
378     return ivjWorkPanel;
379 }
380 /**
381  * Called whenever the part throws an exception.
382  * @param exception java.lang.Throwable
383  */

384 private void handleException(Throwable JavaDoc exception) {
385
386     /* Uncomment the following lines to print uncaught exceptions to stdout */
387     // System.out.println("--------- UNCAUGHT EXCEPTION ---------");
388
// exception.printStackTrace(System.out);
389
}
390 /**
391  * Initializes connections
392  */

393 /* WARNING: THIS METHOD WILL BE REGENERATED. */
394 private void initConnections() {
395     // user code begin {1}
396
// user code end
397
this.addWindowListener(this);
398     this.addComponentListener(this);
399     getWorkPanel().addMouseListener(this);
400 }
401 /**
402  * Initialize the class.
403  */

404 /* WARNING: THIS METHOD WILL BE REGENERATED. */
405 private void initialize() {
406     // user code begin {1}
407
// user code end
408
setName("DoubleListDialog");
409     setLayout(new java.awt.BorderLayout JavaDoc());
410     setSize(400, 400);
411     setResizable(true);
412     add(getContentsPane(), "Center");
413     initConnections();
414     // user code begin {2}
415
getButtonPanel()._init(this, "Cancel");
416     // user code end
417
}
418 /**
419  * main entrypoint - starts the part when it is run as an application
420  * @param args java.lang.String[]
421  */

422 public static void main(java.lang.String JavaDoc[] args) {
423     try {
424         DoubleListDialog aDoubleListDialog = new org.jacorb.poa.gui.beans.DoubleListDialog(new java.awt.Frame JavaDoc());
425         aDoubleListDialog.setModal(true);
426         try {
427             Class JavaDoc aCloserClass = Class.forName("com.ibm.uvm.abt.edit.WindowCloser");
428             Class JavaDoc parmTypes[] = { java.awt.Window JavaDoc.class };
429             Object JavaDoc parms[] = { aDoubleListDialog };
430             java.lang.reflect.Constructor JavaDoc aCtor = aCloserClass.getConstructor(parmTypes);
431             aCtor.newInstance(parms);
432         } catch (java.lang.Throwable JavaDoc exc) {};
433         aDoubleListDialog.setVisible(true);
434     } catch (Throwable JavaDoc exception) {
435         System.err.println("Exception occurred in main() of java.awt.Dialog");
436         exception.printStackTrace(System.out);
437     }
438 }
439 /**
440  * Method to handle events for the MouseListener interface.
441  * @param e java.awt.event.MouseEvent
442  */

443 /* WARNING: THIS METHOD WILL BE REGENERATED. */
444 public void mouseClicked(java.awt.event.MouseEvent JavaDoc e) {
445     // user code begin {1}
446
// user code end
447
// user code begin {2}
448
// user code end
449
}
450 /**
451  * Method to handle events for the MouseListener interface.
452  * @param e java.awt.event.MouseEvent
453  */

454 /* WARNING: THIS METHOD WILL BE REGENERATED. */
455 public void mouseEntered(java.awt.event.MouseEvent JavaDoc e) {
456     // user code begin {1}
457
// user code end
458
// user code begin {2}
459
// user code end
460
}
461 /**
462  * Method to handle events for the MouseListener interface.
463  * @param e java.awt.event.MouseEvent
464  */

465 /* WARNING: THIS METHOD WILL BE REGENERATED. */
466 public void mouseExited(java.awt.event.MouseEvent JavaDoc e) {
467     // user code begin {1}
468
// user code end
469
// user code begin {2}
470
// user code end
471
}
472 /**
473  * Method to handle events for the MouseListener interface.
474  * @param e java.awt.event.MouseEvent
475  */

476 /* WARNING: THIS METHOD WILL BE REGENERATED. */
477 public void mousePressed(java.awt.event.MouseEvent JavaDoc e) {
478     // user code begin {1}
479
// user code end
480
if ((e.getSource() == getWorkPanel()) ) {
481         connEtoC3(e);
482     }
483     // user code begin {2}
484
// user code end
485
}
486 /**
487  * Method to handle events for the MouseListener interface.
488  * @param e java.awt.event.MouseEvent
489  */

490 /* WARNING: THIS METHOD WILL BE REGENERATED. */
491 public void mouseReleased(java.awt.event.MouseEvent JavaDoc e) {
492     // user code begin {1}
493
// user code end
494
// user code begin {2}
495
// user code end
496
}
497 /**
498  * Method to handle events for the WindowListener interface.
499  * @param e java.awt.event.WindowEvent
500  */

501 /* WARNING: THIS METHOD WILL BE REGENERATED. */
502 public void windowActivated(java.awt.event.WindowEvent JavaDoc e) {
503     // user code begin {1}
504
// user code end
505
// user code begin {2}
506
// user code end
507
}
508 /**
509  * Method to handle events for the WindowListener interface.
510  * @param e java.awt.event.WindowEvent
511  */

512 /* WARNING: THIS METHOD WILL BE REGENERATED. */
513 public void windowClosed(java.awt.event.WindowEvent JavaDoc e) {
514     // user code begin {1}
515
// user code end
516
// user code begin {2}
517
// user code end
518
}
519 /**
520  * Method to handle events for the WindowListener interface.
521  * @param e java.awt.event.WindowEvent
522  */

523 /* WARNING: THIS METHOD WILL BE REGENERATED. */
524 public void windowClosing(java.awt.event.WindowEvent JavaDoc e) {
525     // user code begin {1}
526
// user code end
527
if ((e.getSource() == this) ) {
528         connEtoC1(e);
529     }
530     // user code begin {2}
531
// user code end
532
}
533 /**
534  * Method to handle events for the WindowListener interface.
535  * @param e java.awt.event.WindowEvent
536  */

537 /* WARNING: THIS METHOD WILL BE REGENERATED. */
538 public void windowDeactivated(java.awt.event.WindowEvent JavaDoc e) {
539     // user code begin {1}
540
// user code end
541
// user code begin {2}
542
// user code end
543
}
544 /**
545  * Method to handle events for the WindowListener interface.
546  * @param e java.awt.event.WindowEvent
547  */

548 /* WARNING: THIS METHOD WILL BE REGENERATED. */
549 public void windowDeiconified(java.awt.event.WindowEvent JavaDoc e) {
550     // user code begin {1}
551
// user code end
552
// user code begin {2}
553
// user code end
554
}
555 /**
556  * Method to handle events for the WindowListener interface.
557  * @param e java.awt.event.WindowEvent
558  */

559 /* WARNING: THIS METHOD WILL BE REGENERATED. */
560 public void windowIconified(java.awt.event.WindowEvent JavaDoc e) {
561     // user code begin {1}
562
// user code end
563
// user code begin {2}
564
// user code end
565
}
566 /**
567  * Method to handle events for the WindowListener interface.
568  * @param e java.awt.event.WindowEvent
569  */

570 /* WARNING: THIS METHOD WILL BE REGENERATED. */
571 public void windowOpened(java.awt.event.WindowEvent JavaDoc e) {
572     // user code begin {1}
573
// user code end
574
// user code begin {2}
575
// user code end
576
}
577
578
579 }
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
Popular Tags