<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: JavaFX CheckBoxTreeView</title>
	<atom:link href="http://fxexperience.com/2010/06/javafx-checkboxtreeview/feed/" rel="self" type="application/rss+xml" />
	<link>http://fxexperience.com/2010/06/javafx-checkboxtreeview/</link>
	<description>Sharing the Experience of JavaFX</description>
	<lastBuildDate>Wed, 08 Feb 2012 17:43:31 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: Mikhail Gavryuchkov</title>
		<link>http://fxexperience.com/2010/06/javafx-checkboxtreeview/comment-page-1/#comment-31325</link>
		<dc:creator>Mikhail Gavryuchkov</dc:creator>
		<pubDate>Tue, 04 Oct 2011 20:25:25 +0000</pubDate>
		<guid isPermaLink="false">http://fxexperience.com/?p=866#comment-31325</guid>
		<description>I check JavaFX once every year. I agree with Les - practically all frameworks have online demos. JavaFX - only screenshots. It seems that creators of JavaFX are not interested at all in adoption of their product. I am outta here...</description>
		<content:encoded><![CDATA[<p>I check JavaFX once every year. I agree with Les &#8211; practically all frameworks have online demos. JavaFX &#8211; only screenshots. It seems that creators of JavaFX are not interested at all in adoption of their product. I am outta here&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Eric Bruno</title>
		<link>http://fxexperience.com/2010/06/javafx-checkboxtreeview/comment-page-1/#comment-14633</link>
		<dc:creator>Eric Bruno</dc:creator>
		<pubDate>Tue, 08 Feb 2011 15:10:23 +0000</pubDate>
		<guid isPermaLink="false">http://fxexperience.com/?p=866#comment-14633</guid>
		<description>The problem with the code is that if you expand or contract the tree items, the checkbox states change. I suppose that&#039;s because the TreeCells (which contain the checkboxes) are reused as the tree changes. This solution (as well as Bobby&#039;s in the comments) only works if you leave the tree in its expanded or contracted state, and don&#039;t expand or contract any parts of it. Any way around this, Jonathan?</description>
		<content:encoded><![CDATA[<p>The problem with the code is that if you expand or contract the tree items, the checkbox states change. I suppose that&#8217;s because the TreeCells (which contain the checkboxes) are reused as the tree changes. This solution (as well as Bobby&#8217;s in the comments) only works if you leave the tree in its expanded or contracted state, and don&#8217;t expand or contract any parts of it. Any way around this, Jonathan?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bobby</title>
		<link>http://fxexperience.com/2010/06/javafx-checkboxtreeview/comment-page-1/#comment-7648</link>
		<dc:creator>Bobby</dc:creator>
		<pubDate>Wed, 23 Jun 2010 18:46:03 +0000</pubDate>
		<guid isPermaLink="false">http://fxexperience.com/?p=866#comment-7648</guid>
		<description>Jonathan, thanks for the response.  I have a simple two level tree view.  For this tree view, I have found a solution that works.  I subclass TreeItem, like you suggested.  The subclass has a reference to the checkbox for that particular cell.  The TreeItem instance gets the reference to the checkbox in the onUpdate function of TreeCell.  

class SubrequirementTreeItem extends TreeItem {
    var subrequirementResourceID:Integer;
    var checkBox:CheckBox;
}


override var cellFactory = function():TreeCell {
                var cb:CheckBox;
                def cell:TreeCell = TreeCell {
                    node: cb = CheckBox {text: bind (cell.item as String) visible: bind (cell.item != null)
                        onMouseClicked: function (e) {
                            if (cell.treeItem.leaf == true) {
                                if (cb.selected == true) {
                                    insert (cell.treeItem as RunSetupMediator.SubrequirementTreeItem).subrequirementResourceID into targetCategoryViewSubrequirementsSelected;
                                }
                                else {
                                    delete (cell.treeItem as RunSetupMediator.SubrequirementTreeItem).subrequirementResourceID from targetCategoryViewSubrequirementsSelected;
                                }

                            }
                            else {
                                if (cb.selected == true) {
                                    for (child in cell.treeItem.children) {
                                        (child as RunSetupMediator.SubrequirementTreeItem).checkBox.selected = true;
                                        insert (child as RunSetupMediator.SubrequirementTreeItem).subrequirementResourceID into targetCategoryViewSubrequirementsSelected;
                                    }
                                }
                                else {
                                    for (child in cell.treeItem.children) {
                                        (child as RunSetupMediator.SubrequirementTreeItem).checkBox.selected = false;
                                        delete (child as RunSetupMediator.SubrequirementTreeItem).subrequirementResourceID from targetCategoryViewSubrequirementsSelected;
                                    }
                                }
                            }
                        }

                    }
                    onUpdate: function() {
                        if (cell.treeItem.leaf) {
                            (cell.treeItem as RunSetupMediator.SubrequirementTreeItem).checkBox = cell.node as CheckBox;
                        }
                        cell.disclosureNode.visible = (cell.item != null) and not cell.treeItem.leaf;
                    }
                };                
            }</description>
		<content:encoded><![CDATA[<p>Jonathan, thanks for the response.  I have a simple two level tree view.  For this tree view, I have found a solution that works.  I subclass TreeItem, like you suggested.  The subclass has a reference to the checkbox for that particular cell.  The TreeItem instance gets the reference to the checkbox in the onUpdate function of TreeCell.  </p>
<p>class SubrequirementTreeItem extends TreeItem {<br />
    var subrequirementResourceID:Integer;<br />
    var checkBox:CheckBox;<br />
}</p>
<p>override var cellFactory = function():TreeCell {<br />
                var cb:CheckBox;<br />
                def cell:TreeCell = TreeCell {<br />
                    node: cb = CheckBox {text: bind (cell.item as String) visible: bind (cell.item != null)<br />
                        onMouseClicked: function (e) {<br />
                            if (cell.treeItem.leaf == true) {<br />
                                if (cb.selected == true) {<br />
                                    insert (cell.treeItem as RunSetupMediator.SubrequirementTreeItem).subrequirementResourceID into targetCategoryViewSubrequirementsSelected;<br />
                                }<br />
                                else {<br />
                                    delete (cell.treeItem as RunSetupMediator.SubrequirementTreeItem).subrequirementResourceID from targetCategoryViewSubrequirementsSelected;<br />
                                }</p>
<p>                            }<br />
                            else {<br />
                                if (cb.selected == true) {<br />
                                    for (child in cell.treeItem.children) {<br />
                                        (child as RunSetupMediator.SubrequirementTreeItem).checkBox.selected = true;<br />
                                        insert (child as RunSetupMediator.SubrequirementTreeItem).subrequirementResourceID into targetCategoryViewSubrequirementsSelected;<br />
                                    }<br />
                                }<br />
                                else {<br />
                                    for (child in cell.treeItem.children) {<br />
                                        (child as RunSetupMediator.SubrequirementTreeItem).checkBox.selected = false;<br />
                                        delete (child as RunSetupMediator.SubrequirementTreeItem).subrequirementResourceID from targetCategoryViewSubrequirementsSelected;<br />
                                    }<br />
                                }<br />
                            }<br />
                        }</p>
<p>                    }<br />
                    onUpdate: function() {<br />
                        if (cell.treeItem.leaf) {<br />
                            (cell.treeItem as RunSetupMediator.SubrequirementTreeItem).checkBox = cell.node as CheckBox;<br />
                        }<br />
                        cell.disclosureNode.visible = (cell.item != null) and not cell.treeItem.leaf;<br />
                    }<br />
                };<br />
            }</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jonathan Giles</title>
		<link>http://fxexperience.com/2010/06/javafx-checkboxtreeview/comment-page-1/#comment-7635</link>
		<dc:creator>Jonathan Giles</dc:creator>
		<pubDate>Wed, 23 Jun 2010 02:45:33 +0000</pubDate>
		<guid isPermaLink="false">http://fxexperience.com/?p=866#comment-7635</guid>
		<description>@Bobby: You can&#039;t do what you&#039;re wanting to do, as it&#039;s not possible for you to retrieve the TreeCells using public API. This is because internally we reuse TreeCell nodes to minimise memory usage.

One possible workaround would be to bind the CheckBoxTreeCell.selected property (from my example in this post) to be not only related to the checkbox selection, but also the parent selection (assuming you&#039;ve created a TreeItem subclass that contains the selection state - which I don&#039;t show here). This would take a bit of work (with mouse and key events) to ensure the correct value is used, but from it you should be able to get the result you&#039;re wanting.

I may take a further look into this suggestion shortly to see if I can clarify my point. I also know Richard Bair improved upon my proof of concept above, so perhaps he might want to add a comment.

-- Jonathan</description>
		<content:encoded><![CDATA[<p>@Bobby: You can&#8217;t do what you&#8217;re wanting to do, as it&#8217;s not possible for you to retrieve the TreeCells using public API. This is because internally we reuse TreeCell nodes to minimise memory usage.</p>
<p>One possible workaround would be to bind the CheckBoxTreeCell.selected property (from my example in this post) to be not only related to the checkbox selection, but also the parent selection (assuming you&#8217;ve created a TreeItem subclass that contains the selection state &#8211; which I don&#8217;t show here). This would take a bit of work (with mouse and key events) to ensure the correct value is used, but from it you should be able to get the result you&#8217;re wanting.</p>
<p>I may take a further look into this suggestion shortly to see if I can clarify my point. I also know Richard Bair improved upon my proof of concept above, so perhaps he might want to add a comment.</p>
<p>&#8211; Jonathan</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bobby</title>
		<link>http://fxexperience.com/2010/06/javafx-checkboxtreeview/comment-page-1/#comment-7634</link>
		<dc:creator>Bobby</dc:creator>
		<pubDate>Wed, 23 Jun 2010 02:31:46 +0000</pubDate>
		<guid isPermaLink="false">http://fxexperience.com/?p=866#comment-7634</guid>
		<description>Nice example.  I have a check box tree view  using this cellFactory definition:

var cb:CheckBox;
def cell:TreeCell = TreeCell {
    node: cb = CheckBox {text: bind (cell.item as String) visible: bind (cell.item != null)
                        onMouseClicked: function (e) {
                            if (cell.treeItem.leaf == true) {
                                if (cb.selected == true) {
                                    insert (cell.treeItem as RunSetupMediator.SubrequirementTreeItem).subrequirementResourceID into targetCategoryViewSubrequirementsSelected;
                                }
                                else {
                                    delete (cell.treeItem as RunSetupMediator.SubrequirementTreeItem).subrequirementResourceID from targetCategoryViewSubrequirementsSelected;
                                }
                            }
                            else {
                                if (cb.selected == true) {
                                    cb.selected = false;
                                    // Need to go from treeItem to TreeCell ??????
                                }
                            }
                        }

                    }
                    onUpdate: function() {
                        cell.disclosureNode.visible = (cell.item != null) and not cell.treeItem.leaf;
                    }
                }

Question:  TreeCell has a reference to TreeItem and TreeView.  How does one navigate from TreeView/TreeItem to it&#039;s corresponding TreeCells?  What I would like to do is create a TreeNodeCheckBox such that when it is checked, all its children become checked.  

Thanks.</description>
		<content:encoded><![CDATA[<p>Nice example.  I have a check box tree view  using this cellFactory definition:</p>
<p>var cb:CheckBox;<br />
def cell:TreeCell = TreeCell {<br />
    node: cb = CheckBox {text: bind (cell.item as String) visible: bind (cell.item != null)<br />
                        onMouseClicked: function (e) {<br />
                            if (cell.treeItem.leaf == true) {<br />
                                if (cb.selected == true) {<br />
                                    insert (cell.treeItem as RunSetupMediator.SubrequirementTreeItem).subrequirementResourceID into targetCategoryViewSubrequirementsSelected;<br />
                                }<br />
                                else {<br />
                                    delete (cell.treeItem as RunSetupMediator.SubrequirementTreeItem).subrequirementResourceID from targetCategoryViewSubrequirementsSelected;<br />
                                }<br />
                            }<br />
                            else {<br />
                                if (cb.selected == true) {<br />
                                    cb.selected = false;<br />
                                    // Need to go from treeItem to TreeCell ??????<br />
                                }<br />
                            }<br />
                        }</p>
<p>                    }<br />
                    onUpdate: function() {<br />
                        cell.disclosureNode.visible = (cell.item != null) and not cell.treeItem.leaf;<br />
                    }<br />
                }</p>
<p>Question:  TreeCell has a reference to TreeItem and TreeView.  How does one navigate from TreeView/TreeItem to it&#8217;s corresponding TreeCells?  What I would like to do is create a TreeNodeCheckBox such that when it is checked, all its children become checked.  </p>
<p>Thanks.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Java desktop links of the week, June 21 &#124; Jonathan Giles</title>
		<link>http://fxexperience.com/2010/06/javafx-checkboxtreeview/comment-page-1/#comment-7592</link>
		<dc:creator>Java desktop links of the week, June 21 &#124; Jonathan Giles</dc:creator>
		<pubDate>Sun, 20 Jun 2010 21:11:08 +0000</pubDate>
		<guid isPermaLink="false">http://fxexperience.com/?p=866#comment-7592</guid>
		<description>[...] I posted a simple example of using a cell factory in the JavaFX TreeView to create a CheckBoxTreeView control. [...]</description>
		<content:encoded><![CDATA[<p>[...] I posted a simple example of using a cell factory in the JavaFX TreeView to create a CheckBoxTreeView control. [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Les</title>
		<link>http://fxexperience.com/2010/06/javafx-checkboxtreeview/comment-page-1/#comment-7560</link>
		<dc:creator>Les</dc:creator>
		<pubDate>Sat, 19 Jun 2010 13:57:38 +0000</pubDate>
		<guid isPermaLink="false">http://fxexperience.com/?p=866#comment-7560</guid>
		<description>I really like JavaFX, but I find it disturbing that most examples do not include something functional on the page.  Many may include a webstart link, but very few embed it as an applet.  If they do, it requires a click to load.  If the guys writing the examples don&#039;t feel comfortable with page load times when including their examples, will the rest of the world?</description>
		<content:encoded><![CDATA[<p>I really like JavaFX, but I find it disturbing that most examples do not include something functional on the page.  Many may include a webstart link, but very few embed it as an applet.  If they do, it requires a click to load.  If the guys writing the examples don&#8217;t feel comfortable with page load times when including their examples, will the rest of the world?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tbee</title>
		<link>http://fxexperience.com/2010/06/javafx-checkboxtreeview/comment-page-1/#comment-7444</link>
		<dc:creator>Tbee</dc:creator>
		<pubDate>Fri, 18 Jun 2010 10:01:26 +0000</pubDate>
		<guid isPermaLink="false">http://fxexperience.com/?p=866#comment-7444</guid>
		<description>Technically I&#039;m getting more and more impressed with JavaFX. It&#039;s really well thought through with all the lessons learned from Swing. I really hope it will break through in the RIA / TV / Mobile world.</description>
		<content:encoded><![CDATA[<p>Technically I&#8217;m getting more and more impressed with JavaFX. It&#8217;s really well thought through with all the lessons learned from Swing. I really hope it will break through in the RIA / TV / Mobile world.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

