1 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 52 public class InternalInterfacesTable 53 implements Table 54 { 55 56 62 68 69 protected NameController nameController_; 70 71 77 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 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 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 121 protected Object [] getValues(Interface itf, BindingController bc){ 122 Object [] values = new Object [3]; 123 String 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 135 protected ContentController provideContentController(TreeView treeView){ 136 return (ContentController)treeView.getSelectedObject(); 137 } 138 139 145 149 public String [] getHeaders(TreeView treeView) { 150 return new String []{"Interface", "Type", "Connected"}; 151 } 152 153 157 public Object [][] getRows(TreeView treeView) { 158 ContentController cc = provideContentController(treeView); 159 BindingController bc = getBindingController((Interface)cc); 160 nameController_ = getNameController((Interface)cc); 161 Object [] interfaces = cc.getFcInternalInterfaces(); 162 Object [][] values = new Object [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 |