Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » NatTable » Custom order of nodes in NatTable tree
Custom order of nodes in NatTable tree [message #1088640] Sat, 17 August 2013 07:40 Go to next message
Omer Gillani is currently offline Omer Gillani
Messages: 22
Registered: May 2012
Junior Member

Hey,

I am using NatTable tree. I want to implement custom ordering of nodes. We have requirement to allow the user to move any node up and down.

It seems to me, we need to implement TreeList.Format<Node>#getComparator(int depth). But I couldn't find proper documentation to provide its custom implementation.

Can you please provide me some information about custom ordering in NatTable tree using glazedlists TreeList?

I would appreciate your support.

Regards,
Omer Gillani

Re: Custom order of nodes in NatTable tree [message #1088680 is a reply to message #1088640] Sat, 17 August 2013 09:06 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk Fauth
Messages: 1262
Registered: July 2012
Senior Member
You can have a look at our examples to get an idea. But technically a comparator is exactly what it is, a comparator. Smile

Should zour users be able to reorder the rows so that the data model changes or should it be only modify the visual representation? For the later one you could use the RowReorderLayer together with the DetailGlazedListsEventLayer. The other one would be more complicated as you need to implement some order attribute that is used for the sorting of the tree and a mechanism that changes this attribute on user interaction.

Greez,
Dirk
Re: Custom order of nodes in NatTable tree [message #1089791 is a reply to message #1088640] Mon, 19 August 2013 04:50 Go to previous messageGo to next message
SD Khan is currently offline SD Khan
Messages: 63
Registered: May 2013
Member
Hi !

I think you should see the existing functionality of the default comparator, then see how you can write one for you in a similar fashion Cool , isn't it a good idea ?

Regards,
SD Khan
Re: Custom order of nodes in NatTable tree [message #1091140 is a reply to message #1088680] Wed, 21 August 2013 01:04 Go to previous messageGo to next message
Ali Malik is currently offline Ali Malik
Messages: 27
Registered: August 2013
Junior Member
Hi Dirk,

I need to modify the data model, because I need to keep track of the data items.
So what is this order attribute? And how can I make use of it in my case?
Please provide some explanation Smile

Regards,
Ali Ahmad Malik
Re: Custom order of nodes in NatTable tree [message #1091203 is a reply to message #1091140] Wed, 21 August 2013 03:10 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk Fauth
Messages: 1262
Registered: July 2012
Senior Member
Hi Ali,

An order attribute is an attribute of your data model that you use in your comparator for sorting. If zou can not use an existing attribute you need to introduce a new one only used for sorting.

There are surely several tutorials online explaining this in more detail.

Greez,
Dirk
Re: Custom order of nodes in NatTable tree [message #1094796 is a reply to message #1091203] Mon, 26 August 2013 03:47 Go to previous messageGo to next message
Ali Malik is currently offline Ali Malik
Messages: 27
Registered: August 2013
Junior Member
Hi Dirk,

In my case there could be trees upto n-level. So, I have a devised a solution for it.

But what I don't seem to understand now is this:

The compare function takes two arguments and returns an integer.
For a tree list, what is the order for passing the arguments?
For example:

Tree1
-Child1
-Child2
-Child3
Tree2
-Child1
-Child2
-Child3
--SubChild1
--SubChild2


So, in the above case, how would the arguments be sent to this function?
Meaning what will be the two arguments for the compare function each time?

And also, please tell that what is the meaning of the return values?
Like sometimes this function returns 5, what does that mean?
What does 7 mean? Etc. I am asking this as I couldn't find any documentation regarding this issue.

I will really appreciate your help.
Re: Custom order of nodes in NatTable tree [message #1095086 is a reply to message #1094796] Mon, 26 August 2013 11:51 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk Fauth
Messages: 1262
Registered: July 2012
Senior Member
May I ask how experienced you are in Java programming? Because comparators are Java basics.

Have a look here to get an introduction http://docs.oracle.com/javase/tutorial/collections/interfaces/order.html
Re: Custom order of nodes in NatTable tree [message #1095197 is a reply to message #1095086] Mon, 26 August 2013 15:29 Go to previous message
Ali Malik is currently offline Ali Malik
Messages: 27
Registered: August 2013
Junior Member
Hi Dirk,

I know the basics, but I have always known the Comparator to return -1, 0 or 1.
I was debugging an example, SortableGridExample, and found out that the return values were somewhere 2, -53 etc.
So I asked this question to know if these numbers are used in some manner to manage the sorting.
But from your reply I guess these numbers aren't important, the number being negative, zero or positive is important only.

I am quite close to the solution now, will keep you posted.

Thanks,
Ali Ahmad Malik
Previous Topic:Cell spanning
Next Topic:RAP support
Goto Forum:
  


Current Time: Thu Aug 28 01:17:09 EDT 2014

Powered by FUDForum. Page generated in 0.01894 seconds