1 28 29 package org.objectweb.util.browser.plugins.fractal.menu; 30 31 import org.objectweb.fractal.api.control.NameController; 32 import org.objectweb.util.browser.api.MenuItem; 33 import org.objectweb.util.browser.api.MenuItemTreeView; 34 import org.objectweb.util.browser.api.Tree; 35 import org.objectweb.util.browser.api.TreeView; 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.DefaultDialogBox; 39 import org.objectweb.util.browser.gui.lib.LabelBox; 40 41 46 public class FixComponentNameAction 47 implements MenuItem, 48 DialogAction 49 { 50 56 57 protected LabelBox nameBox_; 58 59 60 protected NameController nameController_; 61 62 63 protected Tree tree_; 64 65 66 protected String oldName_; 67 68 74 80 83 protected void createBox(DialogBox dialogBox) { 84 oldName_ = nameController_.getFcName(); 85 nameBox_ = new LabelBox("Name", oldName_); 86 dialogBox.addElementBox(nameBox_); 87 } 88 89 92 protected NameController getNameController(MenuItemTreeView e) { 93 return (NameController)e.getSelectedObject(); 94 } 95 96 102 public void actionPerformed(MenuItemTreeView e) throws Exception { 103 tree_ = e.getTree(); 104 nameController_ = getNameController(e); 105 DialogBox dialog = new DefaultDialogBox("Rename a component"); 106 createBox(dialog); 107 dialog.setValidateAction(this); 108 dialog.show(); 109 } 110 111 114 public int getStatus(TreeView treeView) { 115 return MenuItem.ENABLED_STATUS; 116 } 117 118 124 127 public void executeAction() throws Exception { 128 String name = nameBox_.getLabel(); 129 nameController_.setFcName(name); 130 } 131 132 } | Popular Tags |