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 11:01 Go to next message
Clara Miller is currently offline Clara Miller
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 03:17 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk Fauth
Messages: 1066
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 03: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 09:32 Go to previous messageGo to next message
Michi Classen is currently offline Michi Classen
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 13:01 Go to previous messageGo to next message
Tom Hochstein is currently offline Tom Hochstein
Messages: 12
Registered: July 2009
Junior Member
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 02:43 Go to previous messageGo to next message
Michi Classen is currently offline Michi Classen
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 02:57 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk Fauth
Messages: 1066
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 12:16 Go to previous message
Tom Hochstein is currently offline Tom Hochstein
Messages: 12
Registered: July 2009
Junior Member
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:GlazedLists & EMF
Next Topic:How to disable filter on some columns?
Goto Forum:
  


Current Time: Sat Apr 19 00:44:16 EDT 2014

Powered by FUDForum. Page generated in 0.02031 seconds