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/08/13 16:19:21 UTC
svn commit: r1372440 - in
/pivot/branches/2.0.x/tests/src/org/apache/pivot/tests:
JavascriptConsoleTest.java JavascriptConsoleTest.json
javascript_console_test.bxml javascript_console_test.js
javascript_console_test.json
Author: smartini
Date: Mon Aug 13 14:19:20 2012
New Revision: 1372440
URL: http://svn.apache.org/viewvc?rev=1372440&view=rev
Log:
JavaScript Console Test: small updates, to enable the resolution of labels
Added:
pivot/branches/2.0.x/tests/src/org/apache/pivot/tests/JavascriptConsoleTest.json
pivot/branches/2.0.x/tests/src/org/apache/pivot/tests/javascript_console_test.json
Modified:
pivot/branches/2.0.x/tests/src/org/apache/pivot/tests/JavascriptConsoleTest.java
pivot/branches/2.0.x/tests/src/org/apache/pivot/tests/javascript_console_test.bxml
pivot/branches/2.0.x/tests/src/org/apache/pivot/tests/javascript_console_test.js
Modified: pivot/branches/2.0.x/tests/src/org/apache/pivot/tests/JavascriptConsoleTest.java
URL: http://svn.apache.org/viewvc/pivot/branches/2.0.x/tests/src/org/apache/pivot/tests/JavascriptConsoleTest.java?rev=1372440&r1=1372439&r2=1372440&view=diff
==============================================================================
--- pivot/branches/2.0.x/tests/src/org/apache/pivot/tests/JavascriptConsoleTest.java (original)
+++ pivot/branches/2.0.x/tests/src/org/apache/pivot/tests/JavascriptConsoleTest.java Mon Aug 13 14:19:20 2012
@@ -101,7 +101,9 @@ public class JavascriptConsoleTest exten
bxmlSerializer = new BXMLSerializer();
}
- return (Window)bxmlSerializer.readObject(JavascriptConsoleTest.class, fileName);
+ // return (Window)bxmlSerializer.readObject(JavascriptConsoleTest.class, fileName); // ok
+ // better, to allow usage of resources (without having to call setLocation or setResources in the serializer) ...
+ return (Window)bxmlSerializer.readObject(JavascriptConsoleTest.class, fileName, true);
}
/**
@@ -112,12 +114,12 @@ public class JavascriptConsoleTest exten
* <p>
* Note that all Exceptions are catched inside this method, to not expose them to JS code.
*
- * @param url the URL of the bxml file to load
+ * @param urlString the URL of the bxml file to load, as a String
* @param bxmlSerializer the serializer to use, or if null a new one will be created
* @return the Window instance
*/
- public Window loadWindowFromURL(String url, BXMLSerializer bxmlSerializer) {
- logObject("loadWindow from \"" + url + "\", with the serializer " + bxmlSerializer);
+ public Window loadWindowFromURL(String urlString, BXMLSerializer bxmlSerializer) {
+ logObject("loadWindow from \"" + urlString + "\", with the serializer " + bxmlSerializer);
if (bxmlSerializer == null) {
bxmlSerializer = new BXMLSerializer();
@@ -125,7 +127,12 @@ public class JavascriptConsoleTest exten
Window loadedWindow = null;
try {
- loadedWindow = (Window)bxmlSerializer.readObject(new URL(url));
+ URL url = new URL(urlString);
+
+ // force the location, so it will be possible to decode resources like labels ...
+ bxmlSerializer.setLocation(url);
+
+ loadedWindow = (Window)bxmlSerializer.readObject(url);
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
Added: pivot/branches/2.0.x/tests/src/org/apache/pivot/tests/JavascriptConsoleTest.json
URL: http://svn.apache.org/viewvc/pivot/branches/2.0.x/tests/src/org/apache/pivot/tests/JavascriptConsoleTest.json?rev=1372440&view=auto
==============================================================================
--- pivot/branches/2.0.x/tests/src/org/apache/pivot/tests/JavascriptConsoleTest.json (added)
+++ pivot/branches/2.0.x/tests/src/org/apache/pivot/tests/JavascriptConsoleTest.json Mon Aug 13 14:19:20 2012
@@ -0,0 +1,31 @@
+/*
+ * 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.
+ */
+{
+ title: "JavaScript Console Test, from JavascriptConsoleTest.json",
+ labelText: "Hello, from JavascriptConsoleTest.json",
+ labelInfo: "JavaScript (interpreted by the JVM) Console:",
+ labelTemplates: "Templates:",
+ valuesTemplates_0: " - Choose a template - ", // future use
+ valuesTemplates_1: "Open Frame Local", // future use
+ valuesTemplates_2: "Open Frame Remote (from Pivot Web Site)", // future use
+ labelRun: "Run",
+ labelClear: "Clear",
+ labelJSSource: "JS Source:",
+ labelJSOutput: "JS Output:",
+ labelStatus: "Status:",
+ last: ""
+}
Modified: pivot/branches/2.0.x/tests/src/org/apache/pivot/tests/javascript_console_test.bxml
URL: http://svn.apache.org/viewvc/pivot/branches/2.0.x/tests/src/org/apache/pivot/tests/javascript_console_test.bxml?rev=1372440&r1=1372439&r2=1372440&view=diff
==============================================================================
--- pivot/branches/2.0.x/tests/src/org/apache/pivot/tests/javascript_console_test.bxml (original)
+++ pivot/branches/2.0.x/tests/src/org/apache/pivot/tests/javascript_console_test.bxml Mon Aug 13 14:19:20 2012
@@ -17,7 +17,7 @@ limitations under the License.
-->
<Window bxml:id="window"
- title="JavaScript Console Test" maximized="true"
+ title="%title" maximized="true"
xmlns:bxml="http://pivot.apache.org/bxml"
xmlns="org.apache.pivot.wtk"
>
@@ -35,7 +35,7 @@ limitations under the License.
// "file:///D:/work/pivot/site/trunk/deploy/assets-for-tests" + "/"; // local test
// "http://pivot.apache.org/assets-for-tests" + "/"; // production url
"http://pivot.apache.org/assets-for-tests" + "/";
- var frameName =
+ var frameName =
// "frame.bxml"; // the first level bxml
// "palette.bxml"; // the second level bxml (loaded usually be frame.bxml), just to test here directly
"frame.bxml";
@@ -43,6 +43,10 @@ limitations under the License.
// note that bxml files must have the MIME Type "application/bxml" (as requested by BXMLSerializer),
// or (BXMLSerializer) will try to get it from its file extension ...
+ // assign a label value to a JS variable
+ var valueFromLabel = "%labelText"; // note that this doesn't work as expected, must be handled from the bxmlSerializer ...
+ log("valueFromLabel (direct access) = \"" + valueFromLabel + "\"");
+
log("inline script 1 - end");
]]>
</bxml:script>
@@ -104,6 +108,10 @@ limitations under the License.
// note that this call is done in the usual (non-static) way, and works the same even from here
application.logObject(testRemoteFrame);
+ // assign a label value to a JS variable
+ var valueFromLabel = bxmlSerializer.getNamespace().get("labelText"); // ok, getting the label value from the bxmlSerializer ...
+ log("valueFromLabel (access via bxmlSerializer) = \"" + valueFromLabel + "\"");
+
// test 5, TODO
// comment test 4, and copy its source inside the switch statements below (if possible), to make it really dynamic ...
@@ -127,11 +135,11 @@ limitations under the License.
<TablePane.Row height="-1">
<BoxPane orientation="horizontal" TablePane.columnSpan="3">
- <Label styles="{horizontalAlignment:'center', verticalAlignment:'center'}" text="JavaScript (interpreted by the JVM) Console:"
+ <Label styles="{horizontalAlignment:'center', verticalAlignment:'center'}" text="%labelInfo"
/>
<Label text=" " />
- <Label text="Templates:"/>
+ <Label text="%labelTemplates"/>
<ListButton bxml:id="templateButton"
listData="[' - Choose a template - ', 'Open Frame Local', 'Open Frame Remote (from Pivot Web Site)']"
selectedIndex="-1"
@@ -161,14 +169,14 @@ limitations under the License.
clearConsole();
break;
}
- textArea.text = templateText;
+ textJSSource.text = templateText;
}
</listButtonSelectionListeners>
</ListButton>
<Label text=" " />
- <PushButton bxml:id="runButton" buttonData="Run" ButtonPressListener.buttonPressed="runConsole()"/>
- <PushButton bxml:id="clearButton" buttonData="Clear">
+ <PushButton bxml:id="runButton" buttonData="%labelRun" ButtonPressListener.buttonPressed="runConsole()"/>
+ <PushButton bxml:id="clearButton" buttonData="%labelClear">
<buttonPressListeners>
function buttonPressed(button) {
clearConsole();
@@ -178,12 +186,12 @@ limitations under the License.
</BoxPane>
</TablePane.Row>
<TablePane.Row height="1*">
- <Label styles="{horizontalAlignment:'right', verticalAlignment:'center'}" text="JS Source:"/>
+ <Label styles="{horizontalAlignment:'right', verticalAlignment:'center'}" text="%labelJSSource"/>
<Border>
<ScrollPane horizontalScrollBarPolicy="fill" verticalScrollBarPolicy="fill_to_capacity"
preferredHeight="200"
>
- <TextArea bxml:id="textArea"
+ <TextArea bxml:id="textJSSource"
styles="{wrapText:false}"
editable="true"
text=""
@@ -202,8 +210,23 @@ limitations under the License.
</ScrollPane>
</Border>
</TablePane.Row>
+ <TablePane.Row height="1*">
+ <Label styles="{horizontalAlignment:'right', verticalAlignment:'center'}" text="%labelJSOutput"/>
+ <Border>
+ <ScrollPane horizontalScrollBarPolicy="fill" verticalScrollBarPolicy="fill_to_capacity"
+ preferredHeight="100"
+ >
+ <TextArea bxml:id="textJSOutput"
+ styles="{wrapText:false}"
+ editable="false"
+ text=""
+ >
+ </TextArea>
+ </ScrollPane>
+ </Border>
+ </TablePane.Row>
<TablePane.Row height="-1">
- <Label styles="{horizontalAlignment:'right', verticalAlignment:'center'}" text="Status:"/>
+ <Label styles="{horizontalAlignment:'right', verticalAlignment:'center'}" text="%labelStatus"/>
<Label bxml:id="textStatus" styles="{horizontalAlignment:'left', verticalAlignment:'center'}" text=""/>
</TablePane.Row>
</TablePane>
Modified: pivot/branches/2.0.x/tests/src/org/apache/pivot/tests/javascript_console_test.js
URL: http://svn.apache.org/viewvc/pivot/branches/2.0.x/tests/src/org/apache/pivot/tests/javascript_console_test.js?rev=1372440&r1=1372439&r2=1372440&view=diff
==============================================================================
--- pivot/branches/2.0.x/tests/src/org/apache/pivot/tests/javascript_console_test.js (original)
+++ pivot/branches/2.0.x/tests/src/org/apache/pivot/tests/javascript_console_test.js Mon Aug 13 14:19:20 2012
@@ -40,7 +40,8 @@ function clearStatus() {
function clearConsole() {
templateButton.selectedIndex = 0;
- textArea.text = "";
+ textJSSource.text = "";
+ textJSOutput.text = "";
// runButton.enabled = false; // ok
runButton.setEnabled(false); // explicit usage of the setter
log("Console cleared");
@@ -49,7 +50,7 @@ function clearConsole() {
function runConsole() {
- var text = textArea.text;
+ var text = textJSSource.text;
log("Console Text length = " + text.length());
if (text.length() < 1)
return ;
@@ -57,6 +58,7 @@ function runConsole() {
var msg = "Run JS Code in Console";
log(msg);
updateStatus(msg + " ...");
+ textJSOutput.text = "";
// TODO: continue here ...
;
Added: pivot/branches/2.0.x/tests/src/org/apache/pivot/tests/javascript_console_test.json
URL: http://svn.apache.org/viewvc/pivot/branches/2.0.x/tests/src/org/apache/pivot/tests/javascript_console_test.json?rev=1372440&view=auto
==============================================================================
--- pivot/branches/2.0.x/tests/src/org/apache/pivot/tests/javascript_console_test.json (added)
+++ pivot/branches/2.0.x/tests/src/org/apache/pivot/tests/javascript_console_test.json Mon Aug 13 14:19:20 2012
@@ -0,0 +1,22 @@
+/*
+ * 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.
+ */
+{
+ title: "JavaScript Console Test, from javascript_console_test.json",
+ labelText: "Hello, from JavascriptConsoleTest.json",
+ labelInfo: "JavaScript (interpreted by the JVM) Console:",
+ last: ""
+}