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