1 28 29 package org.objectweb.util.browser.plugins.fractal.menu; 30 31 import org.objectweb.fractal.api.Component; 32 import org.objectweb.fractal.api.Interface; 33 import org.objectweb.fractal.api.control.BindingController; 34 import org.objectweb.fractal.api.type.InterfaceType; 35 import org.objectweb.util.browser.api.DropAction; 36 import org.objectweb.util.browser.api.DropTreeView; 37 import org.objectweb.util.browser.plugins.fractal.FcBrowser; 38 import org.objectweb.util.browser.plugins.fractal.context.ClientCollectionInterfaceContainer; 39 40 46 public class BindInterfaceOnDropAction 47 implements DropAction 48 { 49 50 56 62 68 protected String getName(Interface itf, int number) { 69 String name = FcBrowser.getName(((InterfaceType)itf.getFcItfType())); 70 return name + ((number<10)?"0":"") + number; 71 } 72 73 79 83 public void execute(DropTreeView dropTreeView) throws Exception { 84 try { 85 Interface itfToBind = (Interface) dropTreeView.getDragSourceObject(); 86 ClientCollectionInterfaceContainer icc = (ClientCollectionInterfaceContainer) dropTreeView.getSelectedObject(); 87 int nbConnectedItf = icc.getEntries().length; 88 Interface collectionItf = icc.getItf(); 89 Component component = collectionItf.getFcItfOwner(); 90 BindingController bindingController = FcBrowser.getBindingController(component); 91 bindingController.bindFc(getName(collectionItf, nbConnectedItf), itfToBind); 92 } catch(ClassCastException e) { 93 throw new Exception ("Interface expected!"); 94 } 95 } 96 97 } 98 99 100 | Popular Tags |