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/10/28 18:07:31 UTC

svn commit: r1028363 [1/3] - /pivot/trunk/tutorials/www/

Author: gbrown
Date: Thu Oct 28 16:07:30 2010
New Revision: 1028363

URL: http://svn.apache.org/viewvc?rev=1028363&view=rev
Log:
Continue updating tutorials for Pivot 2.0 release.

Modified:
    pivot/trunk/tutorials/www/localization.xml
    pivot/trunk/tutorials/www/menu-bars.xml
    pivot/trunk/tutorials/www/menu-buttons.xml
    pivot/trunk/tutorials/www/meters.xml
    pivot/trunk/tutorials/www/panoramas.xml
    pivot/trunk/tutorials/www/property-binding.xml
    pivot/trunk/tutorials/www/query-servlet.xml
    pivot/trunk/tutorials/www/rollups.xml
    pivot/trunk/tutorials/www/scripting.xml
    pivot/trunk/tutorials/www/scroll-bars.xml
    pivot/trunk/tutorials/www/scroll-panes.xml
    pivot/trunk/tutorials/www/sliders.xml
    pivot/trunk/tutorials/www/spinners.xml
    pivot/trunk/tutorials/www/tab-panes.xml
    pivot/trunk/tutorials/www/table-views.custom.xml
    pivot/trunk/tutorials/www/table-views.json.xml
    pivot/trunk/tutorials/www/table-views.xml
    pivot/trunk/tutorials/www/tree-views.xml
    pivot/trunk/tutorials/www/web-queries.xml
    pivot/trunk/tutorials/www/windows.xml

Modified: pivot/trunk/tutorials/www/localization.xml
URL: http://svn.apache.org/viewvc/pivot/trunk/tutorials/www/localization.xml?rev=1028363&r1=1028362&r2=1028363&view=diff
==============================================================================
--- pivot/trunk/tutorials/www/localization.xml (original)
+++ pivot/trunk/tutorials/www/localization.xml Thu Oct 28 16:07:30 2010
@@ -88,35 +88,27 @@ limitations under the License.
         <source type="xml" location="org/apache/pivot/tutorials/localization/localization.wtkx">
             <![CDATA[
             <Window title="Localization" maximized="true"
-                xmlns:wtkx="http://pivot.apache.org/wtkx"
+                xmlns:bxml="http://pivot.apache.org/bxml"
                 xmlns="org.apache.pivot.wtk">
                 <windowStateListeners>
-                    <wtkx:script>
                     function windowOpened(window) {
                         window.requestFocus();
                     }
-                    </wtkx:script>
                 </windowStateListeners>
 
-                <content>
-                    <Border styles="{padding:6}">
-                        <content>
-                            <Form>
-                                <sections>
-                                    <Form.Section>
-                                        <TextInput Form.label="%firstName"/>
-                                        <TextInput Form.label="%lastName"/>
-                                        <TextInput Form.label="%street"/>
-                                        <TextInput Form.label="%city"/>
-                                        <TextInput Form.label="%state" textSize="4"/>
-                                        <TextInput Form.label="%postalCode"/>
-                                        <TextInput Form.label="%country"/>
-                                    </Form.Section>
-                                </sections>
-                            </Form>
-                        </content>
-                    </Border>
-                </content>
+                <Border styles="{padding:6}">
+                    <Form>
+                        <Form.Section>
+                            <TextInput Form.label="%firstName"/>
+                            <TextInput Form.label="%lastName"/>
+                            <TextInput Form.label="%street"/>
+                            <TextInput Form.label="%city"/>
+                            <TextInput Form.label="%state" textSize="4"/>
+                            <TextInput Form.label="%postalCode"/>
+                            <TextInput Form.label="%country"/>
+                        </Form.Section>
+                    </Form>
+                </Border>
             </Window>
             ]]>
         </source>
@@ -131,8 +123,8 @@ limitations under the License.
 
             import java.awt.Font;
             import java.awt.GraphicsEnvironment;
-            import java.util.Locale;
 
+            import org.apache.pivot.beans.BXMLSerializer;
             import org.apache.pivot.collections.Map;
             import org.apache.pivot.util.Resources;
             import org.apache.pivot.wtk.Application;
@@ -140,24 +132,19 @@ limitations under the License.
             import org.apache.pivot.wtk.Display;
             import org.apache.pivot.wtk.Theme;
             import org.apache.pivot.wtk.Window;
-            import org.apache.pivot.wtkx.WTKXSerializer;
 
             public class Localization implements Application {
                 private Window window = null;
 
-                public static final String LANGUAGE_KEY = "language";
-
                 @Override
                 public void startup(Display display, Map<String, String> properties) throws Exception {
-                    String language = properties.get(LANGUAGE_KEY);
-                    Locale locale = (language == null) ? Locale.getDefault() : new Locale(language);
-                    Resources resources = new Resources(getClass().getName(), locale);
+                    Resources resources = new Resources(getClass().getName());
 
                     Theme theme = Theme.getTheme();
                     Font font = theme.getFont();
 
                     // Search for a font that can support the sample string
-                    String sampleResource = resources.getString("firstName");
+                    String sampleResource = (String)resources.get("firstName");
                     if (font.canDisplayUpTo(sampleResource) != -1) {
                         Font[] fonts = GraphicsEnvironment.getLocalGraphicsEnvironment().getAllFonts();
 
@@ -169,9 +156,8 @@ limitations under the License.
                         }
                     }
 
-                    WTKXSerializer wtkxSerializer = new WTKXSerializer(resources);
-
-                    window = (Window)wtkxSerializer.readObject(this, "localization.wtkx");
+                    BXMLSerializer bxmlSerializer = new BXMLSerializer();
+                    window = (Window)bxmlSerializer.readObject(Localization.class.getResource("localization.bxml"), resources);
                     window.open(display);
                 }
 

Modified: pivot/trunk/tutorials/www/menu-bars.xml
URL: http://svn.apache.org/viewvc/pivot/trunk/tutorials/www/menu-bars.xml?rev=1028363&r1=1028362&r2=1028363&view=diff
==============================================================================
--- pivot/trunk/tutorials/www/menu-bars.xml (original)
+++ pivot/trunk/tutorials/www/menu-bars.xml Thu Oct 28 16:07:30 2010
@@ -46,14 +46,17 @@ limitations under the License.
             <tt>FileBrowserSheet</tt> component, which requires access to the local file system):
         </p>
 
-        <application class="org.apache.pivot.tutorials.menus.MenuBars"
+        <application class="org.apache.pivot.wtk.ScriptApplication"
             width="640" height="480">
-            <libraries signed="true">
+            <libraries>
                 <library>core</library>
                 <library>wtk</library>
                 <library>wtk-terra</library>
                 <library>tutorials</library>
             </libraries>
+            <startup-properties>
+                <src>/org/apache/pivot/tutorials/menus/menu_bars.bxml</src>
+            </startup-properties>
         </application>
 
         <p>
@@ -68,7 +71,7 @@ limitations under the License.
         </p>
 
         <p>
-            The WTKX source for this example is shown below. It creates the initial menu structure
+            The BXML source for this example is shown below. It creates the initial menu structure
             as well as the tab pane that will host the simulated documents. Note that it also
             defines a set of "action mappings" in the root frame's "actionMappings" sequence.
             Action mappings associate keystrokes with actions; when a keystroke matching an action
@@ -76,13 +79,18 @@ limitations under the License.
             often called "keyboard shortcuts".
         </p>
 
