You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@pivot.apache.org by Eugene Kondrashev <eu...@gmail.com> on 2010/12/10 20:12:30 UTC

Checkmark enabled TreeView

Hi guys!

Ive created a checkmark enabled tree view with mixed mode feature. Here I
faced with two problems:
1. tree node text lable is shiffed relative to checkbox icon. It seems like
there should be a treeNode icon, but i did not set any icons for the node,
why it shows that free space bettween check box and a text label?
2. I wonder if mixed mode "correct" behaviour is implemented by default. By
correct behaviour i meen example at
http://pivot.apache.org/demos/kitchen-sink.html Trees section.
One of the problem here is that parent node is not getting checked
automatically when all child nodes are checked by user. And vise versa -
child nodes are not getting checked while checking parent node.
I can't find sources of example at kitched-sink page regarding Trees. Can
you help me with that, please?



My code wtkx:
<gsq:GSQCustomerProfileController
        xmlns:wtkx="http://pivot.apache.org/wtkx"
        xmlns="org.apache.pivot.wtk"
        xmlns:gsq="com.mbt.client.gui.pivot.modules">
    <Border>
        <content>
            <TablePane>
                <columns>
                    <TablePane.Column width="-1"/>
                    <TablePane.Column width="1*"/>
                </columns>
                <rows>
                    <TablePane.Row height="-1">
                        <BoxPane styles="{padding:4, spacing:4, fill:true}">
                            <Border styles="{color:10}">
                                <content>
                                    <ScrollPane
horizontalScrollBarPolicy="fill" minimumPreferredWidth="70"

 verticalScrollBarPolicy="fill_to_capacity">
                                        <view>
                                            <TreeView wtkx:id="clustersTree"
showMixedCheckmarkState="true" checkmarksEnabled="true">
                                            </TreeView>
                                        </view>
                                    </ScrollPane>
                                </content>
                            </Border>
                        </BoxPane>
                        <CardPane wtkx:id="criteriaCardPane">
                        </CardPane>
                    </TablePane.Row>
                </rows>
            </TablePane>
        </content>
    </Border>
</gsq:GSQCustomerProfileController>

Oh, and one more thing. Let say i have aList of some data object with
enabled flag as internal field. As I understood from the api, I need to
create org.apache.pivot.collections.List<TreeBranch> from java.util.List and
then iterate over tree nodes once again setting enabled flag.. If so that is
really paintfull.

Perhaps I'm doing something wrong, please tell me if so.

        public void handleResponse(List<Cluster> retrievedClusters) {
            org.apache.pivot.collections.List<TreeBranch> clusters = new
LinkedList<TreeBranch>();
            for (Cluster cluster : retrievedClusters) {
                TreeBranch treeBranch = new TreeBranch(cluster.getName());
                for (Criteria criteria : cluster.getCriteria())
                    treeBranch.insert(new TreeNode(criteria.getName()), 0);
                clusters.add(treeBranch);
            }
            clustersTree.setTreeData(clusters);
        }

Thanks,
Eugene

Re: Checkmark enabled TreeView

Posted by Eugene Kondrashev <eu...@gmail.com>.
Thanks a lot!

2010/12/10 Chris Bartlett <cb...@gmail.com>

