Author: rwhitcomb
Date: Mon May 15 21:09:49 2017
New Revision: 1795242

URL: http://svn.apache.org/viewvc?rev=1795242&view=rev
Log:
Extend the ScriptApplication program to be able to display BXML files
that don't have a Window (or a subclass of it) as the outermost component
by creating a default Window in that case and making the BXML component
its content.

Update one of the TextInput tests with one other example for testing.

Modified:
    pivot/trunk/tests/src/org/apache/pivot/tests/text_input_test.bxml
    pivot/trunk/wtk/src/org/apache/pivot/wtk/ScriptApplication.java

Modified: pivot/trunk/tests/src/org/apache/pivot/tests/text_input_test.bxml
URL: 
http://svn.apache.org/viewvc/pivot/trunk/tests/src/org/apache/pivot/tests/text_input_test.bxml?rev=1795242&r1=1795241&r2=1795242&view=diff
==============================================================================
--- pivot/trunk/tests/src/org/apache/pivot/tests/text_input_test.bxml (original)
+++ pivot/trunk/tests/src/org/apache/pivot/tests/text_input_test.bxml Mon May 
15 21:09:49 2017
@@ -23,6 +23,7 @@ limitations under the License.
         <TextInput text="ABCD 1234 abcd 5678 EFGH 90" textSize="6"/>
         <TextInput text="abcd 5678"/>
         <TextInput prompt="Type something!"/>
+        <TextInput password="true" prompt="[Password]"/>
         <TextInput/>
     </BoxPane>
 </Window>

Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/ScriptApplication.java
URL: 
http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/ScriptApplication.java?rev=1795242&r1=1795241&r2=1795242&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/ScriptApplication.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/ScriptApplication.java Mon May 15 
21:09:49 2017
@@ -26,6 +26,11 @@ import org.apache.pivot.util.Resources;
 
 /**
  * Script application loader.
+ * <p> This application will load a BXML file containing a Pivot component
+ * and its content hierarchy and display it.  If the outermost component is
+ * a {@link Window} (or subclass of it) then the window will be displayed
+ * directly.  Otherwise a default {@code Window} will be created and the
+ * component made its content.
  */
 public class ScriptApplication implements Application {
     private Window window = null;
@@ -79,7 +84,13 @@ public class ScriptApplication implement
 
         // Load the file and open the window
         BXMLSerializer bxmlSerializer = new BXMLSerializer();
-        this.window = (Window) bxmlSerializer.readObject(location, resources);
+        Component component = (Component) bxmlSerializer.readObject(location, 
resources);
+        if (component instanceof Window) {
+            this.window = (Window)component;
+        } else {
+            this.window = new Window();
+            this.window.setContent(component);
+        }
         this.window.open(display);
     }
 


Reply via email to