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 2016/02/10 00:31:45 UTC

svn commit: r1729503 - in /pivot/branches/2.0.x: ./ tests/src/org/apache/pivot/tests/DataBindingTest.java tests/src/org/apache/pivot/tests/data_binding_test.bxml

Author: rwhitcomb
Date: Tue Feb  9 23:31:44 2016
New Revision: 1729503

URL: http://svn.apache.org/viewvc?rev=1729503&view=rev
Log:
Further refinement of the DataBindingTest program:  implement the "store" via a new button
in the GUI, and update the "context" display of the values after the store operation.

This is a merge of revision 1729493 from trunk to branches/2.0.x with the Java 7 changes
reverted out.

Modified:
    pivot/branches/2.0.x/   (props changed)
    pivot/branches/2.0.x/tests/src/org/apache/pivot/tests/DataBindingTest.java
    pivot/branches/2.0.x/tests/src/org/apache/pivot/tests/data_binding_test.bxml

Propchange: pivot/branches/2.0.x/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Feb  9 23:31:44 2016
@@ -1 +1 @@
-/pivot/trunk:1346574,1347051,1394847,1394858,1398511,1399331,1401781,1405882,1407585,1409081,1410536,1410555,1417081,1417258,1428056,1428650,1435351,1436707,1438126,1438659,1444260,1444910,1502657,1510821,1516518,1519859,1522078,1523205,1523736,1523776,1525982,1526005,1536829,1537222,1604238,1610563,1611829,1614462,1624381,1675204,1675517,1678238,1678251,1687873-1687874,1688306,1688484,1688523,1691618,1712175,1717360,1727931,1728247,1729480
+/pivot/trunk:1346574,1347051,1394847,1394858,1398511,1399331,1401781,1405882,1407585,1409081,1410536,1410555,1417081,1417258,1428056,1428650,1435351,1436707,1438126,1438659,1444260,1444910,1502657,1510821,1516518,1519859,1522078,1523205,1523736,1523776,1525982,1526005,1536829,1537222,1604238,1610563,1611829,1614462,1624381,1675204,1675517,1678238,1678251,1687873-1687874,1688306,1688484,1688523,1691618,1712175,1717360,1727931,1728247,1729480,1729493

Modified: pivot/branches/2.0.x/tests/src/org/apache/pivot/tests/DataBindingTest.java
URL: http://svn.apache.org/viewvc/pivot/branches/2.0.x/tests/src/org/apache/pivot/tests/DataBindingTest.java?rev=1729503&r1=1729502&r2=1729503&view=diff
==============================================================================
--- pivot/branches/2.0.x/tests/src/org/apache/pivot/tests/DataBindingTest.java (original)
+++ pivot/branches/2.0.x/tests/src/org/apache/pivot/tests/DataBindingTest.java Tue Feb  9 23:31:44 2016
@@ -16,6 +16,7 @@
  */
 package org.apache.pivot.tests;
 
+import java.awt.Color;
 import org.apache.pivot.beans.BXMLSerializer;
 import org.apache.pivot.collections.HashMap;
 import org.apache.pivot.collections.List;
@@ -24,6 +25,7 @@ import org.apache.pivot.json.JSON;
 import org.apache.pivot.json.JSONSerializer;
 import org.apache.pivot.wtk.Application;
 import org.apache.pivot.wtk.Button;
+import org.apache.pivot.wtk.ButtonPressListener;
 import org.apache.pivot.wtk.DesktopApplicationContext;
 import org.apache.pivot.wtk.Display;
 import org.apache.pivot.wtk.Label;
@@ -88,6 +90,22 @@ public class DataBindingTest extends App
     }
 
     private Window window = null;
+    private HashMap<String, Object> context = new HashMap<String, Object>();
+    private int currentColorIndex = -1;
+
+    private static Color[] labelColors = {
+        Color.RED,
+        Color.decode("#FFA500"),
+        Color.decode("#FFD700"),
+        Color.GREEN,
+        Color.BLUE,
+        Color.decode("#4B0082"),
+        Color.decode("#EE82EE")
+    };
+    private Color getNextColor() {
+        currentColorIndex = (currentColorIndex + 1) % labelColors.length;
+        return labelColors[currentColorIndex];
+    }
 
     @Override
     public void startup(Display display, Map<String, String> properties) throws Exception {
@@ -95,18 +113,29 @@ public class DataBindingTest extends App
         window = (Window) bxmlSerializer.readObject(DataBindingTest.class, "data_binding_test.bxml");
         window.open(display);
 
-        HashMap<String, Object> context = new HashMap<String, Object>();
         context.put("id1", "1");
         context.put("id2", "2");
         context.put("id3", "3");
 
         window.getContent().load(context);
 
-        context = new HashMap<String, Object>();
-        window.getContent().store(context);
-
-        Label textLabel = (Label)(bxmlSerializer.getNamespace().get("bindingDataText"));
+        final Label textLabel = (Label)(bxmlSerializer.getNamespace().get("bindingDataText"));
         textLabel.setText(JSONSerializer.toString(context));
+
+        Button storeButton = (Button)(bxmlSerializer.getNamespace().get("storeButton"));
+        storeButton.getButtonPressListeners().add(new ButtonPressListener() {
+            @Override
+            public void buttonPressed(Button button) {
+                window.getContent().store(context);
+                try {
+                    textLabel.setText(JSONSerializer.toString(context));
+                    textLabel.getStyles().put("color", getNextColor());
+                } catch (Exception ex) {
+                    throw new RuntimeException(ex);
+                }
+            }
+        });
+
     }
 
     @Override

Modified: pivot/branches/2.0.x/tests/src/org/apache/pivot/tests/data_binding_test.bxml
URL: http://svn.apache.org/viewvc/pivot/branches/2.0.x/tests/src/org/apache/pivot/tests/data_binding_test.bxml?rev=1729503&r1=1729502&r2=1729503&view=diff
==============================================================================
--- pivot/branches/2.0.x/tests/src/org/apache/pivot/tests/data_binding_test.bxml (original)
+++ pivot/branches/2.0.x/tests/src/org/apache/pivot/tests/data_binding_test.bxml Tue Feb  9 23:31:44 2016
@@ -45,8 +45,8 @@ limitations under the License.
             </ScrollPane>
         </Border>
 
-        <Separator heading="This is the 'selected item' binding data for each component:"/>
-        <Label bxml:id="bindingDataText"/>
+        <Separator heading="This is the current 'selected item' binding data for each component:"/>
+        <Label bxml:id="bindingDataText" styles="{font:'Monospaced Bold'}"/>
 
         <Separator heading="A ListView with selected key 'id1':"/>
         <ListView listData="$list" selectedItemKey="id1">
@@ -81,6 +81,11 @@ limitations under the License.
             </selectedItemBindMapping>
         </Spinner>
 
+        <Separator heading="Press 'Store' to test the other half of data binding."/>
+        <BoxPane styles="{horizontalAlignment:'center'}">
+            <PushButton bxml:id="storeButton" buttonData="Store"/>
+        </BoxPane>
+
         <Separator/>
         <Border styles="{padding:6,backgroundColor:'#F0E68C'}">
             <BoxPane orientation="horizontal">
@@ -88,5 +93,6 @@ limitations under the License.
                 <Label text="http://www.quotes.net" styles="{color:'blue'}"/>
             </BoxPane>
         </Border>
+
     </BoxPane>
 </Window>