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.NoSuchInterfaceException; 33 import org.objectweb.fractal.api.control.NameController; 34 import org.objectweb.fractal.api.factory.Factory; 35 import org.objectweb.fractal.api.factory.InstantiationException; 36 import org.objectweb.util.browser.api.MenuItem; 37 import org.objectweb.util.browser.api.MenuItemTreeView; 38 import org.objectweb.util.browser.api.TreeView; 39 import org.objectweb.util.browser.plugins.fractal.FcBrowser; 40 41 47 public class InstantiateAction 48 implements MenuItem 49 { 50 56 62 68 74 public void actionPerformed(MenuItemTreeView e) { 75 Factory factory = (Factory)e.getSelectedObject(); 76 try { 77 Component component = factory.newFcInstance(); 78 NameController nameController = FcBrowser.getNameController(component); 79 String name = "new-component"; 80 if(nameController!=null) 81 name = nameController.getFcName(); 82 e.getTree().addEntry(name,component); 83 } catch (InstantiationException e1) { 84 System.out.println("[" + getClass().getName() + "] Exception: " + e1.getMessage()); 85 } catch (NoSuchInterfaceException e2) { 86 System.out.println("[" + getClass().getName() + "] Exception: " + e2.getMessage()); 87 } 88 } 89 90 93 public int getStatus(TreeView treeView) { 94 return MenuItem.ENABLED_STATUS; 95 } 96 } | Popular Tags |