> Eugene,
>
> Firstly, the Pivot source code for the 1.5.2 release is available on the
> download page here
> http://pivot.apache.org/download.cgi#1.5.2
>
> Or from SVN here
> http://svn.apache.org/repos/asf/pivot/tags/v1.5.2/
>
> The latest 2.0 source is here
> http://svn.apache.org/repos/asf/pivot/trunk/
>
> The KitchenSink demo is located in the 'tutorials' project here
>
> http://svn.apache.org/repos/asf/pivot/tags/v1.5.2/tutorials/src/org/apache/pivot/tutorials/
>
> http://svn.apache.org/repos/asf/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/
>
>
>
> 1) If you are using a org.apache.pivot.wtk.content.TreeViewNodeRenderer to
> render the TreeView, then be aware that it has a 'showIcon' property.
>
> http://svn.apache.org/repos/asf/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/explorer/tools/event_logger_skin.bxml
>
>
> 2)
> It sounds like you are trying to replicate the behaviour that can be seen
> in the EventLogger window at the bottom right hand side of the
> ComponentExplorer window.
> http://pivot.apache.org/demos/component-explorer.html
>
> Have a look here, and search for the following string
> '// Propagate check state upwards or downwards as necessary'
>
> http://svn.apache.org/repos/asf/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/explorer/tools/EventLoggerSkin.java
>
>
> 3)
> Are you aware of the disabledCheckmarkFilter and disabledNodeFilter
> properties of TableView?
>
> http://pivot.apache.org/1.5.2/docs/api/org/apache/pivot/wtk/TreeView.html#setDisabledNodeFilter(org.apache.pivot.util.Filter)
>
> If you provide a Filter which knows how to determine your internal
> 'enabled' flag, the TreeView should take care of the rest.
> Search for 'checkTreeView.setDisabledNodeFilter(new Filter<TreeNode>() {'
> here
>
> http://svn.apache.org/repos/asf/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/KitchenSink.java
>
>
> Chris
>
> On 11 December 2010 02:12, Eugene Kondrashev <eu...@gmail.com>wrote:
>
>> Hi guys!
>>
>> Ive created a checkmark enabled tree view with mixed mode feature. Here I
>> faced with two problems:
>> 1. tree node text lable is shiffed relative to checkbox icon. It seems
>> like there should be a treeNode icon, but i did not set any icons for the
>> node, why it shows that free space bettween check box and a text label?
>> 2. I wonder if mixed mode "correct" behaviour is implemented by default.
>> By correct behaviour i meen example at
>> http://pivot.apache.org/demos/kitchen-sink.html Trees section.
>> One of the problem here is that parent node is not getting checked
>> automatically when all child nodes are checked by user. And vise versa -
>> child nodes are not getting checked while checking parent node.
>> I can't find sources of example at kitched-sink page regarding Trees. Can
>> you help me with that, please?
>>
>>
>>
>> My code wtkx:
>> <gsq:GSQCustomerProfileController
>>         xmlns:wtkx="http://pivot.apache.org/wtkx"
>>         xmlns="org.apache.pivot.wtk"
>>         xmlns:gsq="com.mbt.client.gui.pivot.modules">
>>     <Border>
>>         <content>
>>             <TablePane>
>>                 <columns>
>>                     <TablePane.Column width="-1"/>
>>                     <TablePane.Column width="1*"/>
>>                 </columns>
>>                 <rows>
>>                     <TablePane.Row height="-1">
>>                         <BoxPane styles="{padding:4, spacing:4,
>> fill:true}">
>>                             <Border styles="{color:10}">
>>                                 <content>
>>                                     <ScrollPane
>> horizontalScrollBarPolicy="fill" minimumPreferredWidth="70"
>>
>>  verticalScrollBarPolicy="fill_to_capacity">
>>                                         <view>
>>                                             <TreeView
>> wtkx:id="clustersTree" showMixedCheckmarkState="true"
>> checkmarksEnabled="true">
>>                                             </TreeView>
>>                                         </view>
>>                                     </ScrollPane>
>>                                 </content>
>>                             </Border>
>>                         </BoxPane>
>>                         <CardPane wtkx:id="criteriaCardPane">
>>                         </CardPane>
>>                     </TablePane.Row>
>>                 </rows>
>>             </TablePane>
>>         </content>
>>     </Border>
>> </gsq:GSQCustomerProfileController>
>>
>> Oh, and one more thing. Let say i have aList of some data object with
>> enabled flag as internal field. As I understood from the api, I need to
>> create org.apache.pivot.collections.List<TreeBranch> from java.util.List and
>> then iterate over tree nodes once again setting enabled flag.. If so that is
>> really paintfull.
>>
>> Perhaps I'm doing something wrong, please tell me if so.
>>
>>         public void handleResponse(List<Cluster> retrievedClusters) {
>>             org.apache.pivot.collections.List<TreeBranch> clusters = new
>> LinkedList<TreeBranch>();
>>             for (Cluster cluster : retrievedClusters) {
>>                 TreeBranch treeBranch = new TreeBranch(cluster.getName());
>>                 for (Criteria criteria : cluster.getCriteria())
>>                     treeBranch.insert(new TreeNode(criteria.getName()),
>> 0);
>>                 clusters.add(treeBranch);
>>             }
>>             clustersTree.setTreeData(clusters);
>>          }
>>
>> Thanks,
>> Eugene
>>
>
>

Re: Checkmark enabled TreeView

Posted by Eugene Kondrashev <eu...@gmail.com>.
That was exactly what i needed.

Thanks again!

2010/12/13 Chris Bartlett <cb...@gmail.com>

