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/09 22:28:08 UTC

svn commit: r962684 - in /pivot/trunk: core/src/org/apache/pivot/beans/ demos/src/org/apache/pivot/demos/displays/ demos/src/org/apache/pivot/demos/itunes/ demos/src/org/apache/pivot/demos/json/ demos/src/org/apache/pivot/demos/xml/ examples/src/org/ap...

Author: gbrown
Date: Fri Jul  9 20:28:07 2010
New Revision: 962684

URL: http://svn.apache.org/viewvc?rev=962684&view=rev
Log:
Revert change that deferred all reference resolution - only defer namespace binding; update script code in various examples to use new simplified listener declarations.


Modified:
    pivot/trunk/core/src/org/apache/pivot/beans/BXMLSerializer.java
    pivot/trunk/demos/src/org/apache/pivot/demos/displays/multiple_display_demo.bxml
    pivot/trunk/demos/src/org/apache/pivot/demos/itunes/search_demo.bxml
    pivot/trunk/demos/src/org/apache/pivot/demos/json/json_viewer.bxml
    pivot/trunk/demos/src/org/apache/pivot/demos/xml/xml_viewer.bxml
    pivot/trunk/examples/src/org/apache/pivot/examples/keyboard/component_key_listener_example.bxml
    pivot/trunk/tutorials/src/org/apache/pivot/tutorials/scripting/scripting.bxml

Modified: pivot/trunk/core/src/org/apache/pivot/beans/BXMLSerializer.java
URL: http://svn.apache.org/viewvc/pivot/trunk/core/src/org/apache/pivot/beans/BXMLSerializer.java?rev=962684&r1=962683&r2=962684&view=diff
==============================================================================
--- pivot/trunk/core/src/org/apache/pivot/beans/BXMLSerializer.java (original)
+++ pivot/trunk/core/src/org/apache/pivot/beans/BXMLSerializer.java Fri Jul  9 20:28:07 2010
@@ -207,10 +207,11 @@ public class BXMLSerializer implements S
 
     private XMLStreamReader xmlStreamReader = null;
     private Element element = null;
-    private LinkedList<Attribute> objectReferenceAttributes = new LinkedList<Attribute>();
 
     private Object root = null;
 
+    private LinkedList<Attribute> namespaceBindingAttributes = new LinkedList<Attribute>();
+
     private static HashMap<String, String> fileExtensions = new HashMap<String, String>();
     private static HashMap<String, Class<? extends Serializer<?>>> mimeTypes =
         new HashMap<String, Class<? extends Serializer<?>>>();
@@ -218,8 +219,9 @@ public class BXMLSerializer implements S
     public static final char URL_PREFIX = '@';
     public static final char RESOURCE_KEY_PREFIX = '%';
     public static final char OBJECT_REFERENCE_PREFIX = '$';
-    public static final char NAMESPACE_BINDING_PREFIX = '{';
-    public static final char NAMESPACE_BINDING_SUFFIX = '}';
+
+    public static final String NAMESPACE_BINDING_PREFIX = OBJECT_REFERENCE_PREFIX + "{";
+    public static final String NAMESPACE_BINDING_SUFFIX = "}";
 
     public static final String LANGUAGE_PROCESSING_INSTRUCTION = "language";
 
@@ -360,7 +362,6 @@ public class BXMLSerializer implements S
     }
 
     @Override
