Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » NatTable » Drag and Drop in a TreeLayer(How to do drag and drop in a TreeLayer)
Drag and Drop in a TreeLayer [message #1843715] Sun, 15 August 2021 17:00 Go to next message
Marc Ernst is currently offline Marc ErnstFriend
Messages: 5
Registered: August 2021
Junior Member
I have done my own ITreeData class which works fine, there are groups with items and just root items. I indexed the list with the sub items sequentially. I tried to implement drag and drop with a mouse down listener, moving the items to the correct index in the list and adding/removing them to and from the group to update the underlying data. Unfortunately it seems the treeLayer sorts and moves the items around so they are totally missaligned with my list. Should I create a layer to simulate drag and drop instead of moving the items around? Thanks for your help.
Re: Drag and Drop in a TreeLayer [message #1843721 is a reply to message #1843715] Mon, 16 August 2021 06:11 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2902
Registered: July 2012
Senior Member
As I don't know your concrete implementation I can't tell much. But typically the tree is built up based on some sorting. Maybe this is causing the issue you are facing.

IIUC you want to implement something similar to the row reorder feature. If you want to directly update the index of an item in the list you don't need a layer as you don't want a transformed view. But you should use the NatTable bindings and not swt listeners. Maybe a look at the RowReorderLayer and especially the bindings to get a better idea of how to solve your requirements.
Re: Drag and Drop in a TreeLayer [message #1843722 is a reply to message #1843721] Mon, 16 August 2021 06:36 Go to previous messageGo to next message
Marc Ernst is currently offline Marc ErnstFriend
Messages: 5
Registered: August 2021
Junior Member
Thanks a lot, I've got it working this morning. I created a row start and end drag n drop command. Then I registered it directly with the data layer. This seems to work fine now. One other problem I have is that I would like to show a column header whenever the underlying data is of different type. I'm experimenting with a layer doing the transformation for me. Do you think this can ever work with treeLayer? Do you have some hints which can help to implement this?

Group -
Name | value -> the header
- Integer child one | 10
- Integer child two | 20
Name | Text -> the header
- Text child one | ""
- Text child two | ""

Above is only an example, the types are more complex.
Re: Drag and Drop in a TreeLayer [message #1843729 is a reply to message #1843722] Mon, 16 August 2021 09:17 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2902
Registered: July 2012
Senior Member
Not sure if I understand your requirement correctly. But typically if you want to render something else in a cell you register a converter.
Re: Drag and Drop in a TreeLayer [message #1843731 is a reply to message #1843729] Mon, 16 August 2021 09:29 Go to previous messageGo to next message
Marc Ernst is currently offline Marc ErnstFriend
Messages: 5
Registered: August 2021
Junior Member
You understood me wrong, the idea is to add a header row dynamically above the rows with the same type. Different types will have different header rows. What I tried is to create an AbstractLayerTransform and calculate the header rows when the underlying layer has changed. I overwrite local to position and underlying layer to local methods but it does not show me any content. I attached the layer, maybe it helps.
Re: Drag and Drop in a TreeLayer [message #1843739 is a reply to message #1843731] Mon, 16 August 2021 11:41 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2902
Registered: July 2012
Senior Member
Sounds similar to the groupby feature in NatTable. But there we actually use GlazedLists and add the structural rows to the list. Adding structural rows in a layer is more complicated. For columns we have done this in the HierarchicalTreeLayer. Maybe that helps.
Re: Drag and Drop in a TreeLayer [message #1843741 is a reply to message #1843739] Mon, 16 August 2021 12:14 Go to previous messageGo to next message
Marc Ernst is currently offline Marc ErnstFriend
Messages: 5
Registered: August 2021
Junior Member
After some modifications I could see some data and row headers using the layer but still it's not showing everything. Seems to be very complicated using a layer. I will try the solution with adding the headers to the structure but this is a bad solution as it is not real data and I have to take care for the drag n drop and adding/removing items (also to a group of items).
Re: Drag and Drop in a TreeLayer [message #1843744 is a reply to message #1843741] Mon, 16 August 2021 14:59 Go to previous message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2902
Registered: July 2012
Senior Member
To every issue there are multiple solutions. Each has its pros and cons. The issue/feature you address is definitely an advanced one.

If you need professional support, I offer consulting around NatTable.
Previous Topic:UpdateDataCommand + ViewportLayer
Next Topic:coloring of nattable cells dynamically
Goto Forum:
  


Current Time: Thu Apr 25 13:27:22 GMT 2024

Powered by FUDForum. Page generated in 0.02867 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top