1 26 27 package org.objectweb.openccm.explorer.Components; 28 29 import java.util.List ; 30 import java.util.Vector ; 31 import java.util.Iterator ; 32 33 import org.omg.Components.CCMObject; 34 import org.omg.Components.ComponentPortDescription; 35 import org.omg.Components.ReceptacleDescription; 36 import org.omg.Components.EmitterDescription; 37 import org.omg.Components.PublisherDescription; 38 import org.omg.Components.ConnectionDescription; 39 import org.objectweb.openccm.explorer.CORBA.TypageCORBA; 40 import org.objectweb.openccm.explorer.util.ior.IorPrinter; 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 import org.omg.Components.SubscriberDescription; 46 47 54 public class RequiredInterfacesTable 55 implements Table 56 { 57 58 64 70 76 protected String getName(org.omg.CORBA.Object o) { 77 TypageCORBA tc = new TypageCORBA(o, org.objectweb.openccm.corba.TheORB.getORB()); 78 return tc.getTypeID(); 79 } 80 81 87 90 public String [] getHeaders(TreeView treeView) { 91 return new String []{"Port","Connection","Connected"}; 92 } 93 94 97 public Object [][] getRows(TreeView treeView) { 98 org.omg.CORBA.ORB orb = org.objectweb.openccm.corba.TheORB.getORB(); 99 IorPrinter iorPrinter = null; 100 List l = new Vector (); 101 102 CCMObject component = (CCMObject) treeView.getSelectedObject(); 103 ComponentPortDescription cpd = component.get_all_ports(); 104 105 ReceptacleDescription[] rd = cpd.receptacles; 107 for (int i = 0; i < rd.length; i++) { 108 ReceptacleContainer rc = new ReceptacleContainer(); 109 rc.setComponent(component); 110 rc.setReceptacle(rd[i]); 111 Entry rdEntry = new DefaultEntry(rd[i].name, rc); 112 113 ConnectionDescription[] cd = rd[i].connections; 114 if(cd.length > 0){ 115 for (int j = 0; j < cd.length; j++) { 116 ConnectionContainer cc = new ConnectionContainer(); 117 cc.setConnection(cd[j]); 118 cc.setReceptacleContainer(rc); 119 Entry ccEntry = new DefaultEntry("Connection (" + j + ")", cc); 120 121 Entry cEntry = new DefaultEntry(getName(cd[j].objref), cd[j].objref); 122 123 l.add(new Object []{rdEntry, ccEntry, cEntry}); 124 } 125 } else { 126 l.add(new Object []{rdEntry, null, null}); 127 } 128 } 129 130 EmitterDescription[] ed = cpd.emitters; 132 for (int i = 0; i < ed.length; i++) { 133 EmitterContainer ec = new EmitterContainer(); 134 ec.setComponent(component); 135 ec.setEmitter(ed[i]); 136 Entry edEntry = new DefaultEntry(ed[i].name, ec); 137 138 if(ed[i].consumer!=null){ 139 Entry cEntry = new DefaultEntry(getName(ed[i].consumer), ed[i].consumer); 140 l.add(new Object []{edEntry, null, cEntry}); 141 } else { 142 l.add(new Object []{edEntry, null, null}); 143 } 144 } 145 146 PublisherDescription[] pd = cpd.publishers; 148 for (int i = 0; i < pd.length; i++) { 149 PublisherContainer pc = new PublisherContainer(); 150 pc.setComponent(component); 151 pc.setPublisher(pd[i]); 152 Entry pdEntry = new DefaultEntry(pd[i].name, pc); 153 154 SubscriberDescription[] sd = pd[i].consumers; 155 if(sd.length > 0){ 156 for (int j = 0; j < sd.length; j++) { 157 SubscriberContainer sc = new SubscriberContainer(); 158 sc.setSubscriber_(sd[j]); 159 sc.setPublisherContainer_(pc); 160 Entry scEntry = new DefaultEntry("Connection (" + j + ")", sc); 161 162 Entry sEntry = new DefaultEntry(getName(sd[j].consumer), sd[j].consumer); 163 164 l.add(new Object []{pdEntry, scEntry, sEntry}); 165 } 166 } else { 167 l.add(new Object []{pdEntry, null, null}); 168 } 169 170 } 171 172 Object [][] contenu = new Object [l.size()][3]; 173 Iterator it = l.iterator(); 174 int cpt = 0; 175 while(it.hasNext()){ 176 contenu[cpt] = (Object [])it.next(); 177 cpt++; 178 } 179 180 return contenu; 181 182 } 183 } 184 | Popular Tags |