You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pivot.apache.org by sm...@apache.org on 2012/04/17 17:42:58 UTC

svn commit: r1327148 - in /pivot/trunk/tests/src/org/apache/pivot/tests: MenuBarTest.java SpinnerFocusTest.java menu_bar_test.bxml

Author: smartini
Date: Tue Apr 17 15:42:58 2012
New Revision: 1327148

URL: http://svn.apache.org/viewvc?rev=1327148&view=rev
Log:
clarified MenuBarTest and trim-whitespace

Modified:
    pivot/trunk/tests/src/org/apache/pivot/tests/MenuBarTest.java
    pivot/trunk/tests/src/org/apache/pivot/tests/SpinnerFocusTest.java
    pivot/trunk/tests/src/org/apache/pivot/tests/menu_bar_test.bxml

Modified: pivot/trunk/tests/src/org/apache/pivot/tests/MenuBarTest.java
URL: http://svn.apache.org/viewvc/pivot/trunk/tests/src/org/apache/pivot/tests/MenuBarTest.java?rev=1327148&r1=1327147&r2=1327148&view=diff
==============================================================================
--- pivot/trunk/tests/src/org/apache/pivot/tests/MenuBarTest.java (original)
+++ pivot/trunk/tests/src/org/apache/pivot/tests/MenuBarTest.java Tue Apr 17 15:42:58 2012
@@ -19,7 +19,10 @@ package org.apache.pivot.tests;
 import org.apache.pivot.beans.BXML;
 import org.apache.pivot.beans.BXMLSerializer;
 import org.apache.pivot.collections.Map;
+import org.apache.pivot.wtk.Action;
+import org.apache.pivot.wtk.Alert;
 import org.apache.pivot.wtk.Application;
+import org.apache.pivot.wtk.ApplicationContext;
 import org.apache.pivot.wtk.BoxPane;
 import org.apache.pivot.wtk.Component;
 import org.apache.pivot.wtk.DesktopApplicationContext;
@@ -30,7 +33,7 @@ import org.apache.pivot.wtk.MenuHandler;
 import org.apache.pivot.wtk.Orientation;
 import org.apache.pivot.wtk.TextInput;
 
-public class MenuBarTest implements Application {
+public class MenuBarTest extends Application.Adapter {
     private Frame frame1 = null;
     private Frame frame2 = null;
 
@@ -47,21 +50,37 @@ public class MenuBarTest implements Appl
         frame1 = new Frame(boxPane);
         frame1.setLocation(50, 50);
         frame1.setPreferredSize(320, 240);
-        frame1.open(display);
+        frame1.setTitle("Frame 1");
+
+        // put this before loading the related bxml, or an IllegalArgumentException will be thrown
+        Action.getNamedActions().put("about", new Action() {
+            @Override
+            public void perform(Component source) {
+                String msg = "Hello from Pivot-"
+                    + ApplicationContext.getPivotVersion().toString()
+                    + ", running from Java "
+                    // + ApplicationContext.getJVMVersion().toString()
+                    + System.getProperty("java.version")
+                ;
+                Alert.alert(msg, frame2.getRootOwner());  // frame2);
+                System.out.println("Help triggered");
+            }
+        });
 
         BXMLSerializer bxmlSerializer = new BXMLSerializer();
         frame2 = (Frame)bxmlSerializer.readObject(MenuBarTest.class, "menu_bar_test.bxml");
+        frame2.setTitle("Frame 2, from bxml");
         bxmlSerializer.bind(this, MenuBarTest.class);
 
         MenuHandler menuHandler = new MenuHandler.Adapter() {
             @Override
             public void configureMenuBar(Component component, MenuBar menuBar) {
-                System.out.println("Configure menu bar: " + component);
+                System.out.println("Configure menu bar: got focus on " + component.getName());
             }
 
             @Override
             public void cleanupMenuBar(Component component, MenuBar menuBar) {
-                System.out.println("Clean up menu bar: " + component);
+                System.out.println("Clean up menu bar: lost focus on " + component.getName());
             }
         };
 
@@ -69,6 +88,7 @@ public class MenuBarTest implements Appl
         textInput2.setMenuHandler(menuHandler);
         textInput3.setMenuHandler(menuHandler);
 
+        frame1.open(display);
         frame2.open(display);
     }
 
@@ -78,15 +98,11 @@ public class MenuBarTest implements Appl
             frame2.close();
         }
 
-        return false;
-    }
-
-    @Override
-    public void suspend() {
-    }
+        if (frame1 != null) {
+            frame1.close();
+        }
 
-    @Override
-    public void resume() {
+        return false;
     }
 
     public static void main(String[] args) {

Modified: pivot/trunk/tests/src/org/apache/pivot/tests/SpinnerFocusTest.java
URL: http://svn.apache.org/viewvc/pivot/trunk/tests/src/org/apache/pivot/tests/SpinnerFocusTest.java?rev=1327148&r1=1327147&r2=1327148&view=diff
==============================================================================
--- pivot/trunk/tests/src/org/apache/pivot/tests/SpinnerFocusTest.java (original)
+++ pivot/trunk/tests/src/org/apache/pivot/tests/SpinnerFocusTest.java Tue Apr 17 15:42:58 2012
@@ -42,7 +42,7 @@ public class SpinnerFocusTest implements
             @Override
             public void perform(Component source) {
                 String msg = "Selected: " + spinner.getSelectedItem().toString();
-            	Alert.alert(msg, frame);
+                Alert.alert(msg, frame);
 
                 spinner.requestFocus();
                 System.out.println("Focus transferred to spinner");

Modified: pivot/trunk/tests/src/org/apache/pivot/tests/menu_bar_test.bxml
URL: http://svn.apache.org/viewvc/pivot/trunk/tests/src/org/apache/pivot/tests/menu_bar_test.bxml?rev=1327148&r1=1327147&r2=1327148&view=diff
==============================================================================
--- pivot/trunk/tests/src/org/apache/pivot/tests/menu_bar_test.bxml (original)
+++ pivot/trunk/tests/src/org/apache/pivot/tests/menu_bar_test.bxml Tue Apr 17 15:42:58 2012
@@ -161,7 +161,7 @@ limitations under the License.
             <MenuBar.Item buttonData="Help">
                 <Menu>
                     <Menu.Section>
-                        <Menu.Item>
+                        <Menu.Item action="about">
                             <buttonData>
                                 <content:MenuItemData text="About" keyboardShortcut="F1"/>
                             </buttonData>