> Eugene,
>
> OK, I think I understand now.
>
> Is this right?
> - You have a some data that needs to be represented in a TreeView.
> - That data consists of your objects, some of which contain an flag to
> represent some kind of state.
> - You want the TreeView to display this state as a checked checkbox.
>
>
> TreeView maintains an internal list of checked nodes.
> This list can queried with
> - isNodeChecked(Path)
> - getCheckedPaths()
> - getNodeCheckState(Path)
> but can only be altered externally via
> - setNodeChecked(Path, boolean)
>
> So ultimately I think you will need to call setNodeChecked(Path, boolean)
> unless you create a subclass of TreeView and handle the checkbox state
> yourself somehow.
>
> I have attached some sample code to show that this should not be a
> particularly difficult task.  (It was written against the pre-release Pivot
> 2.0 and checked against 1.5.2.)
> You can use the 'userData' property of TreeNode and TreeView to hold a
> reference to your real object.
> You can easily iterate over a tree of data using
> org.apache.pivot.collections.Sequence.Tree.DepthFirstItemIterator.
>
> If required you can register listeners for when the checked state changes
> if you need to update your own object's state.  (Not shown in the demo)
>
> While this example uses the provided TreeView and TreeNode classes, you do
> not have to.
> See here http://pivot.apache.org/tutorials/tree-views.html
> Any object in a TreeView's data set which implements
> org.apache.pivot.collections.List will be treated as a branch. Others will
> be treated as nodes.
>
> Chris
>
> On 12 December 2010 21:02, Eugene Kondrashev <eu...@gmail.com>wrote:
>
>> I have one more question regarding TreeView and third point.
>>
>> After reading docs you provided link to, I understood, that i've expressed
>> my thought not clear enough. I mean not enable/disable functionality, but
>> checked/unchecked instead. How can i map my data object 'enable' flag to the
>> checkbox state in suitable way?
>> The confusing thing is that i can't do that at TreeNode creation moment.
>>
>> Thankks, Eugene
>>
>> 2010/12/10 Chris Bartlett <cb...@gmail.com>
>>
>>> Eugene,
>>>
>>> Firstly, the Pivot source code for the 1.5.2 release is available on the
>>> download page here
>>> http://pivot.apache.org/download.cgi#1.5.2
>>>
>>> Or from SVN here
>>> http://svn.apache.org/repos/asf/pivot/tags/v1.5.2/
>>>
>>> The latest 2.0 source is here
>>> http://svn.apache.org/repos/asf/pivot/trunk/
>>>
>>> The KitchenSink demo is located in the 'tutorials' project here
>>>
>>> http://svn.apache.org/repos/asf/pivot/tags/v1.5.2/tutorials/src/org/apache/pivot/tutorials/
>>>
>>> http://svn.apache.org/repos/asf/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/
>>>
>>>
>>>
>>> 1) If you are using a org.apache.pivot.wtk.content.TreeViewNodeRenderer
>>> to render the TreeView, then be aware that it has a 'showIcon' property.
>>>
>>> http://svn.apache.org/repos/asf/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/explorer/tools/event_logger_skin.bxml
>>>
>>>
>>> 2)
>>> It sounds like you are trying to replicate the behaviour that can be seen
>>> in the EventLogger window at the bottom right hand side of the
>>> ComponentExplorer window.
>>> http://pivot.apache.org/demos/component-explorer.html
>>>
>>> Have a look here, and search for the following string
>>> '// Propagate check state upwards or downwards as necessary'
>>>
>>> http://svn.apache.org/repos/asf/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/explorer/tools/EventLoggerSkin.java
>>>
>>>
>>> 3)
>>> Are you aware of the disabledCheckmarkFilter and disabledNodeFilter
>>> properties of TableView?
>>>
>>> http://pivot.apache.org/1.5.2/docs/api/org/apache/pivot/wtk/TreeView.html#setDisabledNodeFilter(org.apache.pivot.util.Filter)
>>>
>>> If you provide a Filter which knows how to determine your internal
>>> 'enabled' flag, the TreeView should take care of the rest.
>>> Search for 'checkTreeView.setDisabledNodeFilter(new Filter<TreeNode>() {'
>>> here
>>>
>>> http://svn.apache.org/repos/asf/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/KitchenSink.java
>>>
>>>
>>> Chris
>>>
>>> On 11 December 2010 02:12, Eugene Kondrashev <
>>> eugene.kondrashev@gmail.com> wrote:
>>>
>>>> Hi guys!
>>>>
>>>> Ive created a checkmark enabled tree view with mixed mode feature. Here
>>>> I faced with two problems:
>>>> 1. tree node text lable is shiffed relative to checkbox icon. It seems
>>>> like there should be a treeNode icon, but i did not set any icons for the
>>>> node, why it shows that free space bettween check box and a text label?
>>>> 2. I wonder if mixed mode "correct" behaviour is implemented by default.
>>>> By correct behaviour i meen example at
>>>> http://pivot.apache.org/demos/kitchen-sink.html Trees section.
>>>> One of the problem here is that parent node is not getting checked
>>>> automatically when all child nodes are checked by user. And vise versa -
>>>> child nodes are not getting checked while checking parent node.
>>>> I can't find sources of example at kitched-sink page regarding Trees.
>>>> Can you help me with that, please?
>>>>
>>>>
>>>>
>>>> My code wtkx:
>>>> <gsq:GSQCustomerProfileController
>>>>         xmlns:wtkx="http://pivot.apache.org/wtkx"
>>>>         xmlns="org.apache.pivot.wtk"
>>>>         xmlns:gsq="com.mbt.client.gui.pivot.modules">
>>>>     <Border>
>>>>         <content>
>>>>             <TablePane>
>>>>                 <columns>
>>>>                     <TablePane.Column width="-1"/>
>>>>                     <TablePane.Column width="1*"/>
>>>>                 </columns>
>>>>                 <rows>
>>>>                     <TablePane.Row height="-1">
>>>>                         <BoxPane styles="{padding:4, spacing:4,
>>>> fill:true}">
>>>>                             <Border styles="{color:10}">
>>>>                                 <content>
>>>>                                     <ScrollPane
>>>> horizontalScrollBarPolicy="fill" minimumPreferredWidth="70"
>>>>
>>>>  verticalScrollBarPolicy="fill_to_capacity">
>>>>                                         <view>
>>>>                                             <TreeView
>>>> wtkx:id="clustersTree" showMixedCheckmarkState="true"
>>>> checkmarksEnabled="true">
>>>>                                             </TreeView>
>>>>                                         </view>
>>>>                                     </ScrollPane>
>>>>                                 </content>
>>>>                             </Border>
>>>>                         </BoxPane>
>>>>                         <CardPane wtkx:id="criteriaCardPane">
>>>>                         </CardPane>
>>>>                     </TablePane.Row>
>>>>                 </rows>
>>>>             </TablePane>
>>>>         </content>
>>>>     </Border>
>>>> </gsq:GSQCustomerProfileController>
>>>>
>>>> Oh, and one more thing. Let say i have aList of some data object with
>>>> enabled flag as internal field. As I understood from the api, I need to
>>>> create org.apache.pivot.collections.List<TreeBranch> from java.util.List and
>>>> then iterate over tree nodes once again setting enabled flag.. If so that is
>>>> really paintfull.
>>>>
>>>> Perhaps I'm doing something wrong, please tell me if so.
>>>>
>>>>         public void handleResponse(List<Cluster> retrievedClusters) {
>>>>             org.apache.pivot.collections.List<TreeBranch> clusters = new
>>>> LinkedList<TreeBranch>();
>>>>             for (Cluster cluster : retrievedClusters) {
>>>>                 TreeBranch treeBranch = new
>>>> TreeBranch(cluster.getName());
>>>>                 for (Criteria criteria : cluster.getCriteria())
>>>>                     treeBranch.insert(new TreeNode(criteria.getName()),
>>>> 0);
>>>>                 clusters.add(treeBranch);
>>>>             }
>>>>             clustersTree.setTreeData(clusters);
>>>>          }
>>>>
>>>> Thanks,
>>>> Eugene
>>>>
>>>
>>>
>>
>

