You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pivot.apache.org by rw...@apache.org on 2013/01/03 23:44:59 UTC

svn commit: r1428652 - in /pivot/branches/2.0.x: ./ core/src/org/apache/pivot/beans/BXMLSerializer.java wtk/src/org/apache/pivot/wtk/Spinner.java

Author: rwhitcomb
Date: Thu Jan  3 22:44:59 2013
New Revision: 1428652

URL: http://svn.apache.org/viewvc?rev=1428652&view=rev
Log:
PIVOT-887: Make changes to Spinner and BXMLSerializer such that using the DefaultProperty of Spinner (which is "spinnerData") in a BXML file will work correctly.

Normally if the original value is a Sequence (as it always will be for the spinner data) the child is added to the sequence.  But using an ImmutableList enables BXMLSerializer to catch the UnsupportedOperationException and do a beanAdapter.put instead (which results in a call to "setSpinnerData"), which is the correct thing to do.

Merge revision 1428650 from trunk to branches/2.0.x.

Modified:
    pivot/branches/2.0.x/   (props changed)
    pivot/branches/2.0.x/core/src/org/apache/pivot/beans/BXMLSerializer.java
    pivot/branches/2.0.x/wtk/src/org/apache/pivot/wtk/Spinner.java

Propchange: pivot/branches/2.0.x/
------------------------------------------------------------------------------
  Merged /pivot/trunk:r1428650

Modified: pivot/branches/2.0.x/core/src/org/apache/pivot/beans/BXMLSerializer.java
URL: http://svn.apache.org/viewvc/pivot/branches/2.0.x/core/src/org/apache/pivot/beans/BXMLSerializer.java?rev=1428652&r1=1428651&r2=1428652&view=diff
==============================================================================
--- pivot/branches/2.0.x/core/src/org/apache/pivot/beans/BXMLSerializer.java (original)
+++ pivot/branches/2.0.x/core/src/org/apache/pivot/beans/BXMLSerializer.java Thu Jan  3 22:44:59 2013
@@ -1210,7 +1210,11 @@ public class BXMLSerializer implements S
 
                             if (defaultPropertyValue instanceof Sequence<?>) {
                                 Sequence<Object> sequence = (Sequence<Object>)defaultPropertyValue;
-                                sequence.add(element.value);
+                                try {
+                                    sequence.add(element.value);
+                                } catch (UnsupportedOperationException uoe) {
+                                    beanAdapter.put(defaultPropertyName, element.value);
+                                }
                             } else {
                                 beanAdapter.put(defaultPropertyName, element.value);
                             }

Modified: pivot/branches/2.0.x/wtk/src/org/apache/pivot/wtk/Spinner.java
URL: http://svn.apache.org/viewvc/pivot/branches/2.0.x/wtk/src/org/apache/pivot/wtk/Spinner.java?rev=1428652&r1=1428651&r2=1428652&view=diff
==============================================================================
--- pivot/branches/2.0.x/wtk/src/org/apache/pivot/wtk/Spinner.java (original)
+++ pivot/branches/2.0.x/wtk/src/org/apache/pivot/wtk/Spinner.java Thu Jan  3 22:44:59 2013
@@ -20,6 +20,7 @@ import java.util.Comparator;
 
 import org.apache.pivot.beans.DefaultProperty;
 import org.apache.pivot.collections.ArrayList;
+import org.apache.pivot.collections.immutable.ImmutableList;
 import org.apache.pivot.collections.List;
 import org.apache.pivot.collections.ListListener;
 import org.apache.pivot.collections.Sequence;
@@ -354,9 +355,14 @@ public class Spinner extends Container {
 
     /**
      * Creates a spinner populated with an empty array list.
+     * <p> The default contents is an {@link ImmutableList} so that
+     * if the default property (which is "spinnerData") is invoked in a BXML
+     * file, <code>BXMLSerializer</code> trying to add to this immutable sequence
+     * will catch an exception and will do a {@link #setSpinnerData setSpinnerData(List<?>)}
+     * instead.
      */
     public Spinner() {
-        this(new ArrayList<Object>());
+        this(new ImmutableList<Object>(new ArrayList<Object>()));
     }
 
     /**