KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > util > explorer > swing > gui > lib > ExtendedTreeChooserBox


1 /*====================================================================
2
3 Objectweb Explorer Framework
4 Copyright (C) 2000-2004 INRIA - USTL - LIFL - GOAL
5 Contact: openccm@objectweb.org
6
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2.1 of the License, or any later version.
11
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public
18 License along with this library; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20 USA
21
22 Initial developer(s): Jerome Moroy, Philippe Merle.
23 Contributor(s): ______________________________________.
24
25 ====================================================================*/

26
27 package org.objectweb.util.explorer.swing.gui.lib;
28
29 import java.awt.Component JavaDoc;
30 import java.util.Iterator JavaDoc;
31 import java.util.List JavaDoc;
32 import java.util.Vector JavaDoc;
33
34 import org.objectweb.util.explorer.swing.gui.api.DialogBox;
35
36
37 /**
38  *
39  *
40  * @author <a HREF="mailto:Jerome.Moroy@lifl.fr">Jerome Moroy</a>
41  *
42  * @version 0.1
43  */

44 public class ExtendedTreeChooserBox
45     extends TreeChooserBox {
46
47     //==================================================================
48
//
49
// Internal state.
50
//
51
//==================================================================
52

53     /** The dialog to use*/
54     protected DialogBox dialog_;
55     
56     /** The list of interface type */
57     protected List JavaDoc treeChooserBoxes_;
58
59     //==================================================================
60
//
61
// Constructors.
62
//
63
//==================================================================
64

65     /**
66      * Default constructor
67      * @param label The label of the box
68      * @param tree The DynamicTree to use
69      */

70     public ExtendedTreeChooserBox(String JavaDoc label, org.objectweb.fractal.api.Component treeComponent, DialogBox dialog) {
71         super(label, treeComponent, false);
72         treeChooserBoxes_ = new Vector JavaDoc();
73         treeChooserBoxes_.add(this);
74         browseButton_.setAction(new ExtendedBrowseAction(this));
75         dialog_ = dialog;
76     }
77
78     //==================================================================
79
//
80
// Internal methods.
81
//
82
//==================================================================
83

84     //==================================================================
85
//
86
// Public methods.
87
//
88
//==================================================================
89

90     public Object JavaDoc[] getObjects(){
91         List JavaDoc l = new Vector JavaDoc();
92         Iterator JavaDoc it = treeChooserBoxes_.iterator();
93         while (it.hasNext()) {
94             TreeChooserBox element = (TreeChooserBox) it.next();
95             Object JavaDoc o = element.getObject();
96             if(o!=null)
97                 l.add(element.getObject());
98         }
99         return (Object JavaDoc[])l.toArray(new Object JavaDoc[0]);
100     }
101
102     //==================================================================
103
//
104
// Internal class.
105
//
106
//==================================================================
107

108     protected class ExtendedBrowseAction extends BrowseAction{
109         
110         protected ExtendedBrowseAction(Component JavaDoc parent) {
111             super(parent);
112         }
113         
114         public void actionPerformed(java.awt.event.ActionEvent JavaDoc ae) {
115             super.actionPerformed(ae);
116             // Create a new TreeChooser
117
if(object_!=null){
118                 TreeChooserBox interfaceBox = new ExtendedTreeChooserBox("Interface Type",component_, ExtendedTreeChooserBox.this.dialog_);
119                 ExtendedTreeChooserBox.this.treeChooserBoxes_.add(interfaceBox);
120                 ExtendedTreeChooserBox.this.dialog_.addElementBox(interfaceBox);
121                 ExtendedTreeChooserBox.this.dialog_.show();
122             }
123         }
124     }
125
126 }
Popular Tags