1 28 29 package org.objectweb.util.browser.plugins.fractal.menu; 30 31 import org.objectweb.fractal.api.type.TypeFactory; 32 import org.objectweb.util.browser.api.MenuItem; 33 import org.objectweb.util.browser.api.MenuItemTreeView; 34 import org.objectweb.util.browser.api.TreeView; 35 import org.objectweb.util.browser.core.api.ContextContainer; 36 import org.objectweb.util.browser.gui.api.DialogAction; 37 import org.objectweb.util.browser.gui.api.DialogBox; 38 import org.objectweb.util.browser.gui.lib.BooleanBox; 39 import org.objectweb.util.browser.gui.lib.DefaultDialogBox; 40 import org.objectweb.util.browser.gui.lib.LabelBox; 41 import org.objectweb.util.browser.plugins.fractal.FcBrowser; 42 43 48 public class CreateInterfaceTypeAction 49 implements MenuItem, 50 DialogAction 51 { 52 58 59 protected BooleanBox isClientBox_, isOptionalBox_, isCollectionBox_; 60 61 62 protected LabelBox nameBox_, signatureBox_; 63 64 65 protected ContextContainer cc_; 66 67 68 protected TypeFactory typeFactory_; 69 70 76 82 85 protected void createBox(DialogBox dialogBox) { 86 nameBox_ = new LabelBox("Name"); 87 dialogBox.addElementBox(nameBox_); 88 signatureBox_ = new LabelBox("Signature"); 89 dialogBox.addElementBox(signatureBox_); 90 isClientBox_ = new BooleanBox("Type","Client","Server",true); 91 dialogBox.addElementBox(isClientBox_); 92 isOptionalBox_ = new BooleanBox("Contingency","Optional","Mandatory",true); 93 dialogBox.addElementBox(isOptionalBox_); 94 isCollectionBox_ = new BooleanBox("Cardinality","Collection","Single",true); 95 dialogBox.addElementBox(isCollectionBox_); 96 } 97 98 104 public void actionPerformed(MenuItemTreeView e) throws Exception { 105 typeFactory_ = FcBrowser.getTypeFactory(FcBrowser.getBootstrapComponent()); 106 cc_ = (ContextContainer)e.getSelectedObject(); 107 DialogBox dialog = new DefaultDialogBox("Create a new interface type"); 108 createBox(dialog); 109 dialog.setValidateAction(this); 110 dialog.show(); 111 } 112 113 116 public int getStatus(TreeView treeView) { 117 return MenuItem.ENABLED_STATUS; 118 } 119 120 126 129 public void executeAction() throws Exception { 130 String name = nameBox_.getLabel(); 131 String signature = signatureBox_.getLabel(); 132 boolean isClient = isClientBox_.getValue(); 133 boolean isOptional = isOptionalBox_.getValue(); 134 boolean isCollection = isCollectionBox_.getValue(); 135 cc_.addEntry(name,typeFactory_.createFcItfType(name,signature,isClient,isOptional,isCollection)); 136 } 137 138 } | Popular Tags |