Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » NatTable » Auto resize column by double clicking
Auto resize column by double clicking [message #1779525] Tue, 09 January 2018 08:59 Go to next message
Angel Fraile is currently offline Angel FraileFriend
Messages: 9
Registered: June 2016
Junior Member
Hi, in my nattable the double click in the column header to resize the column does not work anymore. I´m working with this structure of layers right now:

compositeLayer (CompositeLayer) with bodyLayer and columnHeaderLayer:

bodyLayer (AbstractLayerTransform) with:

bodyDataLayer = new DataLayer(...);
bodyHoverLayer = new HoverLayer(...);
eventLayer = new GlazedListsEventLayer(...)
columnHideShowLayer = new ColumnHideShowLayer(...)
selectionLayer = new SelectionLayer(...);
viewportLayerLeft = new ViewportLayer(...);
viewportLayerRight = new ViewportLayer(...)

columnHeaderLayer (AbstractLayerTransform) with:

columnHeaderDataLayer = new DefaultColumnHeaderDataLayer(...);
columnHeaderLayer = new ColumnHeaderLayer(...)

To restore the functionality I tried:

compositeLayer.registerCommandHandler((new AutoResizeColumnCommandHandler(compositeLayer, bodyDataLayer)));

but it does not work yet. I can see the resize cursor and I can resize the column manually. Any Idea about what I am doing false?

[Updated on: Tue, 09 January 2018 09:00]

Report message to a moderator

Re: Auto resize column by double clicking [message #1779541 is a reply to message #1779525] Tue, 09 January 2018 12:41 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2624
Registered: July 2012
Senior Member
Quote:
Hi, in my nattable the double click in the column header to resize the column does not work anymore.


If you haven't changed anything like for example exchanging a GridLayer with something else, it should not have worked before. The command handler is only registered by default with the GridLayer. So saying it doesn't work anymore feels wrong if you don't tell what you have changed. ;)

I suppose it is an issue in the layers you are using on creating the command handler. They are used to transform the positions accordingly. Typically it should look like this:

compositeLayer.registerCommandHandler(new AutoResizeColumnCommandHandler(compositeLayer, viewportLayer));


Since you are using split viewports I suppose you have a CompositeLayer in the body that is wrapped by a CompositeLayer with column header and the body. Instead of the bodyDataLayer I would try to use the CompositeLayer that builds your body to make it work.
Re: Auto resize column by double clicking [message #1779631 is a reply to message #1779541] Wed, 10 January 2018 13:12 Go to previous messageGo to next message
Angel Fraile is currently offline Angel FraileFriend
Messages: 9
Registered: June 2016
Junior Member
Hi Dirk, thank you for your help!

I was trying with your suggestion to use the CompositeLayer that builds the body but I do not find the right combination to make it work.

Using this:

compositeLayer.registerCommandHandler((new AuthAutoResizeColumnCommandHandler(compositeLayer, compositeLayer.getCreatorBodyLayerStack());


the compositeLayer.getCreatorBodyLayerStack() would be the CompositeLayer that builds the body.

My table can be scrolled horizontally hiding columns. With a couple of hiding columns and executing the double click I don´t have the current right position and the resize operation happens in other column (for example two columns to the right), so I´m working with the wrong layer for sure. I show you my structure of layers more coplete and maybe you can help me again with my issue:


compositeLayer = new CompositeLayerCreator(...);
CompositeLayerCreator extends CompositeLayer with
	 
	// Body Layer
        bodyLayer = new CreatorBodyLayerStack(...)
		
	CreatorBodyLayerStack extends AbstractLayerTransform with
			bodyDataLayer = new DataLayer(...);
			bodyHoverLayer = new HoverLayer(...);
			eventLayer = new GlazedListsEventLayer(...)
			columnHideShowLayer = new ColumnHideShowLayer(...)
			selectionLayer = new SelectionLayer(...);
			
			CompositeLayer compositeLayer = new CompositeLayer with
			viewportLayerLeft = new ViewportLayer(...);
			viewportLayerRight = new ViewportLayer(...);
		

        // Column header
        columnHeaderLayer = new CreatorColumnHeaderLayerStack(...);
		
	CreatorColumnHeaderLayerStack extends AbstractLayerTransform with
			columnHeaderDataLayer = new DefaultColumnHeaderDataLayer(...);
			columnHeaderLayer = new ColumnHeaderLayer(...)



Thanks again.
Re: Auto resize column by double clicking [message #1779634 is a reply to message #1779631] Wed, 10 January 2018 14:23 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2624
Registered: July 2012
Senior Member
I would have expected that it works with your approach. But you are using quite some customizations and I am not sure which is affecting this. Everything is working fine in _5044_HorizontalSplitViewportGridExample in a GridLayer.

Maybe it is your CreatorColumnHeaderLayerStack. Why do you create one? the ColumnHeaderLayer is a very special layer as it is dimensionally dependent on the body. Maybe there is an issue with the transformation? Have you tried to use the ColumnHeaderLayer directly like in the example?
Re: Auto resize column by double clicking [message #1779748 is a reply to message #1779634] Fri, 12 January 2018 08:39 Go to previous message
Angel Fraile is currently offline Angel FraileFriend
Messages: 9
Registered: June 2016
Junior Member
I found a solution to my problem working with the different layers that build my environment.

First I tried to use the ColumnHeaderLayer directly like in the example, but the behaviour was the same. At the end all works fine using my ColumnHideShowLayer:

compositeLayer.registerCommandHandler((new AutoResizeColumnCommandHandler(columnHideShowLayer, compositeLayer.getCreatorBodyLayerStack());


Thanks again!
Previous Topic:ColumnGroup collapsable even if no ColumnGroupExpandCollapseLayer registered
Next Topic:Excel Export with .xlsx
Goto Forum:
  


Current Time: Fri Nov 16 09:15:25 GMT 2018

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

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

Back to the top