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/28 15:21:39 UTC
svn commit: r819528 - in /incubator/pivot/trunk:
tutorials/src/org/apache/pivot/tutorials/clipboard/clipboard.wtkx
wtk/src/org/apache/pivot/wtkx/WTKXSerializer.java
Author: gbrown
Date: Mon Sep 28 13:21:38 2009
New Revision: 819528
URL: http://svn.apache.org/viewvc?rev=819528&view=rev
Log:
Revert change that adds instance value to named objects in start tag; improve debug output support in WTKXSerializer.
Modified:
incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/clipboard/clipboard.wtkx
incubator/pivot/trunk/wtk/src/org/apache/pivot/wtkx/WTKXSerializer.java
Modified: incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/clipboard/clipboard.wtkx
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/clipboard/clipboard.wtkx?rev=819528&r1=819527&r2=819528&view=diff
==============================================================================
--- incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/clipboard/clipboard.wtkx (original)
+++ incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/clipboard/clipboard.wtkx Mon Sep 28 13:21:38 2009
@@ -35,7 +35,7 @@
</columns>
<rows>
<TablePane.Row height="1*">
- <CardPane wtkx:id="copyImageCardPane">
+ <CardPane wtkx:id="copyImageCardPane" styles="{padding:4}">
<ImageView image="org/apache/pivot/tutorials/IMG_0725_2.jpg"/>
<ImageView image="org/apache/pivot/tutorials/IMG_0735_2.jpg"/>
<ImageView image="org/apache/pivot/tutorials/IMG_0767_2.jpg"/>
@@ -51,8 +51,11 @@
<wtkx:script>
<![CDATA[
function selectionChanged(buttonGroup, previousSelection) {
- var index = copyImageButtonBoxPane.indexOf(buttonGroup.getSelection());
- copyImageCardPane.setSelectedIndex(index);
+ var selection = buttonGroup.getSelection();
+ if (selection != null) {
+ var index = copyImageButtonBoxPane.indexOf(buttonGroup.getSelection());
+ copyImageCardPane.setSelectedIndex(index);
+ }
}
]]>
</wtkx:script>
@@ -61,13 +64,19 @@
</wtkx:define>
<PushButton buttonData="IMG_0725_2.jpg" toggleButton="true"
- buttonGroup="$copyImageButtonGroup" selected="true"/>
+ buttonGroup="$copyImageButtonGroup"/>
<PushButton buttonData="IMG_0735_2.jpg" toggleButton="true"
buttonGroup="$copyImageButtonGroup"/>
<PushButton buttonData="IMG_0767_2.jpg" toggleButton="true"
buttonGroup="$copyImageButtonGroup"/>
</BoxPane>
+ <wtkx:script>
+ <![CDATA[
+ copyImageButtonGroup.setSelection(copyImageButtonBoxPane.get(0));
+ ]]>
+ </wtkx:script>
+
<BoxPane styles="{horizontalAlignment:'center'}">
<PushButton wtkx:id="copyButton" buttonData="Copy"/>
</BoxPane>
@@ -85,7 +94,9 @@
</columns>
<rows>
<TablePane.Row height="1*">
- <ImageView wtkx:id="pasteImageView"/>
+ <BoxPane styles="{padding:4}">
+ <ImageView wtkx:id="pasteImageView"/>
+ </BoxPane>
</TablePane.Row>
<TablePane.Row height="-1">
<BoxPane styles="{horizontalAlignment:'center'}">
Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtkx/WTKXSerializer.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtkx/WTKXSerializer.java?rev=819528&r1=819527&r2=819528&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtkx/WTKXSerializer.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtkx/WTKXSerializer.java Mon Sep 28 13:21:38 2009
@@ -210,14 +210,19 @@
throws Throwable {
Object result = null;
- String methodName = method.getName();
- if (methodName.equals(event)) {
- try {
- scriptEngine.eval(script);
- } catch (ScriptException exception) {
- System.err.println(exception);
- System.err.println(script);
+ try {
+ String methodName = method.getName();
+ if (methodName.equals(event)) {
+ try {
+ scriptEngine.eval(script);
+ } catch (ScriptException exception) {
+ System.err.println(exception);
+ System.err.println(script);
+ }
}
+ } catch (Throwable throwable) {
+ throwable.printStackTrace();
+ throw throwable;
}
// If the function didn't return a value, return the default
@@ -246,17 +251,22 @@
throws Throwable {
Object result = null;
- String methodName = method.getName();
- Bindings bindings = scriptEngine.getBindings(ScriptContext.ENGINE_SCOPE);
- if (bindings.containsKey(methodName)) {
- Invocable invocable;
- try {
- invocable = (Invocable)scriptEngine;
- } catch (ClassCastException exception) {
- throw new SerializationException(exception);
- }
+ try {
+ String methodName = method.getName();
+ Bindings bindings = scriptEngine.getBindings(ScriptContext.ENGINE_SCOPE);
+ if (bindings.containsKey(methodName)) {
+ Invocable invocable;
+ try {
+ invocable = (Invocable)scriptEngine;
+ } catch (ClassCastException exception) {
+ throw new SerializationException(exception);
+ }
- result = invocable.invokeFunction(methodName, args);
+ result = invocable.invokeFunction(methodName, args);
+ }
+ } catch (Throwable throwable) {
+ throwable.printStackTrace();
+ throw throwable;
}
// If the function didn't return a value, return the default
@@ -521,9 +531,14 @@
if (attributePrefix != null
&& attributePrefix.equals(WTKX_PREFIX)) {
if (attributeLocalName.equals(ID_ATTRIBUTE)) {
+ if (attributeValue.length() == 0) {
+ throw new IllegalArgumentException(WTKX_PREFIX + ":" + ID_ATTRIBUTE
+ + " must not be empty.");
+ }
+
id = attributeValue;
} else {
- throw new SerializationException(attributePrefix + ":" + attributeLocalName
+ throw new SerializationException(WTKX_PREFIX + ":" + attributeLocalName
+ " is not a valid attribute.");
}
} else {
@@ -578,12 +593,6 @@
Class<?> type = Class.forName(className);
elementType = Element.Type.INSTANCE;
value = type.newInstance();
-
- // Add the value to the named objects map here so it is available to
- // sub-elements (rather than waiting until the close tag)
- if (id != null) {
- namedObjects.put(id, value);
- }
} catch (Exception exception) {
throw new SerializationException(exception);
}
@@ -704,6 +713,11 @@
}
}
+ // Add the value to the named objects map
+ if (element.id != null) {
+ namedObjects.put(element.id, element.value);
+ }
+
// Apply instance attributes
Dictionary<String, Object> dictionary;
if (element.value instanceof Dictionary<?, ?>) {
@@ -938,7 +952,7 @@
scriptReader = new BufferedReader(new InputStreamReader(scriptLocation.openStream()));
scriptEngine.eval(scriptReader);
} catch(ScriptException exception) {
- exception.printStackTrace(System.err);
+ exception.printStackTrace();
} finally {
if (scriptReader != null) {
scriptReader.close();
@@ -958,11 +972,13 @@
scriptEngine.setBindings(bindings, ScriptContext.ENGINE_SCOPE);
- if (element.value != null) {
+ String script = (String)element.value;
+ if (script != null) {
try {
- scriptEngine.eval((String)element.value);
+ scriptEngine.eval(script);
} catch (ScriptException exception) {
- exception.printStackTrace(System.err);
+ System.err.println(exception);
+ System.err.println(script);
}
}
}