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