Re: Checkmark enabled TreeView

Posted by Chris Bartlett <cb...@gmail.com>.
Eugene,

OK, I think I understand now.

Is this right?
- You have a some data that needs to be represented in a TreeView.
- That data consists of your objects, some of which contain an flag to
represent some kind of state.
- You want the TreeView to display this state as a checked checkbox.


TreeView maintains an internal list of checked nodes.
This list can queried with
- isNodeChecked(Path)
- getCheckedPaths()
- getNodeCheckState(Path)
but can only be altered externally via
- setNodeChecked(Path, boolean)

So ultimately I think you will need to call setNodeChecked(Path, boolean)
unless you create a subclass of TreeView and handle the checkbox state
yourself somehow.

I have attached some sample code to show that this should not be a
particularly difficult task.  (It was written against the pre-release Pivot
2.0 and checked against 1.5.2.)
You can use the 'userData' property of TreeNode and TreeView to hold a
reference to your real object.
You can easily iterate over a tree of data using
org.apache.pivot.collections.Sequence.Tree.DepthFirstItemIterator.

If required you can register listeners for when the checked state changes if
you need to update your own object's state.  (Not shown in the demo)

While this example uses the provided TreeView and TreeNode classes, you do
not have to.
See here http://pivot.apache.org/tutorials/tree-views.html
Any object in a TreeView's data set which implements
org.apache.pivot.collections.List will be treated as a branch. Others will
be treated as nodes.

Chris

On 12 December 2010 21:02, Eugene Kondrashev <eu...@gmail.com>wrote:

