KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > ojb > tools > mapping > reversedb2 > propertyEditors > EditableTreeNodeWithProperties


1 package org.apache.ojb.tools.mapping.reversedb2.propertyEditors;
2
3 /* Copyright 2002-2005 The Apache Software Foundation
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */

17
18 /**
19  * This class provides a basic implementation of a PropertyEditor and a TreeNode.
20  * This is the typical application of the propertyEditor framework, you will usually
21  * have a tree or a table with an overview of possibly editable objects and a panel
22  * with a detailed view on the object.
23  *
24  * The properties are maintained in a HashMap, setProperty sets these properties,
25  * getProperty retrieves them. You may want to define public final keys for your
26  * properties in order to have uniform access to them from all editors.
27  *
28  * @author <a HREF="mailto:bfl@florianbruckner.com">Florian Bruckner</a>
29  * @version $Id: EditableTreeNodeWithProperties.java,v 1.1.2.1 2005/12/21 22:33:27 tomdz Exp $
30  */

31 public abstract class EditableTreeNodeWithProperties
32     implements javax.swing.tree.TreeNode JavaDoc,
33     org.apache.ojb.tools.mapping.reversedb2.propertyEditors.PropertyEditorTarget,
34     java.io.Serializable JavaDoc
35 {
36     static final long serialVersionUID = -8720549176372985715L;
37     private java.util.HashMap JavaDoc hmAttributes = new java.util.HashMap JavaDoc();
38     
39     protected java.beans.PropertyChangeSupport JavaDoc propertyChangeDelegate = new
40         java.beans.PropertyChangeSupport JavaDoc(this);
41
42     /** Creates a new instance of EditableTreeNodeWithProperties */
43     public EditableTreeNodeWithProperties()
44     {
45     }
46     
47     /**
48      * Add a new PropertyChangeListener to this node. This functionality has
49      * been borrowed from the java.beans package, though this class has
50      * nothing to do with a bean
51      */

52     public void addPropertyChangeListener (java.beans.PropertyChangeListener JavaDoc listener)
53     {
54         this.propertyChangeDelegate.addPropertyChangeListener(listener);
55     }
56
57     /**
58      * Add a new PropertyChangeListener to this node for a specific property.
59      * This functionality has
60      * been borrowed from the java.beans package, though this class has
61      * nothing to do with a bean
62      */

63     public void addPropertyChangeListener (String JavaDoc propertyName, java.beans.PropertyChangeListener JavaDoc listener)
64     {
65         this.propertyChangeDelegate.addPropertyChangeListener(propertyName, listener);
66     }
67     
68     /**
69      * Remove a PropertyChangeListener from this node. This functionality has
70      * been borrowed from the java.beans package, though this class has
71      * nothing to do with a bean
72      */

73     public void removePropertyChangeListener (java.beans.PropertyChangeListener JavaDoc listener)
74     {
75         this.propertyChangeDelegate.removePropertyChangeListener (listener);
76     }
77
78     /**
79      * Remove a PropertyChangeListener for a specific property from this node.
80      * This functionality has. Please note that the listener this does not remove
81      * a listener that has been added without specifying the property it is
82      * interested in.
83      */

84     public void removePropertyChangeListener (String JavaDoc propertyName, java.beans.PropertyChangeListener JavaDoc listener)
85     {
86         this.propertyChangeDelegate.removePropertyChangeListener(propertyName, listener);
87     }
88     
89     /**
90      * Get an attribute of this node as Object. This method is backed by
91      * a HashMap, so all rules of HashMap apply to this method.
92      */

93     public Object JavaDoc getAttribute(String JavaDoc strKey)
94     {
95         return hmAttributes.get(strKey);
96     }
97     
98     /**
99      * Set an attribute of this node as Object. This method is backed by
100      * a HashMap, so all rules of HashMap apply to this method.
101      * Fires a PropertyChangeEvent.
102      */

103     public void setAttribute(String JavaDoc strKey, Object JavaDoc value)
104     {
105         this.propertyChangeDelegate.firePropertyChange(strKey,
106             hmAttributes.put(strKey, value), value);
107     }
108     
109 }
110
Popular Tags