KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > util > browser > plugins > fractal > 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.1 2004/04/20 16:37:27 moroy Exp $
27  ====================================================================*/

28
29 package org.objectweb.util.browser.plugins.fractal.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.util.browser.api.Entry;
39 import org.objectweb.util.browser.api.Table;
40 import org.objectweb.util.browser.api.TreeView;
41 import org.objectweb.util.browser.core.naming.DefaultEntry;
42 import org.objectweb.util.browser.core.naming.DefaultName;
43 import org.objectweb.util.browser.plugins.fractal.FcBrowser;
44 import org.objectweb.util.browser.plugins.fractal.context.InterfaceWrapperFactory;
45 import org.objectweb.util.browser.plugins.fractal.lib.SignatureWrapper;
46
47 /**
48  * Displays the internal components of a component.
49  * @author <a HREF="mailto:Jerome.Moroy@lifl.fr">Jerome Moroy</a>
50  * @version 0.1
51  */

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

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

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

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

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

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

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

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

135     protected ContentController provideContentController(TreeView treeView){
136         return (ContentController)treeView.getSelectedObject();
137     }
138     
139     //==================================================================
140
//
141
// Public methods for Table interface.
142
//
143
//==================================================================
144

145     /**
146      * Overriding methods
147      * @see org.objectweb.util.browser.api.Table#getHeaders()
148      */

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

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