You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pivot.apache.org by gb...@apache.org on 2011/01/04 12:40:18 UTC

svn commit: r1054979 - in /pivot/trunk/examples/src/org/apache/pivot/examples/builder: BuilderExample.java MyWindow.java builder_example.bxml

Author: gbrown
Date: Tue Jan  4 11:40:17 2011
New Revision: 1054979

URL: http://svn.apache.org/viewvc?rev=1054979&view=rev
Log:
Update builder example to use Bindable and BXML IDs.

Added:
    pivot/trunk/examples/src/org/apache/pivot/examples/builder/MyWindow.java
Modified:
    pivot/trunk/examples/src/org/apache/pivot/examples/builder/BuilderExample.java
    pivot/trunk/examples/src/org/apache/pivot/examples/builder/builder_example.bxml

Modified: pivot/trunk/examples/src/org/apache/pivot/examples/builder/BuilderExample.java
URL: http://svn.apache.org/viewvc/pivot/trunk/examples/src/org/apache/pivot/examples/builder/BuilderExample.java?rev=1054979&r1=1054978&r2=1054979&view=diff
==============================================================================
--- pivot/trunk/examples/src/org/apache/pivot/examples/builder/BuilderExample.java (original)
+++ pivot/trunk/examples/src/org/apache/pivot/examples/builder/BuilderExample.java Tue Jan  4 11:40:17 2011
@@ -16,27 +16,27 @@
  */
 package org.apache.pivot.examples.builder;
 
+import org.apache.pivot.collections.HashMap;
 import org.apache.pivot.collections.Map;
 import org.apache.pivot.wtk.Application;
 import org.apache.pivot.wtk.Display;
 import org.apache.pivot.wtk.Label;
 import org.apache.pivot.wtk.TabPane;
-import org.apache.pivot.wtk.Window;
 
 public class BuilderExample implements Application {
-    private Window window = null;
+    private MyWindow myWindow = null;
 
     @Override
     public void startup(Display display, Map<String, String> properties)
         throws Exception {
-        window = buildWindow();
-        window.open(display);
+        myWindow = buildWindow();
+        myWindow.open(display);
     }
 
     @Override
     public boolean shutdown(boolean optional) {
-        if (window != null) {
-            window.close();
+        if (myWindow != null) {
+            myWindow.close();
         }
 
         return false;
@@ -50,10 +50,14 @@ public class BuilderExample implements A
     public void resume() {
     }
 
-    private Window buildWindow() {
-        return new Window() {
+    private MyWindow buildWindow() {
+        final HashMap<String, Object> namespace = new HashMap<String, Object>();
+
+        return new MyWindow() {
             {   setContent(new TabPane() {
-                    {   getTabs().add(new Label() {
+                    {   namespace.put("tabPane", this);
+
+                        getTabs().add(new Label() {
                             {   setText("Label 1");
                                 TabPane.setTabData(this, "Label 1");
                             }
@@ -77,6 +81,8 @@ public class BuilderExample implements A
 
                 setTitle("Builder Example");
                 setMaximized(true);
+
+                initialize(namespace, null, null);
             }
         };
     }

Added: pivot/trunk/examples/src/org/apache/pivot/examples/builder/MyWindow.java
URL: http://svn.apache.org/viewvc/pivot/trunk/examples/src/org/apache/pivot/examples/builder/MyWindow.java?rev=1054979&view=auto
==============================================================================
--- pivot/trunk/examples/src/org/apache/pivot/examples/builder/MyWindow.java (added)
+++ pivot/trunk/examples/src/org/apache/pivot/examples/builder/MyWindow.java Tue Jan  4 11:40:17 2011
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except in
+ * compliance with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.pivot.examples.builder;
+
+import java.net.URL;
+
+import org.apache.pivot.beans.Bindable;
+import org.apache.pivot.collections.Map;
+import org.apache.pivot.json.JSON;
+import org.apache.pivot.util.Resources;
+import org.apache.pivot.wtk.TabPane;
+import org.apache.pivot.wtk.Window;
+
+public class MyWindow extends Window implements Bindable {
+    private TabPane tabPane;
+
+    @Override
+    public void initialize(Map<String, Object> namespace, URL location, Resources resources) {
+        tabPane = JSON.get(namespace, "tabPane");
+    }
+
+    public TabPane getTabPane() {
+        return tabPane;
+    }
+}

Modified: pivot/trunk/examples/src/org/apache/pivot/examples/builder/builder_example.bxml
URL: http://svn.apache.org/viewvc/pivot/trunk/examples/src/org/apache/pivot/examples/builder/builder_example.bxml?rev=1054979&r1=1054978&r2=1054979&view=diff
==============================================================================
--- pivot/trunk/examples/src/org/apache/pivot/examples/builder/builder_example.bxml (original)
+++ pivot/trunk/examples/src/org/apache/pivot/examples/builder/builder_example.bxml Tue Jan  4 11:40:17 2011
@@ -16,13 +16,14 @@ See the License for the specific languag
 limitations under the License.
 -->
 
-<Window title="Builder Example" maximized="true"
+<builder:MyWindow title="Builder Example" maximized="true"
     xmlns:bxml="http://pivot.apache.org/bxml"
+    xmlns:builder="org.apache.pivot.examples.builder"
     xmlns="org.apache.pivot.wtk">
-    <TabPane selectedIndex="2">
+    <TabPane bxml:id="tabPane" selectedIndex="2">
         <Label text="Label 1" TabPane.tabData="Label 1"/>
         <Label text="Label 2" TabPane.tabData="Label 2"/>
         <Label text="Label 3" TabPane.tabData="Label 3"/>
     </TabPane>
-</Window>
+</builder:MyWindow>