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 2009/09/26 20:03:26 UTC

svn commit: r819183 - in /incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/windows: Windows.java frame.wtkx

Author: gbrown
Date: Sat Sep 26 18:03:25 2009
New Revision: 819183

URL: http://svn.apache.org/viewvc?rev=819183&view=rev
Log:
Initialize palette location to a position relative to the opening frame.

Modified:
    incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/windows/Windows.java
    incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/windows/frame.wtkx

Modified: incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/windows/Windows.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/windows/Windows.java?rev=819183&r1=819182&r2=819183&view=diff
==============================================================================
--- incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/windows/Windows.java (original)
+++ incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/windows/Windows.java Sat Sep 26 18:03:25 2009
@@ -39,6 +39,7 @@
 
         for (int i = 0; i < 3; i++) {
             WTKXSerializer wtkxSerializer = new WTKXSerializer();
+            wtkxSerializer.put("application", this);
 
             Frame frame;
             try {
@@ -76,6 +77,12 @@
     public void resume() {
     }
 
+    public Window load(String fileName)
+        throws SerializationException, IOException {
+        WTKXSerializer wtkxSerializer = new WTKXSerializer();
+        return (Window)wtkxSerializer.readObject(this, fileName);
+    }
+
     public static void main(String[] args) {
         DesktopApplicationContext.main(Windows.class, args);
     }

Modified: incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/windows/frame.wtkx
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/windows/frame.wtkx?rev=819183&r1=819182&r2=819183&view=diff
==============================================================================
--- incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/windows/frame.wtkx (original)
+++ incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/windows/frame.wtkx Sat Sep 26 18:03:25 2009
@@ -16,7 +16,7 @@
 limitations under the License.
 -->
 
-<Frame icon="@application_form.png"
+<Frame wtkx:id="frame" icon="@application_form.png"
     preferredWidth="480" preferredHeight="360"
     xmlns:wtkx="http://pivot.apache.org/wtkx"
     xmlns:content="org.apache.pivot.wtk.content"
@@ -24,9 +24,12 @@
     <wtkx:define>
         <wtkx:include wtkx:id="dialog" src="dialog.wtkx"/>
         <wtkx:include wtkx:id="sheet" src="sheet.wtkx"/>
-        <wtkx:include wtkx:id="palette" src="palette.wtkx"/>
     </wtkx:define>
 
+    <wtkx:script>
+    var palette = null;
+    </wtkx:script>
+
     <content>
         <BoxPane orientation="vertical">
             <PushButton buttonData="Show Alert">
@@ -35,7 +38,7 @@
                     <![CDATA[
                     importPackage(org.apache.pivot.wtk);
                     function buttonPressed(button) {
-                        Alert.alert("This is an Alert.", button.getWindow());
+                        Alert.alert("This is an Alert.", frame);
                     }
                     ]]>
                     </wtkx:script>
@@ -48,7 +51,7 @@
                     <![CDATA[
                     importPackage(org.apache.pivot.wtk);
                     function buttonPressed(button) {
-                        Prompt.prompt("This is a Prompt.", button.getWindow());
+                        Prompt.prompt("This is a Prompt.", frame);
                     }
                     ]]>
                     </wtkx:script>
@@ -61,7 +64,7 @@
                     <![CDATA[
                     importPackage(org.apache.pivot.wtk);
                     function buttonPressed(button) {
-                        dialog.open(button.getWindow(), null);
+                        dialog.open(frame, null);
                     }
                     ]]>
                     </wtkx:script>
@@ -74,7 +77,7 @@
                     <![CDATA[
                     importPackage(org.apache.pivot.wtk);
                     function buttonPressed(button) {
-                        sheet.open(button.getWindow(), null);
+                        sheet.open(frame, null);
                     }
                     ]]>
                     </wtkx:script>
@@ -87,7 +90,12 @@
                     <![CDATA[
                     importPackage(org.apache.pivot.wtk);
                     function buttonPressed(button) {
-                        palette.open(button.getWindow());
+                        if (palette == null) {
+                            palette = application.load("palette.wtkx");
+                            palette.setLocation(frame.getX() + frame.getWidth() + 20, frame.getY() + 20);
+                        }
+
+                        palette.open(frame);
                     }
                     ]]>
                     </wtkx:script>