1 28 29 package org.objectweb.util.browser.plugins.fractal.panel; 30 31 import java.util.Enumeration ; 32 import java.util.Hashtable ; 33 import java.util.Vector ; 34 35 import org.objectweb.fractal.api.Component; 36 import org.objectweb.fractal.api.Interface; 37 import org.objectweb.fractal.api.NoSuchInterfaceException; 38 import org.objectweb.fractal.api.control.BindingController; 39 import org.objectweb.fractal.api.type.InterfaceType; 40 import org.objectweb.util.browser.api.Entry; 41 import org.objectweb.util.browser.api.Table; 42 import org.objectweb.util.browser.api.TreeView; 43 import org.objectweb.util.browser.core.api.ContextContainer; 44 import org.objectweb.util.browser.core.naming.DefaultEntry; 45 import org.objectweb.util.browser.core.naming.DefaultName; 46 import org.objectweb.util.browser.plugins.fractal.FcBrowser; 47 import org.objectweb.util.browser.plugins.fractal.context.ClientCollectionInterfaceContainer; 48 import org.objectweb.util.browser.plugins.fractal.context.ClientInterfaceWrapper; 49 import org.objectweb.util.browser.plugins.fractal.lib.SignatureWrapper; 50 51 58 public class ComponentTable 59 implements Table 60 { 61 62 68 74 80 83 protected boolean isClientType(Interface ir) { 84 InterfaceType it = (InterfaceType) ir.getFcItfType(); 85 return it.isFcClientItf(); 86 } 87 88 91 protected boolean isClientCollectionType(Interface ir) { 92 InterfaceType it = (InterfaceType)ir.getFcItfType(); 93 return (it.isFcClientItf() && it.isFcCollectionItf()); 94 } 95 96 99 protected boolean isControlInterface(Interface itf) { 100 return itf.getFcItfName().endsWith("-controller"); 101 } 102 103 106 protected Entry getBoundInterface(Interface itf, BindingController bc){ 107 if(bc!=null) { 108 try { 109 Interface bindInterface = (Interface)bc.lookupFc(itf.getFcItfName()); 110 if(bindInterface!=null) 111 return new DefaultEntry(bindInterface, 112 new DefaultName(FcBrowser.getPrefixedName(bindInterface))); 113 } catch(NoSuchInterfaceException e) { 114 return null; 115 } 116 } 117 return null; 118 } 119 120 126 130 public String [] getHeaders(TreeView treeView) { 131 return new String [] {"Interface", "Type", "Connected"}; 132 } 133 134 138 public Object [][] getRows(TreeView treeView) { 139 Hashtable collectionInterfaces = new Hashtable (); 140 Vector values = new Vector (); 141 142 Component comp = (Component)treeView.getSelectedObject(); 143 BindingController bc = null; 144 try{ 145 bc = FcBrowser.getBindingController(comp); 146 } catch(Exception e) { 147 System.err.println("Client interface Error : " + e.getMessage()); 148 } 149 150 Object [] objects = (Object [])comp.getFcInterfaces(); 151 for (int i = 0; i < objects.length; i++){ 152 if(!comp.equals(objects[i])){ 153 Interface itf = (Interface)objects[i]; 154 if (!isControlInterface(itf)) { 155 String sign = ((InterfaceType)itf.getFcItfType()).getFcItfSignature(); 156 InterfaceType it = (InterfaceType)itf.getFcItfType(); 157 if (isClientCollectionType(itf)) { 158 String name = FcBrowser.getName(it); 159 if(!collectionInterfaces.containsKey(it.getFcItfName())){ 160 ContextContainer cc = new ClientCollectionInterfaceContainer(itf); 161 cc.addEntry(name,new TableClientCollectionWrapper(itf)); 162 collectionInterfaces.put(it.getFcItfName(),cc); 163 } else { 164 ((ContextContainer)collectionInterfaces.get(it.getFcItfName())).addEntry(name,new TableClientCollectionWrapper(itf)); 165 } 166 } else if(isClientType(itf)) { 167 values.add(new Object [] {new DefaultEntry(new ClientInterfaceWrapper(itf), 168 new DefaultName(FcBrowser.getName(it))), 169 new DefaultEntry(new SignatureWrapper(sign), 170 new DefaultName(sign)), 171 getBoundInterface(itf,bc)}); 172 } else { 173 values.add(new Object [] {new DefaultEntry(itf, 174 new DefaultName(FcBrowser.getName(it))), 175 new DefaultEntry(new SignatureWrapper(sign), 176 new DefaultName(sign)), 177 null}); 178 } 179 } 180 } 181 } 182 Enumeration keys,elements; 184 keys = collectionInterfaces.keys(); 185 elements = collectionInterfaces.elements(); 186 for (int i = 0 ; i < collectionInterfaces.size() ; i++) { 187 ClientCollectionInterfaceContainer itfcc = (ClientCollectionInterfaceContainer)elements.nextElement(); 188 Entry[] entries = itfcc.getEntries(); 189 for(int j = 0 ; j < entries.length ; j++) { 190 Interface itf = ((TableClientCollectionWrapper)entries[j].getValue()).getItf(); 191 String sign = ((InterfaceType)itfcc.getItf().getFcItfType()).getFcItfSignature(); 192 values.add(new Object []{entries[j], 193 new DefaultEntry(new SignatureWrapper(sign), 194 new DefaultName(sign)), 195 getBoundInterface(itf,bc)}); 196 } 197 } 198 199 Object [][] contenu = new Object [values.size()][2]; 200 for(int i=0 ; i<values.size() ; i++) 201 contenu[i] = (Object [])values.get(i); 202 return contenu; 203 } 204 } 205 | Popular Tags |