1 26 27 package org.objectweb.util.browser.plugin.java; 28 import java.util.Properties ; 29 30 import org.objectweb.util.browser.api.MenuItem; 31 import org.objectweb.util.browser.api.MenuItemTreeView; 32 import org.objectweb.util.browser.api.TreeView; 33 import org.objectweb.util.browser.gui.api.DialogAction; 34 import org.objectweb.util.browser.gui.api.DialogBox; 35 import org.objectweb.util.browser.gui.lib.DefaultDialogBox; 36 import org.objectweb.util.browser.gui.lib.LabelBox; 37 38 45 public class AddPropertyAction 46 implements MenuItem, DialogAction { 47 48 54 55 protected Properties properties_; 56 57 58 protected LabelBox keyBox_, valueBox_; 59 60 66 72 78 81 public int getStatus(TreeView treeView) { 82 return MenuItem.ENABLED_STATUS; 83 } 84 85 88 public void actionPerformed(MenuItemTreeView treeView) throws Exception { 89 properties_ = (Properties )treeView.getSelectedObject(); 90 DialogBox dialog_ = new DefaultDialogBox("Add a new property"); 91 keyBox_ = new LabelBox("Key"); 92 valueBox_ = new LabelBox("Value"); 93 dialog_.addElementBox(keyBox_); 94 dialog_.addElementBox(valueBox_); 95 dialog_.setValidateAction(this); 96 dialog_.show(); 97 } 98 99 105 109 public void executeAction() throws Exception { 110 properties_.setProperty(keyBox_.getLabel(),valueBox_.getLabel()); 111 } 112 113 } | Popular Tags |