> I have one more question regarding TreeView and third point.
>
> After reading docs you provided link to, I understood, that i've expressed
> my thought not clear enough. I mean not enable/disable functionality, but
> checked/unchecked instead. How can i map my data object 'enable' flag to the
> checkbox state in suitable way?
> The confusing thing is that i can't do that at TreeNode creation moment.
>
> Thankks, Eugene
>
> 2010/12/10 Chris Bartlett <cb...@gmail.com>
>
>> Eugene,
>>
>> Firstly, the Pivot source code for the 1.5.2 release is available on the
>> download page here
>> http://pivot.apache.org/download.cgi#1.5.2
>>
>> Or from SVN here
>> http://svn.apache.org/repos/asf/pivot/tags/v1.5.2/
>>
>> The latest 2.0 source is here
>> http://svn.apache.org/repos/asf/pivot/trunk/
>>
>> The KitchenSink demo is located in the 'tutorials' project here
>>
>> http://svn.apache.org/repos/asf/pivot/tags/v1.5.2/tutorials/src/org/apache/pivot/tutorials/
>>
>> http://svn.apache.org/repos/asf/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/
>>
>>
>>
>> 1) If you are using a org.apache.pivot.wtk.content.TreeViewNodeRenderer to
>> render the TreeView, then be aware that it has a 'showIcon' property.
>>
>> http://svn.apache.org/repos/asf/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/explorer/tools/event_logger_skin.bxml
>>
>>
>> 2)
>> It sounds like you are trying to replicate the behaviour that can be seen
>> in the EventLogger window at the bottom right hand side of the
>> ComponentExplorer window.
>> http://pivot.apache.org/demos/component-explorer.html
>>
>> Have a look here, and search for the following string
>> '// Propagate check state upwards or downwards as necessary'
>>
>> http://svn.apache.org/repos/asf/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/explorer/tools/EventLoggerSkin.java
>>
>>
>> 3)
>> Are you aware of the disabledCheckmarkFilter and disabledNodeFilter
>> properties of TableView?
>>
>> http://pivot.apache.org/1.5.2/docs/api/org/apache/pivot/wtk/TreeView.html#setDisabledNodeFilter(org.apache.pivot.util.Filter)
>>
>> If you provide a Filter which knows how to determine your internal
>> 'enabled' flag, the TreeView should take care of the rest.
>> Search for 'checkTreeView.setDisabledNodeFilter(new Filter<TreeNode>() {'
>> here
>>
>> http://svn.apache.org/repos/asf/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/KitchenSink.java
>>
>>
>> Chris
>>
>> On 11 December 2010 02:12, Eugene Kondrashev <eugene.kondrashev@gmail.com
>> > wrote:
>>
>>> Hi guys!
>>>
>>> Ive created a checkmark enabled tree view with mixed mode feature. Here I
>>> faced with two problems:
>>> 1. tree node text lable is shiffed relative to checkbox icon. It seems
>>> like there should be a treeNode icon, but i did not set any icons for the
>>> node, why it shows that free space bettween check box and a text label?
>>> 2. I wonder if mixed mode "correct" behaviour is implemented by default.
>>> By correct behaviour i meen example at
>>> http://pivot.apache.org/demos/kitchen-sink.html Trees section.
>>> One of the problem here is that parent node is not getting checked
>>> automatically when all child nodes are checked by user. And vise versa -
>>> child nodes are not getting checked while checking parent node.
>>> I can't find sources of example at kitched-sink page regarding Trees. Can
>>> you help me with that, please?
>>>
>>>
>>>
>>> My code wtkx:
>>> <gsq:GSQCustomerProfileController
>>>         xmlns:wtkx="http://pivot.apache.org/wtkx"
>>>         xmlns="org.apache.pivot.wtk"
>>>         xmlns:gsq="com.mbt.client.gui.pivot.modules">
>>>     <Border>
>>>         <content>
>>>             <TablePane>
>>>                 <columns>
>>>                     <TablePane.Column width="-1"/>
>>>                     <TablePane.Column width="1*"/>
>>>                 </columns>
>>>                 <rows>
>>>                     <TablePane.Row height="-1">
>>>                         <BoxPane styles="{padding:4, spacing:4,
>>> fill:true}">
>>>                             <Border styles="{color:10}">
>>>                                 <content>
>>>                                     <ScrollPane
>>> horizontalScrollBarPolicy="fill" minimumPreferredWidth="70"
>>>
>>>  verticalScrollBarPolicy="fill_to_capacity">
>>>                                         <view>
>>>                                             <TreeView
>>> wtkx:id="clustersTree" showMixedCheckmarkState="true"
>>> checkmarksEnabled="true">
>>>                                             </TreeView>
>>>                                         </view>
>>>                                     </ScrollPane>
>>>                                 </content>
>>>                             </Border>
>>>                         </BoxPane>
>>>                         <CardPane wtkx:id="criteriaCardPane">
>>>                         </CardPane>
>>>                     </TablePane.Row>
>>>                 </rows>
>>>             </TablePane>
>>>         </content>
>>>     </Border>
>>> </gsq:GSQCustomerProfileController>
>>>
>>> Oh, and one more thing. Let say i have aList of some data object with
>>> enabled flag as internal field. As I understood from the api, I need to
>>> create org.apache.pivot.collections.List<TreeBranch> from java.util.List and
>>> then iterate over tree nodes once again setting enabled flag.. If so that is
>>> really paintfull.
>>>
>>> Perhaps I'm doing something wrong, please tell me if so.
>>>
>>>         public void handleResponse(List<Cluster> retrievedClusters) {
>>>             org.apache.pivot.collections.List<TreeBranch> clusters = new
>>> LinkedList<TreeBranch>();
>>>             for (Cluster cluster : retrievedClusters) {
>>>                 TreeBranch treeBranch = new
>>> TreeBranch(cluster.getName());
>>>                 for (Criteria criteria : cluster.getCriteria())
>>>                     treeBranch.insert(new TreeNode(criteria.getName()),
>>> 0);
>>>                 clusters.add(treeBranch);
>>>             }
>>>             clustersTree.setTreeData(clusters);
>>>          }
>>>
>>> Thanks,
>>> Eugene
>>>
>>
>>
>

Re: Checkmark enabled TreeView

Posted by Greg Brown <gk...@verizon.net>.
Todd is more knowledgeable about TreeView than I am, but I believe we left the definition of the "mixed" state up to the application. There are multiple ways to define a mixed state, so, as I recall, we felt that it was best to make it an application-level concern.
G

On Dec 12, 2010, at 9:02 AM, Eugene Kondrashev wrote:

