1 28 29 package org.objectweb.fractal.explorer.menu; 30 31 import org.objectweb.fractal.api.type.TypeFactory; 32 import org.objectweb.fractal.explorer.FcExplorer; 33 import org.objectweb.util.explorer.api.MenuItem; 34 import org.objectweb.util.explorer.api.MenuItemTreeView; 35 import org.objectweb.util.explorer.api.TreeView; 36 import org.objectweb.util.explorer.core.common.api.ContextContainer; 37 import org.objectweb.util.explorer.swing.gui.api.DialogAction; 38 import org.objectweb.util.explorer.swing.gui.api.DialogBox; 39 import org.objectweb.util.explorer.swing.gui.lib.BooleanBox; 40 import org.objectweb.util.explorer.swing.gui.lib.DefaultDialogBox; 41 import org.objectweb.util.explorer.swing.gui.lib.LabelBox; 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 107 public void actionPerformed(MenuItemTreeView e) throws Exception { 108 typeFactory_ = FcExplorer.getTypeFactory(FcExplorer.getBootstrapComponent()); 109 cc_ = (ContextContainer)e.getSelectedObject(); 110 DialogBox dialog = new DefaultDialogBox("Create a new interface type"); 111 createBox(dialog); 112 dialog.setValidateAction(this); 113 dialog.show(); 114 } 115 116 119 public int getStatus(TreeView treeView) { 120 return MenuItem.ENABLED_STATUS; 121 } 122 123 129 132 public void executeAction() throws Exception { 133 String name = nameBox_.getLabel(); 134 String signature = signatureBox_.getLabel(); 135 boolean isClient = isClientBox_.getValue(); 136 boolean isOptional = isOptionalBox_.getValue(); 137 boolean isCollection = isCollectionBox_.getValue(); 138 cc_.addEntry(name,typeFactory_.createFcItfType(name,signature,isClient,isOptional,isCollection)); 139 } 140 141 } | Popular Tags |