1 28 29 package org.objectweb.fractal.explorer.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.fractal.explorer.FcExplorer; 36 import org.objectweb.fractal.explorer.context.ClientCollectionInterfaceContainer; 37 import org.objectweb.util.explorer.api.DropAction; 38 import org.objectweb.util.explorer.api.DropTreeView; 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 = FcExplorer.getName(((InterfaceType)itf.getFcItfType())); 70 return name + ((number<10)?"0":"") + number; 71 } 72 73 79 82 public void execute(DropTreeView dropTreeView) throws Exception { 83 try { 84 Interface itfToBind = (Interface) dropTreeView.getDragSourceObject(); 85 ClientCollectionInterfaceContainer icc = (ClientCollectionInterfaceContainer) dropTreeView.getSelectedObject(); 86 int nbConnectedItf = icc.getEntries(null).length; 87 Interface collectionItf = icc.getItf(); 88 Component component = collectionItf.getFcItfOwner(); 89 BindingController bindingController = FcExplorer.getBindingController(component); 90 bindingController.bindFc(getName(collectionItf, nbConnectedItf), itfToBind); 91 } catch(ClassCastException e) { 92 throw new Exception ("Interface expected!"); 93 } 94 } 95 96 } 97 98 99 | Popular Tags |