Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » NatTable » TreeNatTableExample - single selection on expand/collapse image doesn't work(TreeNatTableExample - single selection on expand/collapse image doesn't work)
TreeNatTableExample - single selection on expand/collapse image doesn't work [message #901060] Thu, 09 August 2012 15:01 Go to next message
Clara Miller is currently offline Clara MillerFriend
Messages: 1
Registered: August 2012
Junior Member
Dear Dirk,
thank you for the good examples and explanations of NatTable usage. I'm interested in using your TreeNatTableExample.

As of one point the sample is perfect:

Currently the tree expands/collapses when a double click is made onto the row. But a single click on the expand/collapse image doesn't work in your example and I can't find the problem, why. The samples at NatTable are using a different approach than you and this point works fine.

Do you know how to correct this erroneous behavior?

Thanks!
Re: TreeNatTableExample - single selection on expand/collapse image doesn't work [message #901157 is a reply to message #901060] Fri, 10 August 2012 07:17 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2902
Registered: July 2012
Senior Member
Hi,

it took me a moment to figure out which example in the NatTable examples you mean. But ok, you are talking about my article in the eclipse magazine this year. Smile

You are right that I missed a configuration for enabling single click expand/collapse there.

You should add the DefaultTreeLayerConfiguration to your NatTable like this

natTable.addConfiguration(new DefaultTreeLayerConfiguration(treeLayer.getModel()));


which will add the needed configurations.

Alternatively you could add the needed UiBindings in your custom configurations yourself like this

	public void configureUiBindings(UiBindingRegistry uiBindingRegistry) {
		uiBindingRegistry.registerFirstDoubleClickBinding(
				MouseEventMatcher.bodyLeftClick(SWT.NONE), 
				new TreeExpandCollapseAction()
		);
		
		uiBindingRegistry.registerFirstSingleClickBinding(
				new CellPainterMouseEventMatcher(GridRegion.BODY, MouseEventMatcher.LEFT_BUTTON, treeImagePainter),
				new TreeExpandCollapseAction()
		);
	}


But I would suggest to use the DefaultTreeLayerConfiguration.

Hope this helps.

Greez,
Dirk

[Updated on: Fri, 10 August 2012 07:20]

Report message to a moderator

Re: TreeNatTableExample - single selection on expand/collapse image doesn't work [message #903975 is a reply to message #901157] Mon, 27 August 2012 13:32 Go to previous messageGo to next message
Michi Classen is currently offline Michi ClassenFriend
Messages: 36
Registered: March 2012
Member
Hi,

thanks for help! Now it works great!

Ciao,
Michi

Re: TreeNatTableExample - single selection on expand/collapse image doesn't work [message #909733 is a reply to message #903975] Fri, 07 September 2012 17:01 Go to previous messageGo to next message
Eclipse UserFriend
I am also having a problem with single-click expand and the TreeGridExample. It appears that DefaultTreeLayerConfiguration() has been removed on head, and the bindings moved to TreeLayer. This change is working fine for the checkbox example, but not for TreeGridExample. From debugging, it appears that the code is matching to MouseEditAction via BodyCellEditorMouseEventMatcher instead of TreeExpandCollapseAction via CellPainterMouseEventMatcher. As an experiment, I modified the code in UiBindingRegistry.getMouseEventAction() so that it would find all actions. In this case both the MouseEditAction and the TreeExpandCollapseAction are found. For the checkbox example, only the one correct action is found.
Re: TreeNatTableExample - single selection on expand/collapse image doesn't work [message #910647 is a reply to message #909733] Mon, 10 September 2012 06:43 Go to previous messageGo to next message
Michi Classen is currently offline Michi ClassenFriend
Messages: 36
Registered: March 2012
Member
Hi Tim,

please add the default tree configuration to the example class TreeNatTableExample:

natTable.addConfiguration( new DefaultTreeLayerConfiguration( grid.getTreeRowModel() ) );


Modify class TreeGridLayer as follows:

public class TreeGridLayer extends SortableGridLayer {

  // new variable
  protected ITreeRowModel<PersonWithAddress> treeRowModel;

  @Override
  protected BodyLayerStack createBodyLayerStack( List<PersonWithAddress> values ) {

    ...

    treeRowModel = new GlazedListTreeRowModel<PersonWithAddress>( treeData );
    BodyLayerStack bodyLayerStack = new BodyLayerStack( glazedListsEventLayer, treeRowModel );
    ...
  }

  public ITreeRowModel<PersonWithAddress> getTreeRowModel() {
    return treeRowModel;
  }
}


Thats it and then the single selection works fine.

Cheers,
Michi
Re: TreeNatTableExample - single selection on expand/collapse image doesn't work [message #910657 is a reply to message #910647] Mon, 10 September 2012 06:57 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2902
Registered: July 2012
Senior Member
Thank you Michi for your explanation. Unfortunately Tim is reporting the issue existing in head of our Git repository, and there it didn't work because of

https://bugs.eclipse.org/bugs/show_bug.cgi?id=386750

So as you can see there, it should be fixed again now. But we will have to take a deeper look at this so you don't have to deal with that yourself.

Greez,
Dirk
Re: TreeNatTableExample - single selection on expand/collapse image doesn't work [message #913026 is a reply to message #910657] Fri, 14 September 2012 16:16 Go to previous message
Eclipse UserFriend
Single click selection (i.e., not expand/collapse) in the tree examples is not working either. Please note that at first I thought this was intermittent, but then I noticed that single click-drag works just fine. This means that if you don't keep your mouse perfectly still while clicking, it will look like it is working.

This doesn't appear to be the same problem as for tree expand/collapse. I modified UIBindingRegistry.getMouseEventAction() again as I described below, but this time I didn't see that one mouse action was hiding the other.

Tom
Previous Topic:Custom Editors
Next Topic:GlazedLists & EMF
Goto Forum:
  


Current Time: Fri Apr 19 15:14:45 GMT 2024

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

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

Back to the top