1 28 29 package org.objectweb.fractal.explorer.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.fractal.explorer.FcExplorer; 41 import org.objectweb.fractal.explorer.context.ClientCollectionInterfaceContainer; 42 import org.objectweb.fractal.explorer.context.ClientInterfaceWrapper; 43 import org.objectweb.fractal.explorer.lib.SignatureWrapper; 44 import org.objectweb.util.explorer.api.Entry; 45 import org.objectweb.util.explorer.api.Table; 46 import org.objectweb.util.explorer.api.TreeView; 47 import org.objectweb.util.explorer.core.common.api.ContextContainer; 48 import org.objectweb.util.explorer.core.naming.lib.DefaultEntry; 49 50 57 public class ComponentTable 58 implements Table 59 { 60 61 67 73 79 82 protected boolean isClientType(Interface ir) { 83 InterfaceType it = (InterfaceType) ir.getFcItfType(); 84 return it.isFcClientItf(); 85 } 86 87 90 protected boolean isClientCollectionType(Interface ir) { 91 InterfaceType it = (InterfaceType)ir.getFcItfType(); 92 return (it.isFcClientItf() && it.isFcCollectionItf()); 93 } 94 95 98 protected boolean isControlInterface(Interface itf) { 99 return itf.getFcItfName().endsWith("-controller"); 100 } 101 102 105 protected Entry getBoundInterface(Interface itf, BindingController bc){ 106 if(bc!=null) { 107 try { 108 Interface bindInterface = (Interface)bc.lookupFc(itf.getFcItfName()); 109 if(bindInterface!=null) 110 return new DefaultEntry(FcExplorer.getPrefixedName(bindInterface), bindInterface); 111 } catch(NoSuchInterfaceException e) { 112 return null; 113 } 114 } 115 return null; 116 } 117 118 124 127 public String [] getHeaders(TreeView treeView) { 128 return new String [] {"Interface", "Type", "Connected"}; 129 } 130 131 134 public Object [][] getRows(TreeView treeView) { 135 Hashtable collectionInterfaces = new Hashtable (); 136 Vector values = new Vector (); 137 138 Component comp = (Component)treeView.getSelectedObject(); 139 BindingController bc = null; 140 try{ 141 bc = FcExplorer.getBindingController(comp); 142 } catch(Exception e) { 143 System.err.println("Client interface Error : " + e.getMessage()); 144 } 145 146 Object [] objects = (Object [])comp.getFcInterfaces(); 147 for (int i = 0; i < objects.length; i++){ 148 if(!comp.equals(objects[i])){ 149 Interface itf = (Interface)objects[i]; 150 if (!isControlInterface(itf)) { 151 String sign = ((InterfaceType)itf.getFcItfType()).getFcItfSignature(); 152 InterfaceType it = (InterfaceType)itf.getFcItfType(); 153 if (isClientCollectionType(itf)) { 154 String name = FcExplorer.getName(it); 155 if(!collectionInterfaces.containsKey(it.getFcItfName())){ 156 ContextContainer cc = new ClientCollectionInterfaceContainer(itf); 157 cc.addEntry(name,new TableClientCollectionWrapper(itf)); 158 collectionInterfaces.put(it.getFcItfName(),cc); 159 } else { 160 ((ContextContainer)collectionInterfaces.get(it.getFcItfName())).addEntry(name,new TableClientCollectionWrapper(itf)); 161 } 162 } else if(isClientType(itf)) { 163 values.add(new Object [] {new DefaultEntry(FcExplorer.getName(it), new ClientInterfaceWrapper(itf)), 164 new DefaultEntry(sign, new SignatureWrapper(sign)), 165 getBoundInterface(itf,bc)}); 166 } else { 167 values.add(new Object [] {new DefaultEntry(FcExplorer.getName(it), itf), 168 new DefaultEntry(sign, new SignatureWrapper(sign)), 169 null}); 170 } 171 } 172 } 173 } 174 Enumeration keys,elements; 176 keys = collectionInterfaces.keys(); 177 elements = collectionInterfaces.elements(); 178 for (int i = 0 ; i < collectionInterfaces.size() ; i++) { 179 ClientCollectionInterfaceContainer itfcc = (ClientCollectionInterfaceContainer)elements.nextElement(); 180 Entry[] entries = itfcc.getEntries(null); 181 for(int j = 0 ; j < entries.length ; j++) { 182 Interface itf = ((TableClientCollectionWrapper)entries[j].getValue()).getItf(); 183 String sign = ((InterfaceType)itfcc.getItf().getFcItfType()).getFcItfSignature(); 184 values.add(new Object []{entries[j], 185 new DefaultEntry(sign, new SignatureWrapper(sign)), 186 getBoundInterface(itf,bc)}); 187 } 188 } 189 190 Object [][] contenu = new Object [values.size()][2]; 191 for(int i=0 ; i<values.size() ; i++) 192 contenu[i] = (Object [])values.get(i); 193 return contenu; 194 } 195 } 196 | Popular Tags |