KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > openccm > explorer > Components > ProvidedInterfacesTable


1 /*====================================================================
2
3 OpenCCM: The Open CORBA Component Model Platform
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
27 package org.objectweb.openccm.explorer.Components;
28
29 /** The Java API's imports */
30 import java.util.List JavaDoc;
31 import java.util.Vector JavaDoc;
32 import java.util.Iterator JavaDoc;
33
34 /** The CCM's imports */
35 import org.omg.Components.CCMObject;
36 import org.omg.Components.ComponentPortDescription;
37 import org.omg.Components.FacetDescription;
38 import org.omg.Components.ConsumerDescription;
39
40 import org.objectweb.openccm.explorer.CORBA.TypageCORBA;
41 import org.objectweb.openccm.explorer.util.ior.IorPrinter;
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 ports of the given <code>CCMObject</code> component.
48  *
49  * @author <a HREF="mailto:Jerome.Moroy@lifl.fr">Jerome Moroy</a>
50  *
51  * @version 0.1
52  */

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

63     //==================================================================
64
//
65
// No constructor.
66
//
67
//==================================================================
68

69     // ==================================================================
70
//
71
// Internal methods.
72
//
73
// ==================================================================
74

75     protected String JavaDoc getName(org.omg.CORBA.Object JavaDoc o) {
76         TypageCORBA tc = new TypageCORBA(o, org.objectweb.openccm.corba.TheORB.getORB());
77         return tc.getTypeID();
78     }
79
80     //==================================================================
81
//
82
// Public methods for Table interface.
83
//
84
//==================================================================
85

86     /* (non-Javadoc)
87      * @see org.objectweb.util.explorer.api.Table#getHeaders(org.objectweb.util.explorer.api.TreeView)
88      */

89     public String JavaDoc[] getHeaders(TreeView treeView) {
90         return new String JavaDoc[]{"Port","Interface"};
91     }
92     
93     /* (non-Javadoc)
94      * @see org.objectweb.util.explorer.api.Table#getRows(org.objectweb.util.explorer.api.TreeView)
95      */

96     public Object JavaDoc[][] getRows(TreeView treeView) {
97         org.omg.CORBA.ORB JavaDoc orb = org.objectweb.openccm.corba.TheORB.getORB();
98         IorPrinter iorPrinter = null;
99         List JavaDoc l = new Vector JavaDoc();
100
101         CCMObject component = (CCMObject) treeView.getSelectedObject();
102         ComponentPortDescription cpd = component.get_all_ports();
103
104         FacetDescription[] fd = cpd.facets;
105         for (int i = 0; i < fd.length; i++)
106             l.add(new Object JavaDoc[]{
107                 new DefaultEntry(fd[i].name, fd[i]),
108                     new DefaultEntry(getName(fd[i].facet_ref), fd[i].facet_ref)
109                     });
110
111         ConsumerDescription[] cd = cpd.consumers;
112         for (int i = 0; i < cd.length; i++)
113             l.add(new Object JavaDoc[]{
114                 new DefaultEntry(cd[i].name, cd[i]),
115                     new DefaultEntry(getName(cd[i].consumer), cd[i].consumer)
116                     });
117                   
118         Object JavaDoc[][] contenu = new Object JavaDoc[l.size()][3];
119         Iterator JavaDoc it = l.iterator();
120         int cpt = 0;
121         while(it.hasNext()){
122             contenu[cpt] = (Object JavaDoc[])it.next();
123             cpt++;
124         }
125
126         return contenu;
127  
128    }
129 }
130
Popular Tags