<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements.  See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to you under the Apache License,
Version 2.0 (the "License"); you may not use this file except in
compliance with the License.  You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->

<document id="tree-views">
    <properties>
        <title>Tree Views</title>
        <explore>TreeView</explore>
    </properties>

    <body>
        <p>
            Tree views are used to present nested lists of data that form a hierarchy. A tree
            view's data is specified just like that of a <a href="lists.html">list view</a>,
            but any item in the tree data that is itself an instance of
            <tt>org.apache.pivot.collections.List</tt> will be treated as a branch in the tree,
            and the user will be able to expand the branch to see its children.
        </p>

        <p>
            The following example shows a basic tree view. This example specifies the tree data as
            the contents of <tt>tree_data.bxml</tt>. For the purpose of this example, this data is
            static. A real application could load dynamic data and use a custom renderer to present
            the raw data straight to the user.
        </p>

        <application class="org.apache.pivot.wtk.ScriptApplication" width="300" height="300">
            <libraries>
                <library>core</library>
                <library>wtk</library>
                <library>wtk-terra</library>
                <library>tutorials</library>
            </libraries>
            <startup-properties>
                <src>/org/apache/pivot/tutorials/treeviews/tree_views.bxml</src>
            </startup-properties>
        </application>

        <p>The BXML for this example is shown below:</p>

        <source type="xml" location="org/apache/pivot/tutorials/treeviews/tree_views.bxml">
            <![CDATA[
            <Window title="Tree Views" maximized="true"
                xmlns:bxml="http://pivot.apache.org/bxml"
                xmlns="org.apache.pivot.wtk">
                <Border>
                    <ScrollPane horizontalScrollBarPolicy="fill_to_capacity">
                        <TreeView>
                            <treeData>
                                <bxml:include src="tree_data.bxml"/>
                            </treeData>
                        </TreeView>
                    </ScrollPane>
                </Border>
            </Window>
            ]]>
        </source>

        <p>
            The BXML that defines the tree data is shown below.
        </p>

        <source type="xml" location="org/apache/pivot/tutorials/treeviews/tree_data.bxml">
            <![CDATA[
            <TreeBranch xmlns="org.apache.pivot.wtk.content">
                <TreeBranch text="Activity" icon="/org/apache/pivot/tutorials/folder.png">
                    <TreeBranch text="Games" icon="/org/apache/pivot/tutorials/folder.png">
                        <TreeNode text="Foosball" icon="/org/apache/pivot/tutorials/page_white.png"/>
                        <TreeNode text="Ping Pong" icon="/org/apache/pivot/tutorials/page_white.png"/>
                        <TreeNode text="Air Hockey" icon="/org/apache/pivot/tutorials/page_white.png"/>
                    </TreeBranch>
                    <TreeBranch text="Sports" icon="/org/apache/pivot/tutorials/folder.png">
                        <TreeNode text="Baseball" icon="/org/apache/pivot/tutorials/page_white.png"/>
                        <TreeNode text="Basketball" icon="/org/apache/pivot/tutorials/page_white.png"/>
                        <TreeNode text="Football" icon="/org/apache/pivot/tutorials/page_white.png"/>
                        <TreeNode text="Ice Hockey" icon="/org/apache/pivot/tutorials/page_white.png"/>
                        <TreeNode text="Soccer" icon="/org/apache/pivot/tutorials/page_white.png"/>
                        <TreeNode text="Softball" icon="/org/apache/pivot/tutorials/page_white.png"/>
                    </TreeBranch>
                    <TreeNode text="Camping" icon="/org/apache/pivot/tutorials/page_white.png"/>
                    <TreeNode text="Skiing" icon="/org/apache/pivot/tutorials/page_white.png"/>
                </TreeBranch>
                <TreeBranch text="Occasion" icon="/org/apache/pivot/tutorials/folder.png">
                    <TreeBranch text="Holidays" icon="/org/apache/pivot/tutorials/folder.png">
                        <TreeNode text="Christmas" icon="/org/apache/pivot/tutorials/page_white.png"/>
                        <TreeNode text="Independence Day" icon="/org/apache/pivot/tutorials/page_white.png"/>
                        <TreeNode text="Labor Day" icon="/org/apache/pivot/tutorials/page_white.png"/>
                        <TreeNode text="New Year's Day" icon="/org/apache/pivot/tutorials/page_white.png"/>
                        <TreeNode text="President's Day" icon="/org/apache/pivot/tutorials/page_white.png"/>
                        <TreeNode text="Thanksgiving" icon="/org/apache/pivot/tutorials/page_white.png"/>
                        <TreeNode text="Valentine's Day" icon="/org/apache/pivot/tutorials/page_white.png"/>
                        <TreeNode text="Veteran's Day" icon="/org/apache/pivot/tutorials/page_white.png"/>
                    </TreeBranch>
                    <TreeNode text="Anniversary" icon="/org/apache/pivot/tutorials/page_white.png"/>
                    <TreeNode text="Birthday" icon="/org/apache/pivot/tutorials/page_white.png"/>
                    <TreeNode text="Wedding" icon="/org/apache/pivot/tutorials/page_white.png"/>
                </TreeBranch>
                <TreeBranch text="Location" icon="/org/apache/pivot/tutorials/folder.png">
                    <TreeNode text="Africa" icon="/org/apache/pivot/tutorials/folder.png"/>
                    <TreeNode text="Antarctica" icon="/org/apache/pivot/tutorials/folder.png"/>
                    <TreeNode text="Asia" icon="/org/apache/pivot/tutorials/folder.png"/>
                    <TreeNode text="Australia" icon="/org/apache/pivot/tutorials/folder.png"/>
                    <TreeNode text="Europe" icon="/org/apache/pivot/tutorials/folder.png"/>
                    <TreeNode text="North America" icon="/org/apache/pivot/tutorials/folder.png"/>
                    <TreeBranch text="South America" icon="/org/apache/pivot/tutorials/folder.png">
                        <TreeNode text="Peru" icon="/org/apache/pivot/tutorials/page_white.png"/>
                    </TreeBranch>
                </TreeBranch>
            </TreeBranch>
            ]]>
        </source>

        <p>
            Since this example is written entirely in BXML, there is no associated Java source.
        </p>
    </body>
</document>
