TreeItemSelectedEvent is not being published

Hello!



I’m just posting this (bug?) issue in this forum again (have originally posted it here) mainly to its strong relation and for the sake of other developers who might come across it. I know it’s a Nifty GUI bug but I hope some of the gurus here could/would be interested to look at it.





I’m using nifty 1.3.1 with jme3 inside an eclipse plugin for software visualization. I was trying to use the TreeBox control to display some items but unfortunately I soon realized that this particular control seems not to be fully implemented yet? Or is what I’m facing are bugs? So here is what I’m facing…



1)TreeItemSelectedEvent is not published at all!! Instead, a ListBoxSelectionChangedEvent is being published which is apparently a result of the the treeBox being internally represented as a ListBox. But still, this should not be the case. The correct event should be published I suppose.



2)Moreover, I found out that nifty behind the scenes adds the following property [onClick=“listBoxItemClicked()”] for each ListBoxItem created (what should have actually been aTreeItem ) and yet, this is not mentioned anywhere in documentation.





3)More importantly, the onListBoxSelectionChanged() method of the TreeBoxControl is actually never called!! This is where the collapse & expand stuff is implemented so without it, the tree items are not collapsible/expandable upon clicking!! I had to catch the ListBoxSelectionChangedEvent and then work my way to force call the onListBoxSelectionChanged() method on the TreeBoxControl which then also results in triggering the TreeItemSelectedEvent !!



Now after the above hack is put in place, the situation is somewhat better but the following problems are still faced:





4) The first node gets always selected, even after the use click on another item!! As soon as that item is selected, the event is generate for that item and then apparently the whole tree structure gets rebuilt which makes the first node becoming selected back again!!



5) The TreeItems are no longer getting highlighted (text getting yellow color)



6) More importantly, now I have to double click an item to get it collapsed/expanded!



I know this is probably too much for a single post but I’m really keen to get this working as I’m developing a tool for my master’s thesis and I don’t want to resort to less exciting solution. I would really appreciate if this bug could be solved quickly or at least someone helps me on how I can best resolve the problems above, especially 4 and 6.



Thank you very much.

Mujtaba





_________________________

Some console output is below in case it helps. Please note that I’m only creating a TreeBox control and not a ListBox !!


Code:
INFO: after setStyle [nifty-listbox-item] <text> [element] (style => nifty-listbox-item, name => label, width => 100% {nifty-listbox-item}, id => scrumsTree#listbox#tree-item-caption, wrap => true, textHAlign => left, font => aurulent-sans-16.fnt {base-font}, textMinHeight => 23px {nifty-label}, color => #000f {nifty-listbox-item}, textVAlign => center {nifty-listbox-item}, controller => de.lessvoid.nifty.controls.label.LabelControl, align => left, textLineHeight => 23px {nifty-label}, height => 15px) <interact> (onClick => listBoxItemClicked() {nifty-listbox-item}) <effects> () <onHover> (color => #444f, neverStopRendering => true, inset => 1px, name => colorBar, post => false, timeType => infinite) <hover> () {nifty-listbox-item} <onClick> (name => focus, targetElement => #parent#parent) {nifty-listbox-item} <onActive> (name => clip, post => false) <onActive> (name => clip, post => false) {nifty-label} <onActive> (name => clip, post => false) {nifty-label} <onActive> (name => clip, post => false) {nifty-label} <onActive> (name => clip, post => false) {nifty-label} <onActive> (name => clip, post => false) {nifty-label} <onActive> (name => clip, post => false) {nifty-label} <onActive> (name => clip, post => false) {nifty-label} <onActive> (name => clip, post => false) {nifty-label} <onActive> (name => clip, post => false) {nifty-label} <onActive> (name => clip, post => false) {nifty-label} <onActive> (name => clip, post => false) {nifty-label} <onActive> (name => clip, post => false) {nifty-label} <onActive> (name => clip, post => false) {nifty-label} <onCustom> (color => #444f, neverStopRendering => true, name => colorBar, post => false, timeType => infinite, customKey => focus) {nifty-listbox-item} <onCustom> (color => #444f, neverStopRendering => true, name => colorBar, post => false, timeType => infinite, customKey => select) {nifty-listbox-item} <onCustom> (color => #fc0f, neverStopRendering => true, name => textColor, post => false, timeType => infinite, customKey => select) {nifty-listbox-item} no children elements


_________________

TreeBox xml definition:
Code:
<panel width="98%" height="10%" childLayout="center" backgroundColor="#F5F5F500" valign="center"> <control id="scrumsTree" name="nifty-tree-box"/> </panel>

_____________________

and finally, the event handling method:
Code:
@NiftyEventSubscriber(pattern=".*") public void toggleTreeItem(String id, ListBoxSelectionChangedEvent<TreeEntryModelClass> event) { // (id=="scrumsTree") doesn't work!! why?? //TreeBoxControl treeBoxControl = (TreeBoxControl)event.getListBox(); //doesn't work ;(
	TreeEntryModelClass selectedItem = (TreeEntryModelClass)event.getSelection().get(0);
	TreeItem item = selectedItem.getTreeItem();
	
	/**
	 * This is a temp hack to invoke the internal event method of TreeBox and 
	 * we are doing it because currently as of Nifty GUI 1.3.1 this method is 
	 * not being called anywhere.
	 */
	TreeBoxControl treeBoxControl = (TreeBoxControl)nifty.getScreen(&quot;start&quot;).findNiftyControl(&quot;scrumsTree&quot;, TreeBox.class);
	treeBoxControl.onListBoxSelectionChanged(id, event);  // This method should have been called internally by Nifty, right?
					
	System.out.println(&quot;Item Selected value is: &quot;+item.getValue());
	System.out.println(&quot;ListBoxSelectionEvent is published with id: &quot;+ id);
	System.out.println(&quot;Item Selected is: &quot;+event.getSelection().get(0));
	
}</div>

Hmm, can’t say I’ve used the tree controls myself but @Void256 is pretty regular on these forums and should be able to help :slight_smile:

Unfortunately void256 won’t be able to help in this case, I’m afraid :confused:



The TreeBox control was completely user contributed and it appears to be quite buggy :confused: It’s the same issue with the TabsControl (written by the same author). The TabsControl has been fixed, cleaned up and improved greatly in the meantime by another Nifty contributer Martin who did an excellent job in cleaning up the mess that the TabsControl was in.



We’re kinda looking for a volunteer to fix the TreeBox control now as well I suppose :confused:



I guess that’s what you learn in managing an open source project: At first it’s great to receive contributions, patches or extensions. But then the original author disappears and you’re left with a mess of code that’s not your own :confused:



Note to self: “Self! Learn to say No more often … or at least make contributers to sign a maintenance contract for their work or something ;)”

