changeset 879:edd9ab755798

RT-20956: add method setUserData in TableColumn (adding the same API to Tab and fixing up copy/paste JavaDoc issues in TableColumn)
author jgiles
date Thu, 26 Apr 2012 19:53:42 +1200
parents d86de2e536a0
children e91d38c52914
files javafx-ui-controls/src/javafx/scene/control/Tab.java javafx-ui-controls/src/javafx/scene/control/TableColumn.java
diffstat 2 files changed, 60 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/javafx-ui-controls/src/javafx/scene/control/Tab.java	Thu Apr 26 19:49:13 2012 +1200
+++ b/javafx-ui-controls/src/javafx/scene/control/Tab.java	Thu Apr 26 19:53:42 2012 +1200
@@ -26,7 +26,6 @@
 
 import com.sun.javafx.css.Styleable;
 import com.sun.javafx.css.StyleableProperty;
-import com.sun.javafx.event.BasicEventDispatcher;
 import javafx.beans.property.BooleanProperty;
 import javafx.beans.property.ObjectProperty;
 import javafx.beans.property.ObjectPropertyBase;
@@ -44,11 +43,12 @@
 import javafx.scene.Node;
 
 import com.sun.javafx.event.EventHandlerManager;
-import java.lang.ref.Reference;
 import java.util.Collections;
+import java.util.HashMap;
 import java.util.List;
 import javafx.beans.DefaultProperty;
 import javafx.beans.property.*;
+import javafx.collections.ObservableMap;
 
 /**
  * <p>Tabs are placed within a {@link TabPane}, where each tab represents a single
@@ -587,6 +587,60 @@
         setDisabled(isDisable() || (getTabPane() != null && getTabPane().isDisabled()));
     }
     
+    // --- Properties
+    private static final Object USER_DATA_KEY = new Object();
+    
+    // A map containing a set of properties for this Tab
+    private ObservableMap<Object, Object> properties;
+
+    /**
+      * Returns an observable map of properties on this Tab for use primarily
+      * by application developers.
+      *
+      * @return an observable map of properties on this Tab for use primarily
+      * by application developers
+      */
+     public final ObservableMap<Object, Object> getProperties() {
+        if (properties == null) {
+            properties = FXCollections.observableMap(new HashMap<Object, Object>());
+        }
+        return properties;
+    }
+    
+    /**
+     * Tests if this Tab has properties.
+     * @return true if this tab has properties.
+     */
+     public boolean hasProperties() {
+        return properties != null;
+    }
+
+     
+    // --- UserData
+    /**
+     * Convenience method for setting a single Object property that can be
+     * retrieved at a later date. This is functionally equivalent to calling
+     * the getProperties().put(Object key, Object value) method. This can later
+     * be retrieved by calling {@link Tab#getUserData()}.
+     *
+     * @param value The value to be stored - this can later be retrieved by calling
+     *          {@link Tab#getUserData()}.
+     */
+    public void setUserData(Object value) {
+        getProperties().put(USER_DATA_KEY, value);
+    }
+
+    /**
+     * Returns a previously set Object property, or null if no such property
+     * has been set using the {@link Tab#setUserData(java.lang.Object)} method.
+     *
+     * @return The Object that was previously set, or null if no property
+     *          has been set or if null was set.
+     */
+    public Object getUserData() {
+        return getProperties().get(USER_DATA_KEY);
+    }
+    
     /**
      * A list of String identifiers which can be used to logically group
      * Nodes, specifically for an external style engine. This variable is
--- a/javafx-ui-controls/src/javafx/scene/control/TableColumn.java	Thu Apr 26 19:49:13 2012 +1200
+++ b/javafx-ui-controls/src/javafx/scene/control/TableColumn.java	Thu Apr 26 19:53:42 2012 +1200
@@ -902,7 +902,7 @@
     }
     
     /**
-     * Tests if Node has properties.
+     * Tests if this TableColumn has properties.
      * @return true if node has properties.
      */
      public boolean hasProperties() {
@@ -915,10 +915,10 @@
      * Convenience method for setting a single Object property that can be
      * retrieved at a later date. This is functionally equivalent to calling
      * the getProperties().put(Object key, Object value) method. This can later
-     * be retrieved by calling {@link Node#getUserData()}.
+     * be retrieved by calling {@link TableColumn#getUserData()}.
      *
      * @param value The value to be stored - this can later be retrieved by calling
-     *          {@link Node#getUserData()}.
+     *          {@link TableColumn#getUserData()}.
      */
     public void setUserData(Object value) {
         getProperties().put(USER_DATA_KEY, value);
@@ -926,7 +926,7 @@
 
     /**
      * Returns a previously set Object property, or null if no such property
-     * has been set using the {@link Node#setUserData(java.lang.Object)} method.
+     * has been set using the {@link TableColumn#setUserData(java.lang.Object)} method.
      *
      * @return The Object that was previously set, or null if no property
      *          has been set or if null was set.