-        <source type="xml" location="org/apache/pivot/tutorials/menus/menu_bars.wtkx">
+        <source type="xml" location="org/apache/pivot/tutorials/menus/menu_bars.bxml">
             <![CDATA[
-            <Frame title="Menu Bars" maximized="true"
+            <menus:MenuBars title="Menu Bars" maximized="true"
                 styles="{padding:{top:0, left:4, bottom:4, right:4}, showWindowControls:false}"
-                xmlns:wtkx="http://pivot.apache.org/wtkx"
+                xmlns:bxml="http://pivot.apache.org/bxml"
                 xmlns:content="org.apache.pivot.wtk.content"
+                xmlns:menus="org.apache.pivot.tutorials.menus"
                 xmlns="org.apache.pivot.wtk">
+                <bxml:define>
+                    <FileBrowserSheet bxml:id="fileBrowserSheet"/>
+                </bxml:define>
+
                 <actionMappings>
                     <Window.ActionMapping action="cut" keyStroke="CTRL-X"/>
                     <Window.ActionMapping action="copy" keyStroke="CTRL-C"/>
@@ -91,68 +99,43 @@ limitations under the License.
 
                 <menuBar>
                     <MenuBar>
-                        <items>
-                            <MenuBar.Item buttonData="File">
-                                <menu>
-                                    <Menu>
-                                        <sections>
-                                            <Menu.Section>
-                                                <Menu.Item action="fileNew">
-                                                    <buttonData>
-                                                        <content:ButtonData text="New"/>
-                                                    </buttonData>
-                                                </Menu.Item>
-                                                <Menu.Item action="fileOpen">
-                                                    <buttonData>
-                                                        <content:ButtonData text="Open"/>
-                                                    </buttonData>
-                                                </Menu.Item>
-                                            </Menu.Section>
-                                        </sections>
-                                    </Menu>
-                                </menu>
-                            </MenuBar.Item>
-
-                            <MenuBar.Item buttonData="Edit">
-                                <menu>
-                                    <Menu>
-                                        <sections>
-                                            <Menu.Section>
-                                                <Menu.Item action="cut">
-                                                    <buttonData>
-                                                        <content:MenuItemData text="Cut"
-                                                            keyboardShortcut="CTRL-X"/>
-                                                    </buttonData>
-                                                </Menu.Item>
-                                                <Menu.Item action="copy">
-                                                    <buttonData>
-                                                        <content:MenuItemData text="Copy"
-                                                            keyboardShortcut="CTRL-C"/>
-                                                    </buttonData>
-                                                </Menu.Item>
-                                                <Menu.Item action="paste">
-                                                    <buttonData>
-                                                        <content:MenuItemData text="Paste"
-                                                            keyboardShortcut="CTRL-V"/>
-                                                    </buttonData>
-                                                </Menu.Item>
-                                            </Menu.Section>
-                                        </sections>
-                                    </Menu>
-                                </menu>
-                            </MenuBar.Item>
-                        </items>
+                        <MenuBar.Item buttonData="File">
+                            <Menu>
+                                <Menu.Section>
+                                    <Menu.Item buttonData="New" action="fileNew"/>
+                                    <Menu.Item buttonData="Open" action="fileOpen"/>
+                                </Menu.Section>
+                            </Menu>
+                        </MenuBar.Item>
+
+                        <MenuBar.Item buttonData="Edit">
+                            <Menu>
+                                <Menu.Section>
+                                    <Menu.Item action="cut">
+                                        <buttonData>
+                                            <content:MenuItemData text="Cut" keyboardShortcut="CTRL-X"/>
+                                        </buttonData>
+                                    </Menu.Item>
+                                    <Menu.Item action="copy">
+                                        <buttonData>
+                                            <content:MenuItemData text="Copy" keyboardShortcut="CTRL-C"/>
+                                        </buttonData>
+                                    </Menu.Item>
+                                    <Menu.Item action="paste">
+                                        <buttonData>
+                                            <content:MenuItemData text="Paste" keyboardShortcut="CTRL-V"/>
+                                        </buttonData>
+                                    </Menu.Item>
+                                </Menu.Section>
+                            </Menu>
+                        </MenuBar.Item>
                     </MenuBar>
                 </menuBar>
 
-                <content>
-                    <Border styles="{backgroundColor:null, padding:2}">
-                        <content>
-                            <TabPane wtkx:id="tabPane"/>
-                        </content>
-                    </Border>
-                </content>
-            </Frame>
+                <Border styles="{backgroundColor:null, padding:2}">
+                    <TabPane bxml:id="tabPane"/>
+                </Border>
+            </menus:MenuBars>
             ]]>
         </source>
 
@@ -160,8 +143,8 @@ limitations under the License.
             The Java source for the example is shown below. In the constructor, the application's
             actions are created and added to the global action dictionary. Then, in
             <tt>startup()</tt>, the application's user interface is loaded and the main window
-            opened. Note that, since the WTKX file refers to the actions by ID, it is essential
-            that the actions be available before the WTKX is read.
+            opened. Note that, since the BXML file refers to the actions by ID, it is essential
+            that the actions be available before the BXML is read.
         </p>
 
         <source type="java" location="org/apache/pivot/tutorials/menus/MenuBars.java">
@@ -169,33 +152,32 @@ limitations under the License.
             package org.apache.pivot.tutorials.menus;
 
             import java.io.IOException;
+            import java.net.URL;
 
+            import org.apache.pivot.beans.BXML;
+            import org.apache.pivot.beans.BXMLSerializer;
+            import org.apache.pivot.beans.Bindable;
             import org.apache.pivot.collections.Map;
             import org.apache.pivot.serialization.SerializationException;
+            import org.apache.pivot.util.Resources;
             import org.apache.pivot.wtk.Action;
-            import org.apache.pivot.wtk.Application;
             import org.apache.pivot.wtk.Border;
             import org.apache.pivot.wtk.Component;
-            import org.apache.pivot.wtk.DesktopApplicationContext;
-            import org.apache.pivot.wtk.Display;
             import org.apache.pivot.wtk.FileBrowserSheet;
+            import org.apache.pivot.wtk.Frame;
             import org.apache.pivot.wtk.MenuBar;
             import org.apache.pivot.wtk.MenuHandler;
-            import org.apache.pivot.wtk.PushButton;
             import org.apache.pivot.wtk.TabPane;
             import org.apache.pivot.wtk.TextInput;
             import org.apache.pivot.wtk.TextInputSelectionListener;