1 Like

Thank you both zarch and mr. void256! I do appreciate your informative response :slight_smile: and yes the current state of the TreeBox implementation is unfortunately quite embarrassing to have in our great Nifty gui library. Anyhow, I suppose in this case I will just live with it just as is for the being time with the hope someone will fix it up in the coming release/s

Hey guys,
first of all @void256 u did a great job so far with Nifty. I know how much work it is to bring up pieces of code that are so flexible and usable for many purposes. Especially if u work alone and in the end it is an open source project so we can’t and wouldn’t expect it.
Therefore I want to make sure that you know I am open to help to develop in the given environment to make things work as easy as they do so far.

Now here is my point:
I wonder what the state of development is. Especially regarding the TreeBox. I need a tree representation for debugging my voxel engine and to see or even manipulate the underlying node structure from the scenegraph during runtime more intuitive. So I faced exactly the problems mentioned above. While trying to find out how the current version actually works I had a closer look at the code and I have found version 1.4 in GIT in which it seems it is at least a little better implemented yet. Anyways I failed to build up equivalent libraries like the 1.3.3 ones that are also released in JME.

So my question is:
Will there be a 1.4 Nifty library bundle released anytime soon? Or how do I build them the way they are structured in 1.3.3. I have problems with the package thing. In my first tries there has always been some other internal structure so that nothing would be found via import de.lessvoid.nifty…

@void256 said: We're kinda looking for a volunteer to fix the TreeBox control now as well I suppose :/
That is actually what I was thinking about. I am working on a voxel engine I plan to share if it is ready or kind of usable. So I try to integrate it perfectly in JME, especially in the whole terrain system. Therefore I have to get involved in all this contribution thing sooner or later anyways and this issue seems to be on the way down the road. So I thought why not make first tries with a "relative" simple task like the treeBox compared to a whole voxel engine ;) So I am looking for a so to speak more direct communication to the developers in this case for the Nifty-GUI, you, to prevent the mess of code and develop in the given framework. But later of course also to the other developers especially the terrain team to make a nice and clean contribution of my voxelengine that is easy and intuitive to use similar to the other terrain types so far.

I hope you can help me with that and give me maybe first steps or contacts or some super secret developer forums and chats or something :smiley: Communicating via this forum actually seems a little unpractical and slow for that, I think. Also I am very interested in what you said about managing an open source project and how it works.

greetz Xeratos

@xeratos said: Will there be a 1.4 Nifty library bundle released anytime soon?

There will be a 1.4 Nifty release. I don’t think it will happen VERY soon though since there are still 1.4 related issues open that I’d like to see fixed/added/improved first. I’ve been a bit distracted by other things so I’ve not done a lot of work for 1.4 already BUT some other volunteers already began cleaning things up in 1.4. So that’s nice to see really :slight_smile:

But yeah, no 1.4 release date available for now. Sorry.

@xeratos said: Or how do I build them the way they are structured in 1.3.3.

To build from source you could do a mvn clean package in the topmost project which should build you all the Nifty jars. You only have to collect them from the “target” sub directories of the individual projects.

If your project uses Maven you could do a mvn clean install to deploy a SNAPSHOT version to your local repository and then use a SNAPSHOT-dependency in your project. Or you use the nightly builds from the “official” Nifty Maven repository as explained here: nifty-gui download | SourceForge.net

Because of this (Maven and the repository) there is currently nothing to collect all the jars automatically into a single directory or so (you have to do that yourself if you don’t use Maven, like find . -name *.jaror so)

@xeratos said: I hope you can help me with that and give me maybe first steps or contacts or some super secret developer forums and chats or something :-D

For the super secret jme developer chat :wink: I don’t know how it works exactly. I think you’ll need to contact Erlend for that but usually you’ll be invited by the inner circle … and then you have to do some terrible things to prove that you’re worthy before being able to join the chat iirc :smiley: 8)

The super secret Nifty chat is not really super secret: you’re welcome to join us at: freenode irc in #niftygui → irc://freenode/niftygui I’ll try to be there each day from 23:00 CET but usually I’ll forget :wink: But yeah that would be a direct contact and github issues and pull requests are a great place to discuss things as well.

There isn’t really a super-secret developers chat.

There is a contributors chat that anyone can just join. There is also a core developers chat that people get invited to once they’ve made significant contributions etc (improves the signal to noise ratio that way :slight_smile: ).

jmechat@jaconda.im is the general chat. It doesn’t see a huge amount of activity but it’s there.