KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > fractal > explorer > panel > InternalInterfacesTable


1 /*====================================================================
2  
3  Objectweb Browser 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.
23  Contributor(s): ______________________________________.
24  
25  ---------------------------------------------------------------------
26  $Id: InternalInterfacesTable.java,v 1.3 2004/11/15 16:44:24 moroy Exp $
27  ====================================================================*/

28
29 package org.objectweb.fractal.explorer.panel;
30
31 import org.objectweb.fractal.api.Component;
32 import org.objectweb.fractal.api.Interface;
33 import org.objectweb.fractal.api.NoSuchInterfaceException;
34 import org.objectweb.fractal.api.control.BindingController;
35 import org.objectweb.fractal.api.control.ContentController;
36 import org.objectweb.fractal.api.control.NameController;
37 import org.objectweb.fractal.api.type.InterfaceType;
38 import org.objectweb.fractal.explorer.FcExplorer;
39 import org.objectweb.fractal.explorer.context.InterfaceWrapperFactory;
40 import org.objectweb.fractal.explorer.lib.SignatureWrapper;
41 import org.objectweb.util.explorer.api.Entry;
42 import org.objectweb.util.explorer.api.Table;
43 import org.objectweb.util.explorer.api.TreeView;
44 import org.objectweb.util.explorer.core.naming.lib.DefaultEntry;
45
46 /**
47  * Displays the internal components of a component.
48  * @author <a HREF="mailto:Jerome.Moroy@lifl.fr">Jerome Moroy</a>
49  * @version 0.1
50  */

51 public class InternalInterfacesTable
52   implements Table
53 {
54     
55     //==================================================================
56
//
57
// Internal states.
58
//
59
//==================================================================
60

61     //==================================================================
62
//
63
// Constructor.
64
//
65
//==================================================================
66

67     /** The name controller. */
68     protected NameController nameController_;
69     
70     // ==================================================================
71
//
72
// Internal methods.
73
//
74
// ==================================================================
75

76     /**
77      * Provides the bound interface of the given client interface.
78      */

79     protected Entry getBoundInterface(Interface itf, BindingController bc){
80         if(bc!=null){
81             try{
82                 Interface bindInterface = (Interface)bc.lookupFc(itf.getFcItfName());
83                 if(bindInterface!=null)
84                     return new DefaultEntry(FcExplorer.getPrefixedName(bindInterface), bindInterface);
85             } catch(NoSuchInterfaceException e) {
86                 return null;
87             }
88         }
89         return null;
90     }
91     
92     /**
93      * Provides the BindingController associates to the given interface.
94      */

95     protected BindingController getBindingController(Interface itf){
96         Component comp = itf.getFcItfOwner();
97         try{
98             return FcExplorer.getBindingController(comp);
99         }catch(NoSuchInterfaceException e){
100             return null;
101         }
102     }
103     
104     /**
105      * Provides the NameController associates to the given interface.
106      */

107     protected NameController getNameController(Interface itf){
108         Component comp = itf.getFcItfOwner();
109         try{
110             return FcExplorer.getNameController(comp);
111         }catch(NoSuchInterfaceException e){
112             return null;
113         }
114     }
115     
116     /**
117      * Provides an interface, its type and the interface it is connected on.
118      */

119     protected Object JavaDoc[] getValues(Interface itf, BindingController bc){
120         Object JavaDoc[] values = new Object JavaDoc[3];
121         String JavaDoc sign = ((InterfaceType)itf.getFcItfType()).getFcItfSignature();
122         values[0] = new DefaultEntry(FcExplorer.getName(itf), InterfaceWrapperFactory.singleton().getWrapper(itf));
123         values[1] = new DefaultEntry(sign, new SignatureWrapper(sign));
124         values[2] = getBoundInterface(itf,bc);
125         return values;
126     }
127     
128     /**
129      * Provides the ContentController for the given tree view.
130      */

131     protected ContentController provideContentController(TreeView treeView){
132         return (ContentController)treeView.getSelectedObject();
133     }
134     
135     //==================================================================
136
//
137
// Public methods for Table interface.
138
//
139
//==================================================================
140

141     /**
142      * Overriding methods
143      * @see org.objectweb.util.browser.api.Table#getHeaders(org.objectweb.util.browser.api.TreeView)
144      */

145     public String JavaDoc[] getHeaders(TreeView treeView) {
146         return new String JavaDoc[]{"Interface", "Type", "Connected"};
147     }
148     
149     /**
150      * Overriding methods
151      * @see org.objectweb.util.browser.api.Table#getRows(org.objectweb.util.browser.api.TreeView)
152      */

153     public Object JavaDoc[][] getRows(TreeView treeView) {
154         ContentController cc = provideContentController(treeView);
155         BindingController bc = getBindingController((Interface)cc);
156         nameController_ = getNameController((Interface)cc);
157         Object JavaDoc[] interfaces = cc.getFcInternalInterfaces();
158         Object JavaDoc[][] values = new Object JavaDoc[interfaces.length][1];
159         for (int i = 0 ; i < interfaces.length ; i++){
160             values[i] = getValues((Interface)interfaces[i],bc);
161         }
162         return values;
163     }
164 }
165
Popular Tags