-            import org.apache.pivot.wtk.TextInputTextListener;
-            import org.apache.pivot.wtk.Window;
-            import org.apache.pivot.wtkx.WTKXSerializer;
-
-            public class MenuBars implements Application {
-                private Window window = null;
-                private TabPane tabPane = null;
-                private FileBrowserSheet fileBrowserSheet = null;
+            import org.apache.pivot.wtk.TextInputContentListener;
+
+            public class MenuBars extends Frame implements Bindable {
+                @BXML private FileBrowserSheet fileBrowserSheet;
+                @BXML private TabPane tabPane = null;
 
                 private MenuHandler menuHandler = new MenuHandler.Adapter() {
-                    TextInputTextListener textInputTextListener = new TextInputTextListener() {
+                    TextInputContentListener textInputTextListener = new TextInputContentListener.Adapter() {
                         @Override
                         public void textChanged(TextInput textInput) {
                             updateActionState(textInput);
@@ -218,7 +200,7 @@ limitations under the License.
                             updateActionState(textInput);
                             Action.getNamedActions().get("paste").setEnabled(true);
 
-                            textInput.getTextInputTextListeners().add(textInputTextListener);
+                            textInput.getTextInputContentListeners().add(textInputTextListener);
                             textInput.getTextInputSelectionListeners().add(textInputSelectionListener);
                         } else {
                             Action.getNamedActions().get("cut").setEnabled(false);
@@ -231,7 +213,7 @@ limitations under the License.
                     public void cleanupMenuBar(Component component, MenuBar menuBar) {
                         if (component instanceof TextInput) {
                             TextInput textInput = (TextInput)component;
-                            textInput.getTextInputTextListeners().remove(textInputTextListener);
+                            textInput.getTextInputContentListeners().remove(textInputTextListener);
                             textInput.getTextInputSelectionListeners().remove(textInputSelectionListener);
                         }
                     }
@@ -245,20 +227,13 @@ limitations under the License.
                 public MenuBars() {
                     Action.getNamedActions().put("fileNew", new Action() {
                         @Override
-                        public void perform() {
-                            WTKXSerializer wtkxSerializer = new WTKXSerializer();
+                        public void perform(Component source) {
+                            BXMLSerializer bxmlSerializer = new BXMLSerializer();
+                            bxmlSerializer.getNamespace().put("menuHandler", menuHandler);
+
                             Component tab;
                             try {
-                                tab = new Border((Component)wtkxSerializer.readObject(this, "document.wtkx"));
-
-                                TextInput textInput1 = (TextInput)wtkxSerializer.get("textInput1");
-                                textInput1.setMenuHandler(menuHandler);
-
-                                TextInput textInput2 = (TextInput)wtkxSerializer.get("textInput2");
-                                textInput2.setMenuHandler(menuHandler);
-
-                                PushButton pushButton = (PushButton)wtkxSerializer.get("pushButton");
-                                pushButton.setMenuHandler(menuHandler);
+                                tab = new Border((Component)bxmlSerializer.readObject(MenuBars.class, "document.bxml"));
                             } catch (IOException exception) {
                                 throw new RuntimeException(exception);
                             } catch (SerializationException exception) {
@@ -266,75 +241,45 @@ limitations under the License.
                             }
 
                             tabPane.getTabs().add(tab);
-                            TabPane.setLabel(tab, "Document " + tabPane.getTabs().getLength());
+                            TabPane.setTabData(tab, "Document " + tabPane.getTabs().getLength());
                             tabPane.setSelectedIndex(tabPane.getTabs().getLength() - 1);
                         }
                     });
 
                     Action.getNamedActions().put("fileOpen", new Action() {
                         @Override
-                        public void perform() {
-                            fileBrowserSheet.open(window);
+                        public void perform(Component source) {
+                            fileBrowserSheet.open(MenuBars.this);
                         }
                     });
 
                     Action.getNamedActions().put("cut", new Action(false) {
                         @Override
-                        public void perform() {
-                            TextInput textInput = (TextInput)window.getFocusDescendant();
+                        public void perform(Component source) {
+                            TextInput textInput = (TextInput)MenuBars.this.getFocusDescendant();
                             textInput.cut();
                         }
                     });
 
                     Action.getNamedActions().put("copy", new Action(false) {
                         @Override
-                        public void perform() {
-                            TextInput textInput = (TextInput)window.getFocusDescendant();
+                        public void perform(Component source) {
+                            TextInput textInput = (TextInput)MenuBars.this.getFocusDescendant();
                             textInput.copy();
                         }
                     });
 
                     Action.getNamedActions().put("paste", new Action(false) {
                         @Override
-                        public void perform() {
-                            TextInput textInput = (TextInput)window.getFocusDescendant();
+                        public void perform(Component source) {
+                            TextInput textInput = (TextInput)MenuBars.this.getFocusDescendant();
                             textInput.paste();
                         }
                     });
                 }
 
                 @Override
-                public void startup(Display display, Map<String, String> properties)
-                    throws Exception {
-                    WTKXSerializer wtkxSerializer = new WTKXSerializer();
-                    window = (Window)wtkxSerializer.readObject(this, "menu_bars.wtkx");
-
-                    tabPane = (TabPane)wtkxSerializer.get("tabPane");
-
-                    fileBrowserSheet = new FileBrowserSheet(FileBrowserSheet.Mode.OPEN);
-
-                    window.open(display);
-                }
-
-                @Override
-                public boolean shutdown(boolean optional) {
-                    if (window != null) {
-                        window.close();
-                    }
-
-                    return false;
-                }
-
-                @Override
-                public void suspend() {
-                }
-
-                @Override
-                public void resume() {
-                }
-
-                public static void main(String[] args) {
-                    DesktopApplicationContext.main(MenuBars.class, args);
+                public void initialize(Map<String, Object> namespace, URL location, Resources resources) {
                 }
             }
             ]]>

Modified: pivot/trunk/tutorials/www/menu-buttons.xml
URL: http://svn.apache.org/viewvc/pivot/trunk/tutorials/www/menu-buttons.xml?rev=1028363&r1=1028362&r2=1028363&view=diff
==============================================================================
--- pivot/trunk/tutorials/www/menu-buttons.xml (original)
+++ pivot/trunk/tutorials/www/menu-buttons.xml Thu Oct 28 16:07:30 2010
@@ -29,108 +29,63 @@ limitations under the License.
         </p>
 
         <p>
-            The following sample application demonstrates the use of a menu button. The
-            application's toolbar contains a menu button containing a list of shapes, and a list
-            button containing a list of colors. Selecting an item from the shape menu button adds
-            the selected shape to the drawing shown in the application's content area:
+            The following sample application demonstrates the use of a menu button. The...
         </p>
 
-        <application class="org.apache.pivot.tutorials.menus.MenuButtons"
-            width="640" height="480">
+        <application class="org.apache.pivot.wtk.ScriptApplication"
+            width="360" height="240">
             <libraries>
                 <library>core</library>
                 <library>wtk</library>
                 <library>wtk-terra</library>
                 <library>tutorials</library>
             </libraries>
+            <startup-properties>
+                <src>/org/apache/pivot/tutorials/menus/menu_buttons.bxml</src>
+            </startup-properties>
         </application>
 
         <p>
-            The WTKX source for the application is as follows:
+            The BXML source for the application is as follows:
         </p>
 
-        <source type="xml" location="org/apache/pivot/tutorials/menus/menu_buttons.wtkx">
+        <source type="xml" location="org/apache/pivot/tutorials/menus/menu_buttons.bxml">
             <![CDATA[
-            <Window title="Menu Buttons" maximized="true"
-                xmlns:wtkx="http://pivot.apache.org/wtkx"
-                xmlns:collections="org.apache.pivot.collections"
+            <menus:MenuButtons title="Menu Buttons" maximized="true"
+                xmlns:bxml="http://pivot.apache.org/bxml"
                 xmlns:content="org.apache.pivot.wtk.content"
+                xmlns:menus="org.apache.pivot.tutorials.menus"
                 xmlns="org.apache.pivot.wtk">
-                <content>
-                    <Border styles="{padding:2}">
-                        <content>
-                            <TablePane styles="{verticalSpacing:2}">
-                                <columns>
-                                    <TablePane.Column width="1*"/>
-                                </columns>
-                                <rows>
-                                    <TablePane.Row height="-1">
-                                        <BoxPane styles="{fill:true}">
-                                            <MenuButton>
-                                                <buttonData>
-                                                    <content:ButtonData icon="@shape_square_add.png" text="New Shape"/>
-                                                </buttonData>
-                                                <menu>
-                                                    <Menu>
-                                                        <sections>
-                                                            <Menu.Section>
-                                                                <Menu.Item buttonData="Circle" action="newCircle"/>
-                                                                <Menu.Item buttonData="Square" action="newSquare"/>
-                                                                <Menu.Item buttonData="Text" action="newText"/>
-                                                            </Menu.Section>
-                                                        </sections>
-                                                    </Menu>
-                                                </menu>
-                                            </MenuButton>
-
-                                            <ListButton wtkx:id="colorListButton" selectedIndex="0" styles="{listSize:6}">
-                                                <listData>
-                                                    <collections:ArrayList>
-                                                        <content:ColorItem color="#000000" name="Black"/>
-                                                        <content:ColorItem color="#0000AA" name="Blue"/>
-                                                        <content:ColorItem color="#00AA00" name="Green"/>
-                                                        <content:ColorItem color="#00AAAA" name="Cyan"/>
-                                                        <content:ColorItem color="#AA0000" name="Red"/>
-                                                        <content:ColorItem color="#AA00AA" name="Magenta"/>
-                                                        <content:ColorItem color="#AA5500" name="Brown"/>
-                                                        <content:ColorItem color="#AAAAAA" name="Light Gray"/>
-                                                        <content:ColorItem color="#555555" name="Dark Gray"/>
-                                                        <content:ColorItem color="#5555FF" name="Bright Blue"/>
-                                                        <content:ColorItem color="#55FF55" name="Bright Green"/>
-                                                        <content:ColorItem color="#55FFFF" name="Bright Cyan"/>
-                                                        <content:ColorItem color="#FF5555" name="Bright Red"/>
-                                                        <content:ColorItem color="#FF55FF" name="Bright Magenta"/>
-                                                        <content:ColorItem color="#FFFF55" name="Bright Yellow"/>
-                                                        <content:ColorItem color="#FFFFFF" name="White"/>
-                                                    </collections:ArrayList>
-                                                </listData>
-                                                <dataRenderer>
-                                                    <content:ListButtonColorItemRenderer/>
-                                                </dataRenderer>
-                                                <itemRenderer>
-                                                    <content:ListViewColorItemRenderer/>
-                                                </itemRenderer>
-                                            </ListButton>
-                                        </BoxPane>
-                                    </TablePane.Row>
-                                    <TablePane.Row height="1*">
-                                        <Border styles="{padding:2}">
-                                            <content>
-                                                <ScrollPane horizontalScrollBarPolicy="fill_to_capacity"
-                                                    verticalScrollBarPolicy="fill_to_capacity">
-                                                    <view>
-                                                        <ImageView wtkx:id="imageView"/>
-                                                    </view>
-                                                </ScrollPane>
-                                            </content>
-                                        </Border>
-                                    </TablePane.Row>
-                                </rows>
-                            </TablePane>
-                        </content>
-                    </Border>
-                </content>
-            </Window>
+                <Border styles="{padding:8}">
+                    <TablePane styles="{horizontalSpacing:4}">
+                        <columns>
+                            <TablePane.Column width="-1"/>
+                            <TablePane.Column width="1*"/>
+                        </columns>
+
+                        <TablePane.Row height="1*">
+                            <BoxPane orientation="vertical">
+                                <MenuButton buttonData="Add Component">
+                                    <Menu>
+                                        <Menu.Section>
+                                            <Menu.Item buttonData="Push Button" action="addPushButton"/>
+                                            <Menu.Item buttonData="Checkbox" action="addCheckbox"/>
+                                            <Menu.Item buttonData="Radio Button" action="addRadioButton"/>
+                                        </Menu.Section>
+                                    </Menu>
+                                </MenuButton>
+                            </BoxPane>
+
+                            <Border>
+                                <ScrollPane>
+                                    <BoxPane bxml:id="componentBoxPane" orientation="vertical"
+                                        styles="{padding:4, spacing:4}"/>
+                                </ScrollPane>
+                            </Border>
+                        </TablePane.Row>
+                    </TablePane>
+                </Border>
+            </menus:MenuButtons>
             ]]>
         </source>
 
@@ -143,144 +98,56 @@ limitations under the License.
             <![CDATA[
             package org.apache.pivot.tutorials.menus;
 
-            import java.awt.Color;
-            import java.awt.Paint;
+            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.Action;
-            import org.apache.pivot.wtk.Application;
-            import org.apache.pivot.wtk.Bounds;
-            import org.apache.pivot.wtk.DesktopApplicationContext;
-            import org.apache.pivot.wtk.Display;
-            import org.apache.pivot.wtk.ImageView;
-            import org.apache.pivot.wtk.ListButton;
-            import org.apache.pivot.wtk.Point;
+            import org.apache.pivot.wtk.BoxPane;
+            import org.apache.pivot.wtk.Checkbox;
+            import org.apache.pivot.wtk.Component;
+            import org.apache.pivot.wtk.PushButton;
+            import org.apache.pivot.wtk.RadioButton;
             import org.apache.pivot.wtk.Window;
-            import org.apache.pivot.wtk.content.ColorItem;
-            import org.apache.pivot.wtk.media.Drawing;
-            import org.apache.pivot.wtk.media.drawing.Ellipse;
-            import org.apache.pivot.wtk.media.drawing.Rectangle;
-            import org.apache.pivot.wtk.media.drawing.Shape;
-            import org.apache.pivot.wtk.media.drawing.Text;
-            import org.apache.pivot.wtkx.WTKXSerializer;
-
-            public class MenuButtons implements Application {
-                private Window window = null;
-                private ListButton colorListButton = null;
-                private ImageView imageView = null;
 
-                private Drawing drawing = null;
-
-                public static final int MAX_X = 480;
-                public static final int MAX_Y = 360;
+            public class MenuButtons extends Window implements Bindable {
+                private BoxPane componentBoxPane = null;
 
                 public MenuButtons() {
-                    Action.getNamedActions().put("newCircle", new Action() {
+                    Action.getNamedActions().put("addPushButton", new Action() {
                         @Override
-                        public void perform() {
-                            Ellipse ellipse = new Ellipse();
-                            ellipse.setSize(50, 50);
-
-                            ellipse.setStroke((Paint)null);
-                            ellipse.setFill(getSelectedColor());
-                            ellipse.setOrigin(getRandomLocation(ellipse));
+                        public void perform(Component source) {
+                            componentBoxPane.add(new PushButton("Push button"));
 
-                            drawing.getCanvas().add(ellipse);
                         }
                     });
 
-                    Action.getNamedActions().put("newSquare", new Action() {
+                    Action.getNamedActions().put("addCheckbox", new Action() {
                         @Override
-                        public void perform() {
-                            Rectangle rectangle = new Rectangle();
-                            rectangle.setSize(50, 50);
-
-                            rectangle.setStroke((Paint)null);
-                            rectangle.setFill(getSelectedColor());
-                            rectangle.setOrigin(getRandomLocation(rectangle));
-
-                            drawing.getCanvas().add(rectangle);
+                        public void perform(Component source) {
+                            componentBoxPane.add(new Checkbox("Checkbox"));
                         }
                     });
 
-                    Action.getNamedActions().put("newText", new Action() {
+                    Action.getNamedActions().put("addRadioButton", new Action() {
                         @Override
-                        public void perform() {
-                            Text text = new Text();
-                            text.setText("ABC");
-                            text.setFont("Arial BOLD 24");
-
-                            text.setFill(getSelectedColor());
-                            text.setOrigin(getRandomLocation(text));
-
-                            drawing.getCanvas().add(text);
+                        public void perform(Component source) {
+                            componentBoxPane.add(new RadioButton("Radio button"));
                         }
                     });
                 }
 
                 @Override
-                public void startup(Display display, Map<String, String> properties) throws Exception {
-                    WTKXSerializer wtkxSerializer = new WTKXSerializer();
-                    window = (Window)wtkxSerializer.readObject(this, "menu_buttons.wtkx");
-                    colorListButton = (ListButton)wtkxSerializer.get("colorListButton");
-                    imageView = (ImageView)wtkxSerializer.get("imageView");
-
-                    drawing = new Drawing();
-
-                    Rectangle borderRectangle = new Rectangle();
-                    borderRectangle.setSize(MAX_X, MAX_Y);
-                    borderRectangle.setStroke((Paint)null);
-                    borderRectangle.setFill("#eeeeee");
-
-                    drawing.getCanvas().add(borderRectangle);
-
-                    imageView.setImage(drawing);
-
-                    window.open(display);
-                }
-
-                @Override
-                public boolean shutdown(boolean optional) {
-                    if (window != null) {
-                        window.close();
-                    }
-
-                    return false;
-                }
-
-                @Override
-                public void suspend() {
-                }
-
-                @Override
-                public void resume() {
-                }
-
-                public Color getSelectedColor() {
-                    ColorItem colorItem = (ColorItem)colorListButton.getSelectedItem();
-                    return colorItem.getColor();
-                }
-
-                public Point getRandomLocation(Shape shape) {
-                    Bounds bounds = shape.getBounds();
-
-                    int x = (int)(Math.random() * (MAX_X - bounds.width));
-                    int y = (int)(Math.random() * (MAX_Y - bounds.height));
-
-                    return new Point(x, y);
-                }
-
-                public static void main(String[] args) {
-                    DesktopApplicationContext.main(MenuButtons.class, args);
+                public void initialize(Map<String, Object> namespace, URL location, Resources resources) {
+                    componentBoxPane = (BoxPane)namespace.get("componentBoxPane");
                 }
             }
             ]]>
         </source>
 
         <p>
-            Each action simply adds a particular shape to the drawing, setting its color based on
-            the current selection in the list button. The shapes are placed at a random location
-            that is adjusted by the shape's size to ensure that the shape remains on-screen.
+            Each action simply adds a particular component to the...
         </p>
     </body>
 </document>

Modified: pivot/trunk/tutorials/www/meters.xml
URL: http://svn.apache.org/viewvc/pivot/trunk/tutorials/www/meters.xml?rev=1028363&r1=1028362&r2=1028363&view=diff
==============================================================================
--- pivot/trunk/tutorials/www/meters.xml (original)
+++ pivot/trunk/tutorials/www/meters.xml Thu Oct 28 16:07:30 2010
@@ -29,7 +29,7 @@ limitations under the License.
             Periodically, the task updates the meter to reflect its progress:
         </p>
 
-        <application class="org.apache.pivot.tutorials.progress.Meters"
+        <application class="org.apache.pivot.wtk.ScriptApplication"
             width="300" height="100">
             <libraries>
                 <library>core</library>
@@ -37,42 +37,42 @@ limitations under the License.
                 <library>wtk-terra</library>
                 <library>tutorials</library>
             </libraries>
+            <startup-properties>
+                <src>/org/apache/pivot/tutorials/progress/meters.bxml</src>
+            </startup-properties>
         </application>
 
         <p>
-            The WTKX source for the example is shown below:
+            The BXML source for the example is shown below:
         </p>
 
-        <source type="xml" location="org/apache/pivot/tutorials/progress/meters.wtkx">
+        <source type="xml" location="org/apache/pivot/tutorials/progress/meters.bxml">
             <![CDATA[
-            <Window title="Meters" maximized="true"
-                xmlns:wtkx="http://pivot.apache.org/wtkx"
+            <progress:Meters title="Meters" maximized="true"
+                xmlns:bxml="http://pivot.apache.org/bxml"
+                xmlns:progress="org.apache.pivot.tutorials.progress"
                 xmlns="org.apache.pivot.wtk">
-                <content>
-                    <TablePane>
-                        <columns>
-                            <TablePane.Column width="1*"/>
-                        </columns>
-                        <rows>
-                            <TablePane.Row height="1*">
-                                <Border styles="{padding:2}">
-                                    <content>
-                                        <BoxPane styles="{horizontalAlignment:'center', verticalAlignment:'center'}">
-                                            <Label text="Progress:"/>
-                                            <Meter wtkx:id="meter" preferredWidth="200" preferredHeight="16"/>
-                                        </BoxPane>
-                                    </content>
-                                </Border>
-                            </TablePane.Row>
-                            <TablePane.Row height="-1">
-                                <BoxPane styles="{horizontalAlignment:'center', padding:6}">
-                                    <PushButton wtkx:id="progressButton" styles="{minimumAspectRatio:3}"/>
-                                </BoxPane>
-                            </TablePane.Row>
-                        </rows>
-                    </TablePane>
-                </content>
-            </Window>
+                <TablePane>
+                    <columns>
+                        <TablePane.Column width="1*"/>
+                    </columns>
+
+                    <TablePane.Row height="1*">
+                        <Border styles="{padding:2}">
+                            <BoxPane styles="{horizontalAlignment:'center', verticalAlignment:'center'}">
+                                <Label text="Progress:"/>
+                                <Meter bxml:id="meter" preferredWidth="200" preferredHeight="16"/>
+                            </BoxPane>
+                        </Border>
+                    </TablePane.Row>
+
+                    <TablePane.Row height="-1">
+                        <BoxPane styles="{horizontalAlignment:'center', padding:6}">
+                            <PushButton bxml:id="progressButton" styles="{minimumAspectRatio:3}"/>
+                        </BoxPane>
+                    </TablePane.Row>
+                </TablePane>
+            </progress:Meters>
             ]]>
         </source>
 
@@ -90,23 +90,23 @@ limitations under the License.
             <![CDATA[
             package org.apache.pivot.tutorials.progress;
 
+            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.util.concurrent.Task;
             import org.apache.pivot.util.concurrent.TaskExecutionException;
             import org.apache.pivot.util.concurrent.TaskListener;
-            import org.apache.pivot.wtk.Application;
             import org.apache.pivot.wtk.ApplicationContext;
             import org.apache.pivot.wtk.Button;
             import org.apache.pivot.wtk.ButtonPressListener;
-            import org.apache.pivot.wtk.DesktopApplicationContext;
-            import org.apache.pivot.wtk.Display;
             import org.apache.pivot.wtk.Meter;
             import org.apache.pivot.wtk.PushButton;
             import org.apache.pivot.wtk.TaskAdapter;
             import org.apache.pivot.wtk.Window;
-            import org.apache.pivot.wtkx.WTKXSerializer;
 
-            public class Meters implements Application {
+            public class Meters extends Window implements Bindable {
                 public class SampleTask extends Task<Void> {
                     private int percentage = 0;
 
@@ -137,19 +137,15 @@ limitations under the License.
                     }
                 }
 
-                private Window window = null;
                 private Meter meter = null;
                 private PushButton progressButton = null;
 
                 private SampleTask sampleTask = null;
 
                 @Override
-                public void startup(Display display, Map<String, String> properties)
-                    throws Exception {
-                    WTKXSerializer wtkxSerializer = new WTKXSerializer();
-                    window = (Window)wtkxSerializer.readObject(this, "meters.wtkx");
-                    meter = (Meter)wtkxSerializer.get("meter");
-                    progressButton = (PushButton)wtkxSerializer.get("progressButton");
+                public void initialize(Map<String, Object> namespace, URL location, Resources resources) {
+                    meter = (Meter)namespace.get("meter");
+                    progressButton = (PushButton)namespace.get("progressButton");
 
                     progressButton.getButtonPressListeners().add(new ButtonPressListener() {
                         @Override
@@ -187,25 +183,6 @@ limitations under the License.
                     });
 
                     updateProgressButton();
-
-                    window.open(display);
-                }
-
-                @Override
-                public boolean shutdown(boolean optional) {
-                    if (window != null) {
-                        window.close();
-                    }
-
-                    return false;
-                }
-
-                @Override
-                public void suspend() {
-                }
-
-                @Override
-                public void resume() {
                 }
 
                 private void updateProgressButton() {
@@ -215,10 +192,6 @@ limitations under the License.
                         progressButton.setButtonData("Cancel");
                     }
                 }
-
-                public static void main(String[] args) {
-                    DesktopApplicationContext.main(Meters.class, args);
-                }
             }
             ]]>
         </source>

Modified: pivot/trunk/tutorials/www/panoramas.xml
URL: http://svn.apache.org/viewvc/pivot/trunk/tutorials/www/panoramas.xml?rev=1028363&r1=1028362&r2=1028363&view=diff
==============================================================================
--- pivot/trunk/tutorials/www/panoramas.xml (original)
+++ pivot/trunk/tutorials/www/panoramas.xml Thu Oct 28 16:07:30 2010
@@ -43,28 +43,21 @@ limitations under the License.
                 <library>tutorials</library>
             </libraries>
             <startup-properties>
-                <src>org/apache/pivot/tutorials/navigation/panoramas.wtkx</src>
+                <src>/org/apache/pivot/tutorials/navigation/panoramas.bxml</src>
             </startup-properties>
         </application>
 
-
-        <source type="xml" location="org/apache/pivot/tutorials/navigation/panoramas.wtkx">
+        <source type="xml" location="org/apache/pivot/tutorials/navigation/panoramas.bxml">
             <![CDATA[
             <Window title="Panoramas" maximized="true"
-                xmlns:wtkx="http://pivot.apache.org/wtkx"
+                xmlns:bxml="http://pivot.apache.org/bxml"
                 xmlns="org.apache.pivot.wtk">
-                <content>
-                    <Border styles="{color:10}">
-                        <content>
-                            <Panorama styles="{buttonColor:'0xffffffff', buttonBackgroundColor:'0x00000044'}">
-                                <view>
-                                    <ImageView image="org/apache/pivot/tutorials/IMG_1147.jpg"
-                                        tooltipText="Pemaquid Point Lighthouse, Bristol ME"/>
-                                </view>
-                            </Panorama>
-                        </content>
-                    </Border>
-                </content>
+                <Border styles="{color:10}">
+                    <Panorama styles="{buttonColor:'0xffffffff', buttonBackgroundColor:'0x00000044'}">
+                        <ImageView image="org/apache/pivot/tutorials/IMG_1147.jpg"
+                            tooltipText="Pemaquid Point Lighthouse, Bristol ME"/>
+                    </Panorama>
+                </Border>
             </Window>
             ]]>
         </source>

Modified: pivot/trunk/tutorials/www/property-binding.xml
URL: http://svn.apache.org/viewvc/pivot/trunk/tutorials/www/property-binding.xml?rev=1028363&r1=1028362&r2=1028363&view=diff
==============================================================================
--- pivot/trunk/tutorials/www/property-binding.xml (original)
+++ pivot/trunk/tutorials/www/property-binding.xml Thu Oct 28 16:07:30 2010
@@ -41,5 +41,108 @@ limitations under the License.
                 <src>/org/apache/pivot/tutorials/databinding/property_binding.bxml</src>
             </startup-properties>
         </application>
+
+        <p>
+            The BXML source for the example is below:
+        </p>
+
+        <source type="xml" location="org/apache/pivot/tutorials/databinding/property_binding.bxml">
+            <![CDATA[
+            <databinding:PropertyBinding title="Property Binding" maximized="true"
+                xmlns:bxml="http://pivot.apache.org/bxml"
+                xmlns:databinding="org.apache.pivot.tutorials.databinding"
+                xmlns="org.apache.pivot.wtk">
+                <bxml:script>
+                importClass(org.apache.pivot.tutorials.databinding.PropertyBinding);
+
+                function toUpperCase(value) {
+                    return value.toUpperCase();
+                }
+
+                function toHex(color) {
+                    return PropertyBinding.toHex(color);
+                }
+                </bxml:script>
+
+                <Border>
+                    <Form>
+                        <Form.Section heading="One-Way Binding">
+                            <TextInput bxml:id="textInput" Form.label="Text Input"/>
+                            <Label Form.label="Text" text="${textInput.text}"/>
+                            <Label Form.label="Uppercase Text" text="${toUpperCase:textInput.text}"/>
+                        </Form.Section>
+
+                        <Form.Section heading="Two-Way Binding">
+                            <TextInput bxml:id="textInput1" Form.label="Text Input 1" text="${textInput2.text}"/>
+                            <TextInput bxml:id="textInput2" Form.label="Text Input 2" text="${textInput1.text}"/>
+                        </Form.Section>
+
+                        <Form.Section heading="Style Binding">
+                            <ColorChooserButton bxml:id="colorChooserButton" Form.label="Color Chooser Button"
+                                selectedColor="#000000"/>
+                            <Label Form.label="Selected Color" text="${colorChooserButton.selectedColor}">
+                                <styles color="${colorChooserButton.selectedColor}"/>
+                            </Label>
+                            <Label Form.label="Selected Color (Hex)" text="${toHex:colorChooserButton.selectedColor}">
+                                <styles color="${toHex:colorChooserButton.selectedColor}"/>
+                            </Label>
+                        </Form.Section>
+
+                        <Form.Section heading="Manual Binding">
+                            <ListButton bxml:id="listButton" Form.label="List Button"
+                                listData="['Zero', 'One', 'Two', 'Three']" selectedIndex="0"/>
+                            <Label bxml:id="listButtonLabel1" Form.label="Selected Item"/>
+                            <Label bxml:id="listButtonLabel2" Form.label="Uppercase Selected Item"/>
+                        </Form.Section>
+                    </Form>
+                </Border>
+            </databinding:PropertyBinding>
+            ]]>
+        </source>
+
+        <p>
+            The Java source is as follows:
+        </p>
+
+        <source type="java" location="org/apache/pivot/tutorials/databinding/PropertyBinding.java">
+            <![CDATA[
+            package org.apache.pivot.tutorials.databinding;
+
+            import java.awt.Color;
+            import java.net.URL;
+
+            import org.apache.pivot.beans.Bindable;
+            import org.apache.pivot.beans.NamespaceBinding;
+            import org.apache.pivot.collections.Map;
+            import org.apache.pivot.util.Resources;
+            import org.apache.pivot.wtk.Window;
+
+            public class PropertyBinding extends Window implements Bindable {
+                @Override
+                public void initialize(Map<String, Object> namespace, URL location, Resources resources) {
+                    // Bind list button selection to label text
+                    NamespaceBinding namespaceBinding1 = new NamespaceBinding(namespace,
+                        "listButton.selectedItem", "listButtonLabel1.text");
+
+                    namespaceBinding1.bind();
+
+                    // Bind list button selection to label text with bind mapping
+                    NamespaceBinding namespaceBinding2 = new NamespaceBinding(namespace,
+                        "listButton.selectedItem", "listButtonLabel2.text", new NamespaceBinding.BindMapping() {
+                        @Override
+                        public Object evaluate(Object value) {
+                            return value.toString().toUpperCase();
+                        }
+                    });
+
+                    namespaceBinding2.bind();
+                }
+
+                public static String toHex(Color color) {
+                    return String.format("#%02X%02X%02X", color.getRed(), color.getBlue(), color.getGreen());
+                }
+            }
+            ]]>
+        </source>
     </body>
 </document>

Modified: pivot/trunk/tutorials/www/query-servlet.xml
URL: http://svn.apache.org/viewvc/pivot/trunk/tutorials/www/query-servlet.xml?rev=1028363&r1=1028362&r2=1028363&view=diff
==============================================================================
--- pivot/trunk/tutorials/www/query-servlet.xml (original)
+++ pivot/trunk/tutorials/www/query-servlet.xml Thu Oct 28 16:07:30 2010
@@ -137,169 +137,171 @@ limitations under the License.
             implementation of each method is discussed in more detail below:
         </p>
 
-        <pre class="brush:java">
-        package org.apache.pivot.tutorials.webqueries.server;
-
-        import java.io.IOException;
-        import java.io.InputStream;
-        import java.net.MalformedURLException;
-        import java.net.URL;
-
-        import javax.servlet.ServletException;
-
-        import org.apache.pivot.collections.HashMap;
-        import org.apache.pivot.collections.List;
-        import org.apache.pivot.json.JSONSerializer;
-        import org.apache.pivot.serialization.CSVSerializer;
-        import org.apache.pivot.serialization.SerializationException;
-        import org.apache.pivot.serialization.Serializer;
-        import org.apache.pivot.web.Query;
-        import org.apache.pivot.web.QueryException;
-        import org.apache.pivot.web.server.QueryServlet;
-
-        /**
-         * Servlet that implements expense management web service.
-         */
-        public class ExpenseServlet extends QueryServlet {
-            private static final long serialVersionUID = 0;
-
-            private List&lt;Expense&gt; expenses = null;
-            private HashMap&lt;Integer, Expense&gt; expenseMap = new HashMap&lt;Integer, Expense&gt;();
-
-            private static int nextID = 0;
-
-            @Override
-            @SuppressWarnings("unchecked")
-            public void init() throws ServletException {
-                CSVSerializer csvSerializer = new CSVSerializer();
-                csvSerializer.getKeys().add("date");
-                csvSerializer.getKeys().add("type");
-                csvSerializer.getKeys().add("amount");
-                csvSerializer.getKeys().add("description");
-                csvSerializer.setItemClass(Expense.class);
-
-                // Load the initial expense data
-                InputStream inputStream = ExpenseServlet.class.getResourceAsStream("expenses.csv");
+        <source type="java" location="org/apache/pivot/tutorials/webqueries/server/ExpenseServlet.java">
+            <![CDATA[
+            package org.apache.pivot.tutorials.webqueries.server;
+
+            import java.io.IOException;
+            import java.io.InputStream;
+            import java.net.MalformedURLException;
+            import java.net.URL;
+
+            import javax.servlet.ServletException;
+
+            import org.apache.pivot.collections.HashMap;
+            import org.apache.pivot.collections.List;
+            import org.apache.pivot.json.JSONSerializer;
+            import org.apache.pivot.serialization.CSVSerializer;
+            import org.apache.pivot.serialization.SerializationException;
+            import org.apache.pivot.serialization.Serializer;
+            import org.apache.pivot.web.Query;
+            import org.apache.pivot.web.QueryException;
+            import org.apache.pivot.web.server.QueryServlet;
+
+            /**
+             * Servlet that implements expense management web service.
+             */
+            public class ExpenseServlet extends QueryServlet {
+                private static final long serialVersionUID = 0;
+
+                private List&lt;Expense&gt; expenses = null;
+                private HashMap&lt;Integer, Expense&gt; expenseMap = new HashMap&lt;Integer, Expense&gt;();
+
+                private static int nextID = 0;
+
+                @Override
+                @SuppressWarnings("unchecked")
+                public void init() throws ServletException {
+                    CSVSerializer csvSerializer = new CSVSerializer();
+                    csvSerializer.getKeys().add("date");
+                    csvSerializer.getKeys().add("type");
+                    csvSerializer.getKeys().add("amount");
+                    csvSerializer.getKeys().add("description");
+                    csvSerializer.setItemClass(Expense.class);
+
+                    // Load the initial expense data
+                    InputStream inputStream = ExpenseServlet.class.getResourceAsStream("expenses.csv");
+
+                    try {
+                        expenses = (List&lt;Expense&gt;)csvSerializer.readObject(inputStream);
+                    } catch (IOException exception) {
+                        throw new ServletException(exception);
+                    } catch (SerializationException exception) {
+                        throw new ServletException(exception);
+                    }
 
-                try {
-                    expenses = (List&lt;Expense&gt;)csvSerializer.readObject(inputStream);
-                } catch (IOException exception) {
-                    throw new ServletException(exception);
-                } catch (SerializationException exception) {
-                    throw new ServletException(exception);
+                    // Index the initial expenses
+                    for (Expense expense : expenses) {
+                        int id = nextID++;
+                        expense.setID(id);
+                        expenseMap.put(id, expense);
+                    }
                 }
 
-                // Index the initial expenses
-                for (Expense expense : expenses) {
-                    int id = nextID++;
-                    expense.setID(id);
-                    expenseMap.put(id, expense);
+                @Override
+                protected Object doGet(Path path) throws QueryException {
+                    Object value;
+
+                    if (path.getLength() == 0) {
+                        value = expenses;
+                    } else {
+                        // Get the ID of the expense to retrieve from the path
+                        int id = Integer.parseInt(path.get(0));
+
+                        // Get the expense data from the map
+                        synchronized (this) {
+                            value = expenseMap.get(id);
+                        }
+
+                        if (value == null) {
+                            throw new QueryException(Query.Status.NOT_FOUND);
+                        }
+                    }
+
+                    return value;
                 }
-            }
 
-            @Override
-            protected Object doGet(Path path) throws QueryException {
-                Object value;
+                @Override
+                protected URL doPost(Path path, Object value) throws QueryException {
+                    if (value == null) {
+                        throw new QueryException(Query.Status.BAD_REQUEST);
+                    }
 
-                if (path.getLength() == 0) {
-                    value = expenses;
-                } else {
-                    // Get the ID of the expense to retrieve from the path
-                    int id = Integer.parseInt(path.get(0));
+                    Expense expense = (Expense)value;
 
-                    // Get the expense data from the map
+                    // Add the expense to the list/map
+                    int id;
                     synchronized (this) {
-                        value = expenseMap.get(id);
+                        id = nextID++;
+                        expense.setID(id);
+                        expenses.add(expense);
+                        expenseMap.put(id, expense);
                     }
 
-                    if (value == null) {
-                        throw new QueryException(Query.Status.NOT_FOUND);
+                    // Return the location of the newly-created resource
+                    URL location = getLocation();
+                    try {
+                        location = new URL(location, Integer.toString(id));
+                    } catch (MalformedURLException exception) {
+                        throw new QueryException(Query.Status.INTERNAL_SERVER_ERROR);
                     }
-                }
-
-                return value;
-            }
 
-            @Override
-            protected URL doPost(Path path, Object value) throws QueryException {
-                if (value == null) {
-                    throw new QueryException(Query.Status.BAD_REQUEST);
-                }
-
-                Expense expense = (Expense)value;
-
-                // Add the expense to the list/map
-                int id;
-                synchronized (this) {
-                    id = nextID++;
-                    expense.setID(id);
-                    expenses.add(expense);
-                    expenseMap.put(id, expense);
-                }
-
-                // Return the location of the newly-created resource
-                URL location = getLocation();
-                try {
-                    location = new URL(location, Integer.toString(id));
-                } catch (MalformedURLException exception) {
-                    throw new QueryException(Query.Status.INTERNAL_SERVER_ERROR);
+                    return location;
                 }
 
-                return location;
-            }
+                @Override
+                protected boolean doPut(Path path, Object value) throws QueryException {
+                    if (path.getLength() == 0
+                        || value == null) {
+                        throw new QueryException(Query.Status.BAD_REQUEST);
+                    }
 
-            @Override
-            protected boolean doPut(Path path, Object value) throws QueryException {
-                if (path.getLength() == 0
-                    || value == null) {
-                    throw new QueryException(Query.Status.BAD_REQUEST);
-                }
+                    // Get the ID of the expense to retrieve from the path
+                    int id = Integer.parseInt(path.get(0));
 
-                // Get the ID of the expense to retrieve from the path
-                int id = Integer.parseInt(path.get(0));
+                    // Create the new expense and bind the data to it
+                    Expense expense = (Expense)value;
+                    expense.setID(id);
 
-                // Create the new expense and bind the data to it
-                Expense expense = (Expense)value;
-                expense.setID(id);
+                    // Update the list/map
+                    Expense previousExpense;
+                    synchronized (this) {
+                        previousExpense = expenseMap.put(id, expense);
+                        expenses.remove(previousExpense);
+                        expenses.add(expense);
+                    }
 
-                // Update the list/map
-                Expense previousExpense;
-                synchronized (this) {
-                    previousExpense = expenseMap.put(id, expense);
-                    expenses.remove(previousExpense);
-                    expenses.add(expense);
+                    return (previousExpense == null);
                 }
 
-                return (previousExpense == null);
-            }
+                @Override
+                protected void doDelete(Path path) throws QueryException {
+                    if (path.getLength() == 0) {
+                        throw new QueryException(Query.Status.BAD_REQUEST);
+                    }
 
-            @Override
-            protected void doDelete(Path path) throws QueryException {
-                if (path.getLength() == 0) {
-                    throw new QueryException(Query.Status.BAD_REQUEST);
-                }
+                    // Get the ID of the expense to retrieve from the path
+                    int id = Integer.parseInt(path.get(0));
 
-                // Get the ID of the expense to retrieve from the path
-                int id = Integer.parseInt(path.get(0));
+                    // Update the list/map
+                    Expense expense;
+                    synchronized (this) {
+                        expense = expenseMap.remove(id);
+                        expenses.remove(expense);
+                    }
 
-                // Update the list/map
-                Expense expense;
-                synchronized (this) {
-                    expense = expenseMap.remove(id);
-                    expenses.remove(expense);
+                    if (expense == null) {
+                        throw new QueryException(Query.Status.NOT_FOUND);
+                    }
                 }
 
-                if (expense == null) {
-                    throw new QueryException(Query.Status.NOT_FOUND);
+                @Override
+                protected Serializer&lt;?&gt; createSerializer(Path path) throws QueryException {
+                    return new JSONSerializer(Expense.class);
                 }
             }
-
-            @Override
-            protected Serializer&lt;?&gt; createSerializer(Path path) throws QueryException {
-                return new JSONSerializer(Expense.class);
-            }
-        }
-        </pre>
+            ]]>
+        </source>
 
         <h3>init()</h3>
 
@@ -309,34 +311,36 @@ limitations under the License.
             <tt>ExpenseServlet</tt>'s implementation of <tt>init()</tt> is as follows:
         </p>
 
-        <pre class="brush:java">
-        public void init() throws ServletException {
-            CSVSerializer csvSerializer = new CSVSerializer();
-            csvSerializer.getKeys().add("date");
-            csvSerializer.getKeys().add("type");
-            csvSerializer.getKeys().add("amount");
-            csvSerializer.getKeys().add("description");
-            csvSerializer.setItemClass(Expense.class);
-
-            // Load the initial expense data
-            InputStream inputStream = ExpenseServlet.class.getResourceAsStream("expenses.csv");
-
-            try {
-                expenses = (List&lt;Expense&gt;)csvSerializer.readObject(inputStream);
-            } catch (IOException exception) {
-                throw new ServletException(exception);
-            } catch (SerializationException exception) {
-                throw new ServletException(exception);
-            }
+        <source type="java">
+            <![CDATA[
+            public void init() throws ServletException {
+                CSVSerializer csvSerializer = new CSVSerializer();
+                csvSerializer.getKeys().add("date");
+                csvSerializer.getKeys().add("type");
+                csvSerializer.getKeys().add("amount");
+                csvSerializer.getKeys().add("description");
+                csvSerializer.setItemClass(Expense.class);
 
-            // Index the initial expenses
-            for (Expense expense : expenses) {
-                int id = nextID++;
-                expense.setID(id);
-                expenseMap.put(id, expense);
+                // Load the initial expense data
+                InputStream inputStream = ExpenseServlet.class.getResourceAsStream("expenses.csv");
+
+                try {
+                    expenses = (List&lt;Expense&gt;)csvSerializer.readObject(inputStream);
+                } catch (IOException exception) {
+                    throw new ServletException(exception);
+                } catch (SerializationException exception) {
+                    throw new ServletException(exception);
+                }
+
+                // Index the initial expenses
+                for (Expense expense : expenses) {
+                    int id = nextID++;
+                    expense.setID(id);
+                    expenseMap.put(id, expense);
+                }
             }
-        }
-        </pre>
+            ]]>
+        </source>
 
         <p>
             It loads an initial list of expenses using an instance of <tt>CSVSerializer</tt>. The
@@ -360,69 +364,71 @@ limitations under the License.
             Bean class that is defined as follows:
         </p>
 
-        <pre class="brush:java">
-        package org.apache.pivot.tutorials.webqueries.server;
+        <source type="java" location="org/apache/pivot/tutorials/webqueries/server/Expense.java">
+            <![CDATA[
+            package org.apache.pivot.tutorials.webqueries.server;
 
-        public class Expense {
-            private Integer id = -1;
-            private String date = null;
-            private String type = null;
-            private Double amount = 0d;
-            private String description = null;
+            public class Expense {
+                private Integer id = -1;
+                private String date = null;
+                private String type = null;
+                private Double amount = 0d;
+                private String description = null;
 
-            public Integer getID() {
-                return id;
-            }
+                public Integer getID() {
+                    return id;
+                }
 
-            public Integer getId() {
-                return getID();
-            }
+                public Integer getId() {
+                    return getID();
+                }
 
-            public void setID(Integer id) {
-                this.id = id;
-            }
+                public void setID(Integer id) {
+                    this.id = id;
+                }
 
-            public void setId(Integer id) {
-                setID(id);
-            }
+                public void setId(Integer id) {
+                    setID(id);
+                }
 
-            public String getDate() {
-                return date;
-            }
+                public String getDate() {
+                    return date;
+                }
 
-            public void setDate(String date) {
-                this.date = date;
-            }
+                public void setDate(String date) {
+                    this.date = date;
+                }
 
-            public String getType() {
-                return type;
-            }
+                public String getType() {
+                    return type;
+                }
 
-            public void setType(String type) {
-                this.type = type;
-            }
+                public void setType(String type) {
+                    this.type = type;
+                }
 
-            public Double getAmount() {
-                return amount;
-            }
+                public Double getAmount() {
+                    return amount;
+                }
 
-            public void setAmount(Double amount) {
-                this.amount = amount;
-            }
+                public void setAmount(Double amount) {
+                    this.amount = amount;
+                }
 
-            public final void setAmount(String amount) {
-                setAmount(Double.parseDouble(amount));
-            }
+                public final void setAmount(String amount) {
+                    setAmount(Double.parseDouble(amount));
+                }
 
-            public String getDescription() {
-                return description;
-            }
+                public String getDescription() {
+                    return description;
+                }
 
-            public void setDescription(String description) {
-                this.description = description;
+                public void setDescription(String description) {
+                    this.description = description;
+                }
             }
-        }
-        </pre>
+            ]]>
+        </source>
 
         <p>
             After the list of expenses has been loaded, <tt>init()</tt> iterates over the list,
@@ -439,29 +445,31 @@ limitations under the License.
             servlet is defined as follows:
         </p>
 
-        <pre class="brush:java">
-        protected Object doGet(Path path) throws QueryException {
-            Object value;
-
-            if (path.getLength() == 0) {
-                value = expenses;
-            } else {
-                // Get the ID of the expense to retrieve from the path
-                int id = Integer.parseInt(path.get(0));
+        <source type="java">
+            <![CDATA[
+            protected Object doGet(Path path) throws QueryException {
+                Object value;
 
-                // Get the expense data from the map
-                synchronized (this) {
-                    value = expenseMap.get(id);
-                }
+                if (path.getLength() == 0) {
+                    value = expenses;
+                } else {
+                    // Get the ID of the expense to retrieve from the path
+                    int id = Integer.parseInt(path.get(0));
 
-                if (value == null) {
-                    throw new QueryException(Query.Status.NOT_FOUND);
+                    // Get the expense data from the map
+                    synchronized (this) {
+                        value = expenseMap.get(id);
+                    }
+
+                    if (value == null) {
+                        throw new QueryException(Query.Status.NOT_FOUND);
+                    }
                 }
-            }
 
-            return value;
-        }
-        </pre>
+                return value;
+            }
+            ]]>
+        </source>
 
         <p>
             If the request does not contain a path, the method returns the list of all expenses.
@@ -493,34 +501,36 @@ limitations under the License.
             The <tt>doPost()</tt> method in the example looks like this:
         </p>
 
-        <pre class="brush:java">
-        protected URL doPost(Path path, Object value) throws QueryException {
-            if (value == null) {
-                throw new QueryException(Query.Status.BAD_REQUEST);
-            }
+        <source type="java">
+            <![CDATA[
+            protected URL doPost(Path path, Object value) throws QueryException {
+                if (value == null) {
+                    throw new QueryException(Query.Status.BAD_REQUEST);
+                }
 
-            Expense expense = (Expense)value;
+                Expense expense = (Expense)value;
 
-            // Add the expense to the list/map
-            int id;
-            synchronized (this) {
-                id = nextID++;
-                expense.setID(id);
-                expenses.add(expense);
-                expenseMap.put(id, expense);
-            }
+                // Add the expense to the list/map
+                int id;
+                synchronized (this) {
+                    id = nextID++;
+                    expense.setID(id);
+                    expenses.add(expense);
+                    expenseMap.put(id, expense);
+                }
 
-            // Return the location of the newly-created resource
-            URL location = getLocation();
-            try {
-                location = new URL(location, Integer.toString(id));
-            } catch (MalformedURLException exception) {
-                throw new QueryException(Query.Status.INTERNAL_SERVER_ERROR);
-            }
+                // Return the location of the newly-created resource
+                URL location = getLocation();
+                try {
+                    location = new URL(location, Integer.toString(id));
+                } catch (MalformedURLException exception) {
+                    throw new QueryException(Query.Status.INTERNAL_SERVER_ERROR);
+                }
 
-            return location;
-        }
-        </pre>
+                return location;
+            }
+            ]]>
+        </source>
 
         <p>
             The first thing the method does is ensure that the request is valid. If the caller has
@@ -548,31 +558,33 @@ limitations under the License.
             <tt>ExpenseServlet</tt>'s implementation of <tt>doPut()</tt> is as follows:
         </p>
 
-        <pre class="brush:java">
-        protected boolean doPut(Path path, Object value) throws QueryException {
-            if (path.getLength() == 0
-                || value == null) {
-                throw new QueryException(Query.Status.BAD_REQUEST);
-            }
+        <source type="java">
+            <![CDATA[
+            protected boolean doPut(Path path, Object value) throws QueryException {
+                if (path.getLength() == 0
+                    || value == null) {
+                    throw new QueryException(Query.Status.BAD_REQUEST);
+                }
+
+                // Get the ID of the expense to retrieve from the path
+                int id = Integer.parseInt(path.get(0));
 
-            // Get the ID of the expense to retrieve from the path
-            int id = Integer.parseInt(path.get(0));
+                // Create the new expense and bind the data to it
+                Expense expense = (Expense)value;
+                expense.setID(id);
 
-            // Create the new expense and bind the data to it
-            Expense expense = (Expense)value;
-            expense.setID(id);
-
-            // Update the list/map
-            Expense previousExpense;
-            synchronized (this) {
-                previousExpense = expenseMap.put(id, expense);
-                expenses.remove(previousExpense);
-                expenses.add(expense);
-            }
+                // Update the list/map
+                Expense previousExpense;
+                synchronized (this) {
+                    previousExpense = expenseMap.put(id, expense);
+                    expenses.remove(previousExpense);
+                    expenses.add(expense);
+                }
 
-            return (previousExpense == null);
-        }
-        </pre>
+                return (previousExpense == null);
+            }
+            ]]>
+        </source>
 
         <p>
             Like <tt>doPost()</tt>, it first validates the format of the request. In addition to a
@@ -591,27 +603,29 @@ limitations under the License.
             this method is shown below:
         </p>
 
-        <pre class="brush:java">
-        protected void doDelete(Path path) throws QueryException {
-            if (path.getLength() == 0) {
-                throw new QueryException(Query.Status.BAD_REQUEST);
-            }
+        <source type="java">
+            <![CDATA[
+            protected void doDelete(Path path) throws QueryException {
+                if (path.getLength() == 0) {
+                    throw new QueryException(Query.Status.BAD_REQUEST);
+                }
 
-            // Get the ID of the expense to retrieve from the path
-            int id = Integer.parseInt(path.get(0));
+                // Get the ID of the expense to retrieve from the path
+                int id = Integer.parseInt(path.get(0));
 
-            // Update the list/map
-            Expense expense;
-            synchronized (this) {
-                expense = expenseMap.remove(id);
-                expenses.remove(expense);
-            }
+                // Update the list/map
+                Expense expense;
+                synchronized (this) {
+                    expense = expenseMap.remove(id);
+                    expenses.remove(expense);
+                }
 
-            if (expense == null) {
-                throw new QueryException(Query.Status.NOT_FOUND);
+                if (expense == null) {
+                    throw new QueryException(Query.Status.NOT_FOUND);
+                }
             }
-        }
-        </pre>
+            ]]>
+        </source>
 
         <p>
             Like the other methods, the request is first validated; then, if the expense exists,