> I have one more question regarding TreeView and third point.
> 
> After reading docs you provided link to, I understood, that i've expressed my thought not clear enough. I mean not enable/disable functionality, but checked/unchecked instead. How can i map my data object 'enable' flag to the checkbox state in suitable way?
> The confusing thing is that i can't do that at TreeNode creation moment.
> 
> Thankks, Eugene
> 
> 2010/12/10 Chris Bartlett <cb...@gmail.com>
> Eugene,
> 
> Firstly, the Pivot source code for the 1.5.2 release is available on the download page here
> http://pivot.apache.org/download.cgi#1.5.2
> 
> Or from SVN here
> http://svn.apache.org/repos/asf/pivot/tags/v1.5.2/
> 
> The latest 2.0 source is here
> http://svn.apache.org/repos/asf/pivot/trunk/
> 
> The KitchenSink demo is located in the 'tutorials' project here
> http://svn.apache.org/repos/asf/pivot/tags/v1.5.2/tutorials/src/org/apache/pivot/tutorials/
> http://svn.apache.org/repos/asf/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/
> 
> 
> 
> 1) If you are using a org.apache.pivot.wtk.content.TreeViewNodeRenderer to render the TreeView, then be aware that it has a 'showIcon' property.
> http://svn.apache.org/repos/asf/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/explorer/tools/event_logger_skin.bxml
> 
> 
> 2)
> It sounds like you are trying to replicate the behaviour that can be seen in the EventLogger window at the bottom right hand side of the ComponentExplorer window.
> http://pivot.apache.org/demos/component-explorer.html
> 
> Have a look here, and search for the following string
> '// Propagate check state upwards or downwards as necessary'
> http://svn.apache.org/repos/asf/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/explorer/tools/EventLoggerSkin.java
>    
> 
> 3)
> Are you aware of the disabledCheckmarkFilter and disabledNodeFilter properties of TableView? 
> http://pivot.apache.org/1.5.2/docs/api/org/apache/pivot/wtk/TreeView.html#setDisabledNodeFilter(org.apache.pivot.util.Filter)
> 
> If you provide a Filter which knows how to determine your internal 'enabled' flag, the TreeView should take care of the rest.
> Search for 'checkTreeView.setDisabledNodeFilter(new Filter<TreeNode>() {' here
> http://svn.apache.org/repos/asf/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/KitchenSink.java
> 
> 
> Chris
> 
> On 11 December 2010 02:12, Eugene Kondrashev <eu...@gmail.com> wrote:
> Hi guys!
> 
> Ive created a checkmark enabled tree view with mixed mode feature. Here I faced with two problems:
> 1. tree node text lable is shiffed relative to checkbox icon. It seems like there should be a treeNode icon, but i did not set any icons for the node, why it shows that free space bettween check box and a text label?
> 2. I wonder if mixed mode "correct" behaviour is implemented by default. By correct behaviour i meen example at http://pivot.apache.org/demos/kitchen-sink.html Trees section.
> One of the problem here is that parent node is not getting checked automatically when all child nodes are checked by user. And vise versa - child nodes are not getting checked while checking parent node.
> I can't find sources of example at kitched-sink page regarding Trees. Can you help me with that, please?
> 
> 
> 
> My code wtkx:
> <gsq:GSQCustomerProfileController
>         xmlns:wtkx="http://pivot.apache.org/wtkx"
>         xmlns="org.apache.pivot.wtk"
>         xmlns:gsq="com.mbt.client.gui.pivot.modules">
>     <Border>
>         <content>
>             <TablePane>
>                 <columns>
>                     <TablePane.Column width="-1"/>
>                     <TablePane.Column width="1*"/>
>                 </columns>
>                 <rows>
>                     <TablePane.Row height="-1">
>                         <BoxPane styles="{padding:4, spacing:4, fill:true}">
>                             <Border styles="{color:10}">
>                                 <content>
>                                     <ScrollPane horizontalScrollBarPolicy="fill" minimumPreferredWidth="70"
>                                                 verticalScrollBarPolicy="fill_to_capacity">
>                                         <view>
>                                             <TreeView wtkx:id="clustersTree" showMixedCheckmarkState="true" checkmarksEnabled="true">
>                                             </TreeView>
>                                         </view>
>                                     </ScrollPane>
>                                 </content>
>                             </Border>
>                         </BoxPane>
>                         <CardPane wtkx:id="criteriaCardPane">
>                         </CardPane>
>                     </TablePane.Row>
>                 </rows>
>             </TablePane>
>         </content>
>     </Border>
> </gsq:GSQCustomerProfileController>
> 
> Oh, and one more thing. Let say i have aList of some data object with enabled flag as internal field. As I understood from the api, I need to create org.apache.pivot.collections.List<TreeBranch> from java.util.List and then iterate over tree nodes once again setting enabled flag.. If so that is really paintfull.
> 
> Perhaps I'm doing something wrong, please tell me if so.
> 
>         public void handleResponse(List<Cluster> retrievedClusters) {
>             org.apache.pivot.collections.List<TreeBranch> clusters = new LinkedList<TreeBranch>(); 
>             for (Cluster cluster : retrievedClusters) {
>                 TreeBranch treeBranch = new TreeBranch(cluster.getName());
>                 for (Criteria criteria : cluster.getCriteria())
>                     treeBranch.insert(new TreeNode(criteria.getName()), 0);
>                 clusters.add(treeBranch);
>             }
>             clustersTree.setTreeData(clusters);
>         }
> 
> Thanks,
> Eugene
> 
> 


Re: Checkmark enabled TreeView

Posted by Eugene Kondrashev <eu...@gmail.com>.
I have one more question regarding TreeView and third point.

After reading docs you provided link to, I understood, that i've expressed
my thought not clear enough. I mean not enable/disable functionality, but
checked/unchecked instead. How can i map my data object 'enable' flag to the
checkbox state in suitable way?
The confusing thing is that i can't do that at TreeNode creation moment.

Thankks, Eugene

2010/12/10 Chris Bartlett <cb...@gmail.com>

