pivot-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Greg Brown <gkbr...@mac.com>
Subject Re: dynamic treeview example
Date Wed, 17 Feb 2010 13:58:11 GMT
Another option is to use the Bindable interface. Assuming that your top-level WTKX element
is a Window, create a subclass that implements Bindable and use that as your root element
instead:

public class MyWindow extends Window implements Bindable {
    @WTKX private TreeView treeView = null;

    @Override
    public void initialize(Resources resources) {
        // Add your nodes to treeView, attach listeners, etc.
    }
}

In WTKX:

<foo:MyWindow title="My Window Title" maximized="true"
    xmlns:wtkx="http://pivot.apache.org/wtkx"
    xmlns:foo="com.foo"
    xmlns="org.apache.pivot.wtk">
    <content>
        <TreeView wtkx:id="treeView"/>
    </content>
</foo:MyWindow>

When initialize() is called, all of the annotated member variables will have been automatically
bound to the corresponding values in the WTKX file.

Note that the Resources argument was added for Pivot 1.4.1, which has not yet been released
- the 1.4 version does not define any arguments.

G


On Feb 17, 2010, at 6:37 AM, Todd Volkert wrote:

> Hi Steven,
> 
> First, I'd move your wtkxSerializer.readObject() call to be right below the serializer
instantiation, and I'd follow it with a wtkxSerializer.bind(this) call to apply the @WTKX
bindings.  Then you should remove the 'treeView = new TreeView()' line, because it'll cause
you to blow away the tree view that's defined in WTKX.
> 
> Hope that helps,
> -T
> 
> On Tue, Feb 16, 2010 at 11:46 PM, Pivot-Steven Dahlin <pivot.sdahlin@gmail.com>
wrote:
> I cannot get the tree view to work.  I have a wtkx file with the following for the treeview:
> <view>
>   <TreeView wtkx:id="treeView">
>     <nodeRenderer>
>       <content:TreeViewNodeRenderer showIcon="false"/>
>     </nodeRenderer>
>   </TreeView>
> </view>
> 
> In my java code I have the following:
> 
>     private Window window = null;
>     @WTKX private TreeView treeView = null;
>     @WTKX private TreeBranch treeBranch = null;
> 
>     @Override
>     public void startup( Display display,
>                          Map<String,
>                          String> properties )
>       throws Exception
>     {
>         Resources resources = new Resources(getClass().getName(), "UTF-8");
>         WTKXSerializer wtkxSerializer = new WTKXSerializer(resources);
> 
>         treeView = new TreeView();
>         
>         treeBranch = new TreeBranch();
>         
>         TreeNode node = new TreeNode();
>         node.setText( "node1" );
>         treeBranch.add(node);
> 
>         node = new TreeNode();
>         node.setText( "node2" );
>         treeBranch.add(node);
> 
>         node = new TreeNode();
>         node.setText( "node3" );
>         treeBranch.add(node);
>         
>         treeView.setTreeData( treeBranch );
> 
>         window = (Window) wtkxSerializer.readObject( this,
>                                                      "PassTracker.wtkx");
>         window.open(display);
>     }
> 
> Just a simple test but the treeview does not appear.  Does anyone have any suggestions
as to what I am doing wrong?
> 
> Thanks
> 


Mime
View raw message