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 2010/07/28 14:23:18 UTC
svn commit: r980034 - in /pivot/trunk/examples: ./
src/org/apache/pivot/examples/scripting/
Author: gbrown
Date: Wed Jul 28 12:23:18 2010
New Revision: 980034
URL: http://svn.apache.org/viewvc?rev=980034&view=rev
Log:
Add example of using Scala with Pivot; minor updates to Groovy and JavaScript examples.
Added:
pivot/trunk/examples/src/org/apache/pivot/examples/scripting/ScalaWindow.scala
pivot/trunk/examples/src/org/apache/pivot/examples/scripting/scala_window.bxml
Modified:
pivot/trunk/examples/.classpath
pivot/trunk/examples/.project
pivot/trunk/examples/src/org/apache/pivot/examples/scripting/groovy_window.bxml
pivot/trunk/examples/src/org/apache/pivot/examples/scripting/javascript_window.bxml
Modified: pivot/trunk/examples/.classpath
URL: http://svn.apache.org/viewvc/pivot/trunk/examples/.classpath?rev=980034&r1=980033&r2=980034&view=diff
==============================================================================
--- pivot/trunk/examples/.classpath (original)
+++ pivot/trunk/examples/.classpath Wed Jul 28 12:23:18 2010
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
+ <classpathentry kind="con" path="ch.epfl.lamp.sdt.launching.SCALA_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry combineaccessrules="false" kind="src" path="/core"/>
<classpathentry combineaccessrules="false" kind="src" path="/web"/>
Modified: pivot/trunk/examples/.project
URL: http://svn.apache.org/viewvc/pivot/trunk/examples/.project?rev=980034&r1=980033&r2=980034&view=diff
==============================================================================
--- pivot/trunk/examples/.project (original)
+++ pivot/trunk/examples/.project Wed Jul 28 12:23:18 2010
@@ -6,12 +6,13 @@
</projects>
<buildSpec>
<buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
+ <name>ch.epfl.lamp.sdt.core.scalabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
+ <nature>ch.epfl.lamp.sdt.core.scalanature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
Added: pivot/trunk/examples/src/org/apache/pivot/examples/scripting/ScalaWindow.scala
URL: http://svn.apache.org/viewvc/pivot/trunk/examples/src/org/apache/pivot/examples/scripting/ScalaWindow.scala?rev=980034&view=auto
==============================================================================
--- pivot/trunk/examples/src/org/apache/pivot/examples/scripting/ScalaWindow.scala (added)
+++ pivot/trunk/examples/src/org/apache/pivot/examples/scripting/ScalaWindow.scala Wed Jul 28 12:23:18 2010
@@ -0,0 +1,53 @@
+/*
+ * 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.scripting;
+
+import java.net.URL;
+
+import org.apache.pivot.beans.Bindable;
+import org.apache.pivot.collections.Map;
+import org.apache.pivot.util.Resources;
+import org.apache.pivot.wtk.Alert;
+import org.apache.pivot.wtk.Button;
+import org.apache.pivot.wtk.ButtonPressListener;
+import org.apache.pivot.wtk.Display;
+import org.apache.pivot.wtk.PushButton;
+import org.apache.pivot.wtk.Window;
+
+class ScalaWindow extends Window with Bindable {
+ private var sayHelloButton:PushButton = null;
+
+ override def initialize(namespace: Map[String, Object], location:URL, resources:Resources) {
+ sayHelloButton = namespace.get("sayHelloButton").asInstanceOf[PushButton];
+
+ sayHelloButton.getButtonPressListeners().add(new ButtonPressListener {
+ override def buttonPressed(button:Button) {
+ sayHello();
+ }
+ });
+ }
+
+ override def open(display:Display, owner:Window) {
+ super.open(display, owner);
+
+ sayHelloButton.requestFocus();
+ }
+
+ private def sayHello() {
+ Alert.alert("Hello from Scala!", this);
+ }
+}
Modified: pivot/trunk/examples/src/org/apache/pivot/examples/scripting/groovy_window.bxml
URL: http://svn.apache.org/viewvc/pivot/trunk/examples/src/org/apache/pivot/examples/scripting/groovy_window.bxml?rev=980034&r1=980033&r2=980034&view=diff
==============================================================================
--- pivot/trunk/examples/src/org/apache/pivot/examples/scripting/groovy_window.bxml (original)
+++ pivot/trunk/examples/src/org/apache/pivot/examples/scripting/groovy_window.bxml Wed Jul 28 12:23:18 2010
@@ -21,17 +21,21 @@ limitations under the License.
xmlns:bxml="http://pivot.apache.org/bxml"
xmlns="org.apache.pivot.wtk">
<bxml:script>
+ <![CDATA[
import org.apache.pivot.wtk.*
sayHello = {
Alert.alert("Hello from Groovy!", window)
}
+ ]]>
</bxml:script>
<windowStateListeners>
+ <![CDATA[
windowOpened = {
sayHelloButton.requestFocus()
}
+ ]]>
</windowStateListeners>
<BoxPane orientation="vertical"
Modified: pivot/trunk/examples/src/org/apache/pivot/examples/scripting/javascript_window.bxml
URL: http://svn.apache.org/viewvc/pivot/trunk/examples/src/org/apache/pivot/examples/scripting/javascript_window.bxml?rev=980034&r1=980033&r2=980034&view=diff
==============================================================================
--- pivot/trunk/examples/src/org/apache/pivot/examples/scripting/javascript_window.bxml (original)
+++ pivot/trunk/examples/src/org/apache/pivot/examples/scripting/javascript_window.bxml Wed Jul 28 12:23:18 2010
@@ -20,23 +20,27 @@ limitations under the License.
xmlns:bxml="http://pivot.apache.org/bxml"
xmlns="org.apache.pivot.wtk">
<bxml:script>
+ <![CDATA[
importPackage(org.apache.pivot.wtk);
function sayHello() {
- Alert.alert("Hello from JavaScript!", window)
+ Alert.alert("Hello from JavaScript!", window);
}
+ ]]>
</bxml:script>
<windowStateListeners>
- function windowOpened {
- sayHelloButton.requestFocus()
+ <![CDATA[
+ function windowOpened() {
+ sayHelloButton.requestFocus();
}
+ ]]>
</windowStateListeners>
<BoxPane orientation="vertical"
styles="{horizontalAlignment:'center', verticalAlignment:'center'}">
<Label text="This is a JavaScript window."/>
- <PushButton buttonData="Say Hello">
+ <PushButton bxml:id="sayHelloButton" buttonData="Say Hello">
<buttonPressListeners>
<![CDATA[
function buttonPressed() {
Added: pivot/trunk/examples/src/org/apache/pivot/examples/scripting/scala_window.bxml
URL: http://svn.apache.org/viewvc/pivot/trunk/examples/src/org/apache/pivot/examples/scripting/scala_window.bxml?rev=980034&view=auto
==============================================================================
--- pivot/trunk/examples/src/org/apache/pivot/examples/scripting/scala_window.bxml (added)
+++ pivot/trunk/examples/src/org/apache/pivot/examples/scripting/scala_window.bxml Wed Jul 28 12:23:18 2010
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+
+<scripting:ScalaWindow title="Scala Window" maximized="true"
+ xmlns:bxml="http://pivot.apache.org/bxml"
+ xmlns:scripting="org.apache.pivot.examples.scripting"
+ xmlns="org.apache.pivot.wtk">
+ <BoxPane orientation="vertical"
+ styles="{horizontalAlignment:'center', verticalAlignment:'center'}">
+ <Label text="This is a Scala window."/>
+ <PushButton bxml:id="sayHelloButton" buttonData="Say Hello"/>
+ </BoxPane>
+</scripting:ScalaWindow>