> Eugene,
>
> Firstly, the Pivot source code for the 1.5.2 release is available on the
> download page here
> http://pivot.apache.org/download.cgi#1.5.2
>
> Or from SVN here
> http://svn.apache.org/repos/asf/pivot/tags/v1.5.2/
>
> The latest 2.0 source is here
> http://svn.apache.org/repos/asf/pivot/trunk/
>
> The KitchenSink demo is located in the 'tutorials' project here
>
> http://svn.apache.org/repos/asf/pivot/tags/v1.5.2/tutorials/src/org/apache/pivot/tutorials/
>
> http://svn.apache.org/repos/asf/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/
>
>
>
> 1) If you are using a org.apache.pivot.wtk.content.TreeViewNodeRenderer to
> render the TreeView, then be aware that it has a 'showIcon' property.
>
> http://svn.apache.org/repos/asf/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/explorer/tools/event_logger_skin.bxml
>
>
> 2)
> It sounds like you are trying to replicate the behaviour that can be seen
> in the EventLogger window at the bottom right hand side of the
> ComponentExplorer window.
> http://pivot.apache.org/demos/component-explorer.html
>
> Have a look here, and search for the following string
> '// Propagate check state upwards or downwards as necessary'
>
> http://svn.apache.org/repos/asf/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/explorer/tools/EventLoggerSkin.java
>
>
> 3)
> Are you aware of the disabledCheckmarkFilter and disabledNodeFilter
> properties of TableView?
>
> http://pivot.apache.org/1.5.2/docs/api/org/apache/pivot/wtk/TreeView.html#setDisabledNodeFilter(org.apache.pivot.util.Filter)
>
> If you provide a Filter which knows how to determine your internal
> 'enabled' flag, the TreeView should take care of the rest.
> Search for 'checkTreeView.setDisabledNodeFilter(new Filter<TreeNode>() {'
> here
>
> http://svn.apache.org/repos/asf/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/KitchenSink.java
>
>
> Chris
>
> On 11 December 2010 02:12, Eugene Kondrashev <eu...@gmail.com>wrote:
>
>> Hi guys!
>>
>> Ive created a checkmark enabled tree view with mixed mode feature. Here I
>> faced with two problems:
>> 1. tree node text lable is shiffed relative to checkbox icon. It seems
>> like there should be a treeNode icon, but i did not set any icons for the
>> node, why it shows that free space bettween check box and a text label?
>> 2. I wonder if mixed mode "correct" behaviour is implemented by default.
>> By correct behaviour i meen example at
>> http://pivot.apache.org/demos/kitchen-sink.html Trees section.
>> One of the problem here is that parent node is not getting checked
>> automatically when all child nodes are checked by user. And vise versa -
>> child nodes are not getting checked while checking parent node.
>> I can't find sources of example at kitched-sink page regarding Trees. Can
>> you help me with that, please?
>>
>>
>>
>> My code wtkx:
>> <gsq:GSQCustomerProfileController
>>         xmlns:wtkx="http://pivot.apache.org/wtkx"
>>         xmlns="org.apache.pivot.wtk"
>>         xmlns:gsq="com.mbt.client.gui.pivot.modules">
>>     <Border>
>>         <content>
>>             <TablePane>
>>                 <columns>
>>                     <TablePane.Column width="-1"/>
>>                     <TablePane.Column width="1*"/>
>>                 </columns>
>>                 <rows>
>>                     <TablePane.Row height="-1">
>>                         <BoxPane styles="{padding:4, spacing:4,
>> fill:true}">
>>                             <Border styles="{color:10}">
>>                                 <content>
>>                                     <ScrollPane
>> horizontalScrollBarPolicy="fill" minimumPreferredWidth="70"
>>
>>  verticalScrollBarPolicy="fill_to_capacity">
>>                                         <view>
>>                                             <TreeView
>> wtkx:id="clustersTree" showMixedCheckmarkState="true"
>> checkmarksEnabled="true">
>>                                             </TreeView>
>>                                         </view>
>>                                     </ScrollPane>
>>                                 </content>
>>                             </Border>
>>                         </BoxPane>
>>                         <CardPane wtkx:id="criteriaCardPane">
>>                         </CardPane>
>>                     </TablePane.Row>
>>                 </rows>
>>             </TablePane>
>>         </content>
>>     </Border>
>> </gsq:GSQCustomerProfileController>
>>
>> Oh, and one more thing. Let say i have aList of some data object with
>> enabled flag as internal field. As I understood from the api, I need to
>> create org.apache.pivot.collections.List<TreeBranch> from java.util.List and
>> then iterate over tree nodes once again setting enabled flag.. If so that is
>> really paintfull.
>>
>> Perhaps I'm doing something wrong, please tell me if so.
>>
>>         public void handleResponse(List<Cluster> retrievedClusters) {
>>             org.apache.pivot.collections.List<TreeBranch> clusters = new
>> LinkedList<TreeBranch>();
>>             for (Cluster cluster : retrievedClusters) {
>>                 TreeBranch treeBranch = new TreeBranch(cluster.getName());
>>                 for (Criteria criteria : cluster.getCriteria())
>>                     treeBranch.insert(new TreeNode(criteria.getName()),
>> 0);
>>                 clusters.add(treeBranch);
>>             }
>>             clustersTree.setTreeData(clusters);
>>          }
>>
>> Thanks,
>> Eugene
>>
>
>

