KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > util > browser > plugin > java > AddPropertyAction


1 /*====================================================================
2
3 Objectweb Browser framework
4 Copyright (C) 2000-2003 INRIA & USTL - LIFL - GOAL
5 Contact: openccm@objectweb.org
6
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2.1 of the License, or any later version.
11
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public
18 License along with this library; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20 USA
21
22 Initial developer(s): Jerome Moroy.
23 Contributor(s): ______________________________________.
24
25 ====================================================================*/

26
27 package org.objectweb.util.browser.plugin.java;
28 import java.util.Properties JavaDoc;
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 /**
39  * This class allows to add a propertie into a <code>java.util.Properties<code> object.
40  *
41  * @author <a HREF="mailto:Jerome.Moroy@lifl.fr">Jerome Moroy</a>
42  *
43  * @version 0.1
44  */

45 public class AddPropertyAction
46     implements MenuItem, DialogAction {
47
48     //==================================================================
49
//
50
// No internal state.
51
//
52
//==================================================================
53

54     /** The Properties object where adding the property */
55     protected Properties JavaDoc properties_;
56     
57     /** The boxes to specify the values */
58     protected LabelBox keyBox_, valueBox_;
59
60     //==================================================================
61
//
62
// No constructor.
63
//
64
//==================================================================
65

66     //==================================================================
67
//
68
// No internal method.
69
//
70
//==================================================================
71

72     //==================================================================
73
//
74
// Public methods for MenuItem interface.
75
//
76
//==================================================================
77

78     /**
79      * @see org.objectweb.util.browser.api.MenuItem#getStatus(org.objectweb.util.browser.api.TreeView)
80      */

81     public int getStatus(TreeView treeView) {
82         return MenuItem.ENABLED_STATUS;
83     }
84
85     /**
86      * @see org.objectweb.util.browser.api.MenuItem#actionPerformed(org.objectweb.util.browser.api.MenuItemTreeView)
87      */

88     public void actionPerformed(MenuItemTreeView treeView) throws Exception JavaDoc {
89         properties_ = (Properties JavaDoc)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     //==================================================================
100
//
101
// Public methods for DialogAction interface.
102
//
103
//==================================================================
104

105     /**
106      * Overriding methods
107      * @see org.objectweb.util.browser.gui.api.DialogAction#executeAction()
108      */

109     public void executeAction() throws Exception JavaDoc {
110         properties_.setProperty(keyBox_.getLabel(),valueBox_.getLabel());
111     }
112
113 }
Popular Tags