-    @SuppressWarnings("unchecked")
     public Object readObject(InputStream inputStream)
         throws IOException, SerializationException {
         if (inputStream == null) {
@@ -416,66 +417,42 @@ public class BXMLSerializer implements S
 
         xmlStreamReader = null;
 
-        // Resolve object references
-        for (Attribute attribute : objectReferenceAttributes) {
+        // Apply the namespace bindings
+        for (Attribute attribute : namespaceBindingAttributes) {
             Element element = attribute.element;
-            String reference = (String)attribute.value;
-
-            if (reference.startsWith(Character.toString(NAMESPACE_BINDING_PREFIX))
-                && reference.endsWith(Character.toString(NAMESPACE_BINDING_SUFFIX))) {
-                reference = reference.substring(1, reference.length() - 1);
-
-                switch (element.type) {
-                    case INSTANCE:
-                    case INCLUDE: {
-                        // Bind to <element ID>.<attribute name>
-                        if (element.id == null) {
-                            throw new SerializationException("Bind target does not have an ID.");
-                        }
-
-                        String targetPath = element.id + "." + attribute.name;
-                        NamespaceBinding namespaceBinding = new NamespaceBinding(namespace, reference, targetPath);
-                        namespaceBinding.bind();
+            String sourcePath = (String)attribute.value;
 
-                        break;
+            switch (element.type) {
+                case INSTANCE:
+                case INCLUDE: {
+                    // Bind to <element ID>.<attribute name>
+                    if (element.id == null) {
+                        throw new SerializationException("Bind target does not have an ID.");
                     }
 
-                    case READ_ONLY_PROPERTY: {
-                        // Bind to <parent element ID>.<element name>.<attribute name>
-                        if (element.parent.id == null) {
-                            throw new SerializationException("Bind target does not have an ID.");
-                        }
-
-                        String targetPath = element.parent.id + "." + element.name + "." + attribute.name;
-                        NamespaceBinding namespaceBinding = new NamespaceBinding(namespace, reference, targetPath);
-                        namespaceBinding.bind();
+                    String targetPath = element.id + "." + attribute.name;
+                    NamespaceBinding namespaceBinding = new NamespaceBinding(namespace, sourcePath, targetPath);
+                    namespaceBinding.bind();
 
-                        break;
-                    }
-                }
-            } else {
-                if (!JSON.containsKey(namespace, reference)) {
-                    throw new SerializationException("Value \"" + reference + "\" does not exist.");
+                    break;
                 }
 
-                Object value = JSON.get(namespace, reference);
-
-                if (attribute.propertyClass == null) {
-                    Dictionary<String, Object> dictionary;
-                    if (element.value instanceof Dictionary<?, ?>) {
-                        dictionary = (Dictionary<String, Object>)element.value;
-                    } else {
-                        dictionary = new BeanAdapter(element.value);
+                case READ_ONLY_PROPERTY: {
+                    // Bind to <parent element ID>.<element name>.<attribute name>
+                    if (element.parent.id == null) {
+                        throw new SerializationException("Bind target does not have an ID.");
                     }
 
-                    dictionary.put(attribute.name, value);
-                } else {
-                    setStaticProperty(element.value, attribute.propertyClass, attribute.name, value);
+                    String targetPath = element.parent.id + "." + element.name + "." + attribute.name;
+                    NamespaceBinding namespaceBinding = new NamespaceBinding(namespace, sourcePath, targetPath);
+                    namespaceBinding.bind();
+
+                    break;
                 }
             }
         }
 
-        objectReferenceAttributes.clear();
+        namespaceBindingAttributes.clear();
 
         // Bind the root to the namespace
         if (root instanceof Bindable) {
@@ -571,10 +548,52 @@ public class BXMLSerializer implements S
                     break;
                 }
 
-                case SCRIPT:
-                case WRITABLE_PROPERTY: {
-                    // TODO Also do this for read-only properties, so we can handle inline
-                    // script?
+                case READ_ONLY_PROPERTY: {
+                    if (element.value instanceof ListenerList<?>) {
+                        // Get a script engine for the current language; apply simple bindings
+                        // so the engine namespace isn't polluted with the listener functions
+                        ScriptEngine scriptEngine = scriptEngineManager.getEngineByName(language);
+                        scriptEngine.setBindings(new SimpleBindings(), ScriptContext.ENGINE_SCOPE);
+
+                        try {
+                            scriptEngine.eval(text);
+                        } catch (ScriptException exception) {
+                            System.err.println(exception);
+                            break;
+                        }
+
+                        // Create the listener and add it to the list
+                        Class<?> listenerListClass = element.value.getClass();
+
+                        java.lang.reflect.Type[] genericInterfaces = listenerListClass.getGenericInterfaces();
+                        Class<?> listenerClass = (Class<?>)genericInterfaces[0];
+
+                        ElementInvocationHandler handler = new ElementInvocationHandler(scriptEngine);
+
+                        Method addMethod;
+                        try {
+                            addMethod = listenerListClass.getMethod("add", Object.class);
+                        } catch (NoSuchMethodException exception) {
+                            throw new RuntimeException(exception);
+                        }
+
+                        Object listener = Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(),
+                            new Class<?>[]{listenerClass}, handler);
+
+                        try {
+                            addMethod.invoke(element.value, listener);
+                        } catch (IllegalAccessException exception) {
+                            throw new SerializationException(exception);
+                        } catch (InvocationTargetException exception) {
+                            throw new SerializationException(exception);
+                        }
+                    }
+
+                    break;
+                }
+
+                case WRITABLE_PROPERTY:
+                case SCRIPT: {
                     element.value = text;
                     break;
                 }
@@ -867,81 +886,79 @@ public class BXMLSerializer implements S
                         name = localName;
                     }
 
-                    // Resolve the attribute value
-                    Attribute attribute = new Attribute(element, name, propertyClass, value);
-                    boolean resolved = true;
-
-                    if (value.length() > 0) {
-                        if (value.charAt(0) == URL_PREFIX) {
-                            value = value.substring(1);
-
-                            if (value.length() > 0) {
-                                if (value.charAt(0) == URL_PREFIX) {
-                                    attribute.value = value;
-                                } else {
-                                    if (location == null) {
-                                        throw new IllegalStateException("Base location is undefined.");
-                                    }
-
-                                    try {
-                                        attribute.value = new URL(location, value);
-                                    } catch (MalformedURLException exception) {
-                                        throw new SerializationException(exception);
-                                    }
-                                }
-                            } else {
-                                throw new SerializationException("Invalid URL resolution argument.");
-                            }
-                        } else if (value.charAt(0) == RESOURCE_KEY_PREFIX) {
-                            value = value.substring(1);
+                    if (value.startsWith(NAMESPACE_BINDING_PREFIX)
+                        && value.endsWith(NAMESPACE_BINDING_SUFFIX)) {
+                        // The attribute represents a namespace binding
+                        if (propertyClass != null) {
+                            throw new SerializationException("Namespace binding is not supported for static properties.");
+                        }
 
-                            if (value.length() > 0) {
-                                if (value.charAt(0) == RESOURCE_KEY_PREFIX) {
-                                    attribute.value = value;
-                                } else {
-                                    if (resources == null) {
-                                        throw new IllegalStateException("Resource bundle is undefined.");
-                                    }
+                        namespaceBindingAttributes.add(new Attribute(element, name, propertyClass,
+                            value.substring(2, value.length() - 1)));
+                    } else {
+                        // Resolve the attribute value
+                        Attribute attribute = new Attribute(element, name, propertyClass, value);
 
-                                    attribute.value = JSON.get(resources, value);
+                        if (value.length() > 0) {
+                            if (value.charAt(0) == URL_PREFIX) {
+                                value = value.substring(1);
 
-                                    if (attribute.value == null) {
+                                if (value.length() > 0) {
+                                    if (value.charAt(0) == URL_PREFIX) {
                                         attribute.value = value;
+                                    } else {
+                                        if (location == null) {
+                                            throw new IllegalStateException("Base location is undefined.");
+                                        }
+
+                                        try {
+                                            attribute.value = new URL(location, value);
+                                        } catch (MalformedURLException exception) {
+                                            throw new SerializationException(exception);
+                                        }
                                     }
+                                } else {
+                                    throw new SerializationException("Invalid URL resolution argument.");
                                 }
-                            } else {
-                                throw new SerializationException("Invalid resource resolution argument.");
-                            }
-                        } else if (value.charAt(0) == OBJECT_REFERENCE_PREFIX) {
-                            value = value.substring(1);
+                            } else if (value.charAt(0) == RESOURCE_KEY_PREFIX) {
+                                value = value.substring(1);
 
-                            if (value.length() > 0) {
-                                if (value.charAt(0) == OBJECT_REFERENCE_PREFIX) {
-                                    attribute.value = value;
-                                } else {
-                                    if (attribute.propertyClass != null) {
-                                        if (attribute.propertyClass.isInterface()) {
-                                            throw new SerializationException("An object reference is not valid in this context.");
+                                if (value.length() > 0) {
+                                    if (value.charAt(0) == RESOURCE_KEY_PREFIX) {
+                                        attribute.value = value;
+                                    } else {
+                                        if (resources == null) {
+                                            throw new IllegalStateException("Resource bundle is undefined.");
                                         }
 
-                                        if (value.startsWith(Character.toString(NAMESPACE_BINDING_PREFIX))
-                                            && value.endsWith(Character.toString(NAMESPACE_BINDING_SUFFIX))) {
-                                            throw new SerializationException("Cannot bind to a static property.");
+                                        attribute.value = JSON.get(resources, value);
+
+                                        if (attribute.value == null) {
+                                            attribute.value = value;
                                         }
                                     }
+                                } else {
+                                    throw new SerializationException("Invalid resource resolution argument.");
+                                }
+                            } else if (value.charAt(0) == OBJECT_REFERENCE_PREFIX) {
+                                value = value.substring(1);
+
+                                if (value.length() > 0) {
+                                    if (value.charAt(0) == OBJECT_REFERENCE_PREFIX) {
+                                        attribute.value = value;
+                                    } else {
+                                        if (!JSON.containsKey(namespace, value)) {
+                                            throw new SerializationException("Value \"" + value + "\" is not defined.");
+                                        }
 
-                                    attribute.value = value;
-                                    objectReferenceAttributes.add(attribute);
-                                    resolved = false;
+                                        attribute.value = JSON.get(namespace, value);
+                                    }
+                                } else {
+                                    throw new SerializationException("Invalid object resolution argument.");
                                 }
-                            } else {
-                                throw new SerializationException("Invalid object resolution argument.");
                             }
                         }
-                    }
 
-                    // If the value was resolved, add it to the element's attribute list
-                    if (resolved) {
                         element.attributes.add(attribute);
                     }
                 }
@@ -1065,23 +1082,23 @@ public class BXMLSerializer implements S
             }
 
             case READ_ONLY_PROPERTY: {
-                // TODO If this is a listener list, handle inline script
+                if (!(element.value instanceof ListenerList<?>)) {
+                    Dictionary<String, Object> dictionary;
+                    if (element.value instanceof Dictionary<?, ?>) {
+                        dictionary = (Dictionary<String, Object>)element.value;
+                    } else {
+                        dictionary = new BeanAdapter(element.value);
+                    }
 
-                Dictionary<String, Object> dictionary;
-                if (element.value instanceof Dictionary<?, ?>) {
-                    dictionary = (Dictionary<String, Object>)element.value;
-                } else {
-                    dictionary = new BeanAdapter(element.value);
-                }
+                    // Process attributes looking for instance property setters
+                    for (Attribute attribute : element.attributes) {
+                        if (attribute.propertyClass != null) {
+                            throw new SerializationException("Static setters are not supported"
+                                + " for read-only properties.");
+                        }
 
-                // Process attributes looking for instance property setters
-                for (Attribute attribute : element.attributes) {
-                    if (attribute.propertyClass != null) {
-                        throw new SerializationException("Static setters are not supported"
-                            + " for read-only properties.");
+                        dictionary.put(attribute.name, attribute.value);
                     }
-
-                    dictionary.put(attribute.name, attribute.value);
                 }
 
                 break;

Modified: pivot/trunk/demos/src/org/apache/pivot/demos/displays/multiple_display_demo.bxml
URL: http://svn.apache.org/viewvc/pivot/trunk/demos/src/org/apache/pivot/demos/displays/multiple_display_demo.bxml?rev=962684&r1=962683&r2=962684&view=diff
==============================================================================
--- pivot/trunk/demos/src/org/apache/pivot/demos/displays/multiple_display_demo.bxml (original)
+++ pivot/trunk/demos/src/org/apache/pivot/demos/displays/multiple_display_demo.bxml Fri Jul  9 20:28:07 2010
@@ -25,20 +25,16 @@ limitations under the License.
                 <Label text="I am a secondary display!"/>
                 <PushButton buttonData="Close">
                     <buttonPressListeners>
-                        <bxml:script>
-                        function buttonPressed(button) {
-                            button.display.hostWindow.dispose();
-                        }
-                        </bxml:script>
+                    function buttonPressed(button) {
+                        button.display.hostWindow.dispose();
+                    }
                     </buttonPressListeners>
                 </PushButton>
                 <PushButton buttonData="Set Title">
                     <buttonPressListeners>
-                        <bxml:script>
-                        function buttonPressed(button) {
-                            secondaryDisplayWindow.title = "New Secondary Window Title";
-                        }
-                        </bxml:script>
+                    function buttonPressed(button) {
+                        secondaryDisplayWindow.title = "New Secondary Window Title";
+                    }
                     </buttonPressListeners>
                 </PushButton>
             </BoxPane>
@@ -48,32 +44,28 @@ limitations under the License.
     <BoxPane orientation="vertical" styles="{padding:8}">
         <PushButton buttonData="Open Secondary Display">
             <buttonPressListeners>
-                <bxml:script>
-                importClass(org.apache.pivot.wtk.DesktopApplicationContext);
+            importClass(org.apache.pivot.wtk.DesktopApplicationContext);
 
-                function buttonPressed(button) {
-                    var display = DesktopApplicationContext.createDisplay(640, 480, 100, 100, true,
-                        true, false, button.getDisplay().getHostWindow(),
-                        new DesktopApplicationContext.DisplayListener() {
-                            hostWindowOpened: function(display) {
-                                secondaryDisplayWindow.open(display);
-                            },
+            function buttonPressed(button) {
+                var display = DesktopApplicationContext.createDisplay(640, 480, 100, 100, true,
+                    true, false, button.getDisplay().getHostWindow(),
+                    new DesktopApplicationContext.DisplayListener() {
+                        hostWindowOpened: function(display) {
+                            secondaryDisplayWindow.open(display);
+                        },
 
-                            hostWindowClosed: function(display) {
-                                secondaryDisplayWindow.close();
-                            }
-                        });
-                }
-                </bxml:script>
+                        hostWindowClosed: function(display) {
+                            secondaryDisplayWindow.close();
+                        }
+                    });
+            }
             </buttonPressListeners>
         </PushButton>
         <PushButton buttonData="Set Title">
             <buttonPressListeners>
-                <bxml:script>
-                function buttonPressed(button) {
-                    primaryDisplayWindow.title = "New Primary Window Title";
-                }
-                </bxml:script>
+            function buttonPressed(button) {
+                primaryDisplayWindow.title = "New Primary Window Title";
+            }
             </buttonPressListeners>
         </PushButton>
     </BoxPane>

Modified: pivot/trunk/demos/src/org/apache/pivot/demos/itunes/search_demo.bxml
URL: http://svn.apache.org/viewvc/pivot/trunk/demos/src/org/apache/pivot/demos/itunes/search_demo.bxml?rev=962684&r1=962683&r2=962684&view=diff
==============================================================================
--- pivot/trunk/demos/src/org/apache/pivot/demos/itunes/search_demo.bxml (original)
+++ pivot/trunk/demos/src/org/apache/pivot/demos/itunes/search_demo.bxml Fri Jul  9 20:28:07 2010
@@ -37,65 +37,60 @@ limitations under the License.
                         <BoxPane styles="{verticalAlignment:'center'}">
                             <TextInput textSize="18" bxml:id="termTextInput">
                                 <componentKeyListeners>
-                                    <bxml:script>
-                                    <![CDATA[
-                                    importPackage(org.apache.pivot.wtk);
-                                    function keyPressed(component, keyCode, keyLocation) {
-                                        var term = termTextInput.getText();
-
-                                        if (keyCode == Keyboard.KeyCode.ENTER) {
-                                            if (!application.isQueryExecuting()
-                                                && term.length() > 0) {
-                                                searchButton.press();
-                                            }
+                                <![CDATA[
+                                importPackage(org.apache.pivot.wtk);
+                                function keyPressed(component, keyCode, keyLocation) {
+                                    var term = termTextInput.getText();
+
+                                    if (keyCode == Keyboard.KeyCode.ENTER) {
+                                        if (!application.isQueryExecuting()
+                                            && term.length() > 0) {
+                                            searchButton.press();
                                         }
-
-                                        return false;
                                     }
-                                    ]]>
-                                    </bxml:script>
+
+                                    return false;
+                                }
+                                ]]>
                                 </componentKeyListeners>
+
                                 <textInputTextListeners>
-                                    <bxml:script>
-                                    <![CDATA[
-                                    function textChanged(textInput) {
-                                        var term = termTextInput.getText();
-                                        searchButton.setEnabled(term.length() > 0);
-                                    }
-                                    ]]>
-                                    </bxml:script>
+                                <![CDATA[
+                                function textChanged(textInput) {
+                                    var term = termTextInput.getText();
+                                    searchButton.setEnabled(term.length() > 0);
+                                }
+                                ]]>
                                 </textInputTextListeners>
                             </TextInput>
+
                             <PushButton bxml:id="searchButton" enabled="false"
                                 styles="{toolbar:true, padding:1}">
                                 <buttonPressListeners>
-                                    <bxml:script>
-                                    <![CDATA[
-                                    function buttonPressed(button) {
-                                        if (application.isQueryExecuting()) {
-                                            application.abortQuery();
-                                        } else {
-                                            application.executeQuery(termTextInput.getText());
-                                        }
+                                <![CDATA[
+                                function buttonPressed(button) {
+                                    if (application.isQueryExecuting()) {
+                                        application.abortQuery();
+                                    } else {
+                                        application.executeQuery(termTextInput.getText());
                                     }
-                                    ]]>
-                                    </bxml:script>
+                                }
+                                ]]>
                                 </buttonPressListeners>
+
                                 <componentKeyListeners>
-                                    <bxml:script>
-                                    <![CDATA[
-                                    importPackage(org.apache.pivot.wtk);
-                                    function keyPressed(component, keyCode, keyLocation) {
-                                        if (keyCode == Keyboard.KeyCode.ESCAPE) {
-                                            if (application.isQueryExecuting()) {
-                                                application.abortQuery();
-                                            }
+                                <![CDATA[
+                                importPackage(org.apache.pivot.wtk);
+                                function keyPressed(component, keyCode, keyLocation) {
+                                    if (keyCode == Keyboard.KeyCode.ESCAPE) {
+                                        if (application.isQueryExecuting()) {
+                                            application.abortQuery();
                                         }
-
-                                        return false;
                                     }
-                                    ]]>
-                                    </bxml:script>
+
+                                    return false;
+                                }
+                                ]]>
                                 </componentKeyListeners>
                             </PushButton>
                         </BoxPane>
@@ -124,53 +119,47 @@ limitations under the License.
                                         </columns>
 
                                         <componentMouseButtonListeners>
-                                            <bxml:script>
-                                            <![CDATA[
-                                            importClass(java.awt.Desktop);
-                                            importClass(java.net.URL);
-                                            var selectedResult;
-
-                                            function mouseClick(component, button, x, y, count) {
-                                                if (count == 1) {
-                                                    selectedResult = resultsTableView.getSelectedRow();
-                                                } else if (count == 2) {
-                                                    if (selectedResult == resultsTableView.getSelectedRow()) {
-                                                        var url = new URL(selectedResult.get("previewUrl"));
-                                                        Desktop.getDesktop().browse(url.toURI());
-                                                    }
+                                        <![CDATA[
+                                        importClass(java.awt.Desktop);
+                                        importClass(java.net.URL);
+                                        var selectedResult;
+
+                                        function mouseClick(component, button, x, y, count) {
+                                            if (count == 1) {
+                                                selectedResult = resultsTableView.getSelectedRow();
+                                            } else if (count == 2) {
+                                                if (selectedResult == resultsTableView.getSelectedRow()) {
+                                                    var url = new URL(selectedResult.get("previewUrl"));
+                                                    Desktop.getDesktop().browse(url.toURI());
                                                 }
                                             }
-                                            ]]>
-                                            </bxml:script>
+                                        }
+                                        ]]>
                                         </componentMouseButtonListeners>
 
                                         <tableViewSelectionListeners>
-                                            <bxml:script>
-                                            <![CDATA[
-                                            function selectedRangeAdded(tableView, rangeStart, rangeEnd) {
-                                                application.updateArtwork();
-                                            }
+                                        <![CDATA[
+                                        function selectedRangeAdded(tableView, rangeStart, rangeEnd) {
+                                            application.updateArtwork();
+                                        }
 
-                                            function selectedRangeRemoved(tableView, rangeStart, rangeEnd) {
-                                                application.updateArtwork();
-                                            }
+                                        function selectedRangeRemoved(tableView, rangeStart, rangeEnd) {
+                                            application.updateArtwork();
+                                        }
 
-                                            function selectedRangesChanged(tableView, previousSelectedRanges) {
-                                                application.updateArtwork();
-                                            }
-                                            ]]>
-                                            </bxml:script>
+                                        function selectedRangesChanged(tableView, previousSelectedRanges) {
+                                            application.updateArtwork();
+                                        }
+                                        ]]>
                                         </tableViewSelectionListeners>
 
                                         <tableViewSortListeners>
-                                            <bxml:script>
-                                            <![CDATA[
-                                            function sortChanged(tableView) {
-                                                var tableData = tableView.getTableData();
-                                                tableData.setComparator(new org.apache.pivot.wtk.content.TableViewRowComparator(tableView));
-                                            }
-                                            ]]>
-                                            </bxml:script>
+                                        <![CDATA[
+                                        function sortChanged(tableView) {
+                                            var tableData = tableView.getTableData();
+                                            tableData.setComparator(new org.apache.pivot.wtk.content.TableViewRowComparator(tableView));
+                                        }
+                                        ]]>
                                         </tableViewSortListeners>
                                     </TableView>
 
@@ -195,17 +184,15 @@ limitations under the License.
                             <BoxPane styles="{horizontalAlignment:'center'}">
                                 <PushButton bxml:id="previewButton" buttonData="Preview" enabled="false">
                                     <buttonPressListeners>
-                                        <bxml:script>
-                                        <![CDATA[
-                                        importClass(java.awt.Desktop);
-                                        importClass(java.net.URL);
-                                        function buttonPressed(button) {
-                                            var selectedResult = resultsTableView.getSelectedRow();
-                                            var url = new URL(selectedResult.get("previewUrl"));
-                                            Desktop.getDesktop().browse(url.toURI());
-                                        }
-                                        ]]>
-                                        </bxml:script>
+                                    <![CDATA[
+                                    importClass(java.awt.Desktop);
+                                    importClass(java.net.URL);
+                                    function buttonPressed(button) {
+                                        var selectedResult = resultsTableView.getSelectedRow();
+                                        var url = new URL(selectedResult.get("previewUrl"));
+                                        Desktop.getDesktop().browse(url.toURI());
+                                    }
+                                    ]]>
                                     </buttonPressListeners>
                                 </PushButton>
                             </BoxPane>

Modified: pivot/trunk/demos/src/org/apache/pivot/demos/json/json_viewer.bxml
URL: http://svn.apache.org/viewvc/pivot/trunk/demos/src/org/apache/pivot/demos/json/json_viewer.bxml?rev=962684&r1=962683&r2=962684&view=diff
==============================================================================
--- pivot/trunk/demos/src/org/apache/pivot/demos/json/json_viewer.bxml (original)
+++ pivot/trunk/demos/src/org/apache/pivot/demos/json/json_viewer.bxml Fri Jul  9 20:28:07 2010
@@ -30,17 +30,15 @@ limitations under the License.
                     <content:TreeViewNodeRenderer showIcon="false"/>
                 </nodeRenderer>
                 <componentKeyListeners>
-                    <bxml:script>
-                    <![CDATA[
-                    importPackage(org.apache.pivot.wtk);
-                    function keyPressed(component, keyCode, keyLocation) {
-                        if (keyCode == Keyboard.KeyCode.V
-                            && Keyboard.isPressed(Platform.getCommandModifier())) {
-                            application.paste();
-                        }
+                <![CDATA[
+                importPackage(org.apache.pivot.wtk);
+                function keyPressed(component, keyCode, keyLocation) {
+                    if (keyCode == Keyboard.KeyCode.V
+                        && Keyboard.isPressed(Platform.getCommandModifier())) {
+                        application.paste();
                     }
-                    ]]>
-                    </bxml:script>
+                }
+                ]]>
                 </componentKeyListeners>
             </TreeView>
         </ScrollPane>

Modified: pivot/trunk/demos/src/org/apache/pivot/demos/xml/xml_viewer.bxml
URL: http://svn.apache.org/viewvc/pivot/trunk/demos/src/org/apache/pivot/demos/xml/xml_viewer.bxml?rev=962684&r1=962683&r2=962684&view=diff
==============================================================================
--- pivot/trunk/demos/src/org/apache/pivot/demos/xml/xml_viewer.bxml (original)
+++ pivot/trunk/demos/src/org/apache/pivot/demos/xml/xml_viewer.bxml Fri Jul  9 20:28:07 2010
@@ -34,27 +34,23 @@ limitations under the License.
                             </nodeRenderer>
 
                             <componentKeyListeners>
-                                <bxml:script>
-                                <![CDATA[
-                                importPackage(org.apache.pivot.wtk);
-                                function keyPressed(component, keyCode, keyLocation) {
-                                    if (keyCode == Keyboard.KeyCode.V
-                                        && Keyboard.isPressed(Platform.getCommandModifier())) {
-                                        application.paste();
-                                    }
+                            <![CDATA[
+                            importPackage(org.apache.pivot.wtk);
+                            function keyPressed(component, keyCode, keyLocation) {
+                                if (keyCode == Keyboard.KeyCode.V
+                                    && Keyboard.isPressed(Platform.getCommandModifier())) {
+                                    application.paste();
                                 }
-                                ]]>
-                                </bxml:script>
+                            }
+                            ]]>
                             </componentKeyListeners>
 
                             <treeViewSelectionListeners>
-                                <bxml:script>
-                                <![CDATA[
-                                function selectedPathsChanged(treeView, previousSelectedPaths) {
-                                    application.updateProperties();
-                                }
-                                ]]>
-                                </bxml:script>
+                            <![CDATA[
+                            function selectedPathsChanged(treeView, previousSelectedPaths) {
+                                application.updateProperties();
+                            }
+                            ]]>
                             </treeViewSelectionListeners>
                         </TreeView>
                     </ScrollPane>

Modified: pivot/trunk/examples/src/org/apache/pivot/examples/keyboard/component_key_listener_example.bxml
URL: http://svn.apache.org/viewvc/pivot/trunk/examples/src/org/apache/pivot/examples/keyboard/component_key_listener_example.bxml?rev=962684&r1=962683&r2=962684&view=diff
==============================================================================
--- pivot/trunk/examples/src/org/apache/pivot/examples/keyboard/component_key_listener_example.bxml (original)
+++ pivot/trunk/examples/src/org/apache/pivot/examples/keyboard/component_key_listener_example.bxml Fri Jul  9 20:28:07 2010
@@ -23,19 +23,17 @@ limitations under the License.
     <BoxPane styles="{padding:8}">
         <TextInput bxml:id="textInput">
             <componentKeyListeners>
-                <bxml:script>
-                <![CDATA[
-                importPackage(java.lang);
-                importPackage(org.apache.pivot.wtk);
+            <![CDATA[
+            importPackage(java.lang);
+            importPackage(org.apache.pivot.wtk);
 
-                function keyPressed(component, keyCode, keyLocation) {
-                    if (keyCode == Keyboard.KeyCode.S
-                        && Keyboard.isPressed(Keyboard.Modifier.CTRL)) {
-                        System.out.println("You pressed Control-S!");
-                    }
+            function keyPressed(component, keyCode, keyLocation) {
+                if (keyCode == Keyboard.KeyCode.S
+                    && Keyboard.isPressed(Keyboard.Modifier.CTRL)) {
+                    System.out.println("You pressed Control-S!");
                 }
-                ]]>
-                </bxml:script>
+            }
+            ]]>
             </componentKeyListeners>
         </TextInput>
     </BoxPane>

Modified: pivot/trunk/tutorials/src/org/apache/pivot/tutorials/scripting/scripting.bxml
URL: http://svn.apache.org/viewvc/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/scripting/scripting.bxml?rev=962684&r1=962683&r2=962684&view=diff
==============================================================================
--- pivot/trunk/tutorials/src/org/apache/pivot/tutorials/scripting/scripting.bxml (original)
+++ pivot/trunk/tutorials/src/org/apache/pivot/tutorials/scripting/scripting.bxml Fri Jul  9 20:28:07 2010
@@ -45,14 +45,12 @@ limitations under the License.
         <BoxPane orientation="vertical" styles="{padding:6}">
             <PushButton buttonData="Click Me!">
                 <buttonPressListeners>
-                    <bxml:script>
-                    <![CDATA[
-                    importPackage(org.apache.pivot.wtk);
-                    function buttonPressed(button) {
-                        Prompt.prompt("x = " + x, button.getWindow());
-                    }
-                    ]]>
-                    </bxml:script>
+                <![CDATA[
+                importPackage(org.apache.pivot.wtk);
+                function buttonPressed(button) {
+                    Prompt.prompt("x = " + x, button.getWindow());
+                }
+                ]]>
                 </buttonPressListeners>
             </PushButton>