Re: Checkmark enabled TreeView

Posted by Chris Bartlett <cb...@gmail.com>.
Eugene,

Firstly, the Pivot source code for the 1.5.2 release is available on the
download page here
http://pivot.apache.org/download.cgi#1.5.2

Or from SVN here
http://svn.apache.org/repos/asf/pivot/tags/v1.5.2/

The latest 2.0 source is here
http://svn.apache.org/repos/asf/pivot/trunk/

The KitchenSink demo is located in the 'tutorials' project here
http://svn.apache.org/repos/asf/pivot/tags/v1.5.2/tutorials/src/org/apache/pivot/tutorials/
http://svn.apache.org/repos/asf/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/



1) If you are using a org.apache.pivot.wtk.content.TreeViewNodeRenderer to
render the TreeView, then be aware that it has a 'showIcon' property.
http://svn.apache.org/repos/asf/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/explorer/tools/event_logger_skin.bxml


2)
It sounds like you are trying to replicate the behaviour that can be seen in
the EventLogger window at the bottom right hand side of the
ComponentExplorer window.
http://pivot.apache.org/demos/component-explorer.html

Have a look here, and search for the following string
'// Propagate check state upwards or downwards as necessary'
http://svn.apache.org/repos/asf/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/explorer/tools/EventLoggerSkin.java


3)
Are you aware of the disabledCheckmarkFilter and disabledNodeFilter
properties of TableView?
http://pivot.apache.org/1.5.2/docs/api/org/apache/pivot/wtk/TreeView.html#setDisabledNodeFilter(org.apache.pivot.util.Filter)

If you provide a Filter which knows how to determine your internal 'enabled'
flag, the TreeView should take care of the rest.
Search for 'checkTreeView.setDisabledNodeFilter(new Filter<TreeNode>() {'
here
http://svn.apache.org/repos/asf/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/KitchenSink.java


Chris

On 11 December 2010 02:12, Eugene Kondrashev <eu...@gmail.com>wrote:

> Hi guys!
>
> Ive created a checkmark enabled tree view with mixed mode feature. Here I
> faced with two problems:
> 1. tree node text lable is shiffed relative to checkbox icon. It seems like
> there should be a treeNode icon, but i did not set any icons for the node,
> why it shows that free space bettween check box and a text label?
> 2. I wonder if mixed mode "correct" behaviour is implemented by default. By
> correct behaviour i meen example at
> http://pivot.apache.org/demos/kitchen-sink.html Trees section.
> One of the problem here is that parent node is not getting checked
> automatically when all child nodes are checked by user. And vise versa -
> child nodes are not getting checked while checking parent node.
> I can't find sources of example at kitched-sink page regarding Trees. Can
> you help me with that, please?
>
>
>
> My code wtkx:
> <gsq:GSQCustomerProfileController
>         xmlns:wtkx="http://pivot.apache.org/wtkx"
>         xmlns="org.apache.pivot.wtk"
>         xmlns:gsq="com.mbt.client.gui.pivot.modules">
>     <Border>
>         <content>
>             <TablePane>
>                 <columns>
>                     <TablePane.Column width="-1"/>
>                     <TablePane.Column width="1*"/>
>                 </columns>
>                 <rows>
>                     <TablePane.Row height="-1">
>                         <BoxPane styles="{padding:4, spacing:4,
> fill:true}">
>                             <Border styles="{color:10}">
>                                 <content>
>                                     <ScrollPane
> horizontalScrollBarPolicy="fill" minimumPreferredWidth="70"
>
>  verticalScrollBarPolicy="fill_to_capacity">
>                                         <view>
>                                             <TreeView
> wtkx:id="clustersTree" showMixedCheckmarkState="true"
> checkmarksEnabled="true">
>                                             </TreeView>
>                                         </view>
>                                     </ScrollPane>
>                                 </content>
>                             </Border>
>                         </BoxPane>
>                         <CardPane wtkx:id="criteriaCardPane">
>                         </CardPane>
>                     </TablePane.Row>
>                 </rows>
>             </TablePane>
>         </content>
>     </Border>
> </gsq:GSQCustomerProfileController>
>
> Oh, and one more thing. Let say i have aList of some data object with
> enabled flag as internal field. As I understood from the api, I need to
> create org.apache.pivot.collections.List<TreeBranch> from java.util.List and
> then iterate over tree nodes once again setting enabled flag.. If so that is
> really paintfull.
>
> Perhaps I'm doing something wrong, please tell me if so.
>
>         public void handleResponse(List<Cluster> retrievedClusters) {
>             org.apache.pivot.collections.List<TreeBranch> clusters = new
> LinkedList<TreeBranch>();
>             for (Cluster cluster : retrievedClusters) {
>                 TreeBranch treeBranch = new TreeBranch(cluster.getName());
>                 for (Criteria criteria : cluster.getCriteria())
>                     treeBranch.insert(new TreeNode(criteria.getName()), 0);
>                 clusters.add(treeBranch);
>             }
>             clustersTree.setTreeData(clusters);
>         }
>
> Thanks,
> Eugene
>