1 26 27 package org.objectweb.util.browser.plugins.fractal.menu; 28 29 30 import java.awt.Dimension ; 31 32 33 import org.objectweb.fractal.api.Component; 34 import org.objectweb.fractal.api.Interface; 35 import org.objectweb.fractal.api.NoSuchInterfaceException; 36 import org.objectweb.fractal.api.control.ContentController; 37 import org.objectweb.fractal.api.control.LifeCycleController; 38 39 40 import org.objectweb.util.browser.api.MenuItem; 41 import org.objectweb.util.browser.api.MenuItemTreeView; 42 import org.objectweb.util.browser.api.TreeView; 43 import org.objectweb.util.browser.core.common.DynamicTree; 44 import org.objectweb.util.browser.gui.api.DialogAction; 45 import org.objectweb.util.browser.gui.api.DialogBox; 46 import org.objectweb.util.browser.gui.api.TreeProvider; 47 import org.objectweb.util.browser.gui.lib.DefaultDialogBox; 48 import org.objectweb.util.browser.gui.lib.DefaultTreeProvider; 49 import org.objectweb.util.browser.gui.lib.TreeBox; 50 51 57 public class RemoveSubComponentAction 58 implements MenuItem, DialogAction { 59 60 66 67 protected TreeBox treeBox_; 68 69 70 protected ContentController contentInterface_; 71 72 78 84 90 93 public int getStatus(TreeView treeView) { 94 ContentController contentInterface = (ContentController)treeView.getSelectedObject(); 95 Component component = ((Interface)contentInterface).getFcItfOwner(); 96 try { 97 LifeCycleController lcc = (LifeCycleController)component.getFcInterface("lifecycle-controller"); 98 String status = lcc.getFcState(); 99 if (status.equals("STARTED")) 100 return MenuItem.DISABLED_STATUS; 101 } catch (NoSuchInterfaceException e) { 102 } 104 return MenuItem.ENABLED_STATUS; 105 } 106 107 110 public void actionPerformed(MenuItemTreeView e) throws Exception { 111 112 contentInterface_ = (ContentController)e.getSelectedObject(); 113 114 TreeProvider treeProvider = new DefaultTreeProvider(); 115 DynamicTree tree = treeProvider.createDynamicTree(e,false); 116 tree.addEntry("Content Interface",contentInterface_,1); 117 118 treeBox_ = new TreeBox(tree); 119 treeBox_.setPreferredSize(new Dimension (450, 350)); 120 121 DialogBox dialog = new DefaultDialogBox("Select a component to remove"); 122 dialog.setValidateAction(this); 123 dialog.addElementBox(treeBox_); 124 dialog.show(); 125 } 126 127 133 136 public void executeAction() throws Exception { 137 Object o = treeBox_.getObject(); 138 try{ 139 Component subComponent = (Component)o; 140 contentInterface_.removeFcSubComponent(subComponent); 141 }catch(ClassCastException e1){ 142 throw new Exception ("You must select a ComponentIdentity !"); 143 } 144 } 145 146 147 } | Popular Tags |