Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » NatTable » Hiding scrollbars of NatTable?
Hiding scrollbars of NatTable? [message #1012793] Fri, 22 February 2013 08:34 Go to next message
Alex Kipling is currently offline Alex Kipling
Messages: 254
Registered: July 2012
Senior Member
I would like to attach an additional view to my table, which would be scrolled vertically together with the table.

It should not be hidden on horizontal scrolling,
so i will not implement it as a NatTable column, but as an external widget.

http://i.imgur.com/pQxGS9h.png


Now, because I need only one scrollbar - I wanna take that , of the external widget.

Question:

How does the ViewPortlayer activate the scrollbars?
Where does it happen? How can I hide the Scrollbars, without loosing the ability to scroll the table?
Re: Hiding scrollbars of NatTable? [message #1012799 is a reply to message #1012793] Fri, 22 February 2013 08:41 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk Fauth
Messages: 1300
Registered: July 2012
Senior Member
Quote:
Where does it happen?


ScrollBarHandlerTemplate

Quote:
How can I hide the Scrollbars, without loosing the ability to scroll the table?


Currently you can't
Re: Hiding scrollbars of NatTable? [message #1013062 is a reply to message #1012799] Fri, 22 February 2013 17:38 Go to previous messageGo to next message
Alex Kipling is currently offline Alex Kipling
Messages: 254
Registered: July 2012
Senior Member
Hey Dirk,

I tried to override the doCommand method on the ViewPortLayer,
but there is something (probably the SelectLayer), what enables the ScrollBars again on Cell Select.

I would like to hook in and disable the VerticalScrollbar for ALL Layers.


Is there a point, which is ALLWAYS executed, before the NatTable is painted?

In which method can I hook in, to override disable the ScrollBars?

Do all layers send a repaint request to the Table? Can I hook in on Canvas repaint?


Do you have an idea how to disable the vertical scrollbar quick and dirty?


		bodyDataProvider = setupBodyDataProvider();
		DataLayer bodyDataLayer = new DataLayer(bodyDataProvider);
		//stack
		ColumnReorderLayer columnReorderLayer = new ColumnReorderLayer(bodyDataLayer);
		
		ColumnHideShowLayer columnHideShowLayer = new ColumnHideShowLayer(columnReorderLayer);
		SelectionLayer selectionLayer = new SelectionLayer(columnHideShowLayer);
		ViewportLayer viewportLayer = new ViewportLayer(selectionLayer){
			
			boolean isGridResizeOn= true;
			
			@Override
			public boolean doCommand(ILayerCommand command) {
				boolean result; 
						
				if(command instanceof ClientAreaResizeCommand){
					isGridResizeOn = false;
					result = super.doCommand(command);
					isGridResizeOn = false;
					natTable.getVerticalBar().setVisible(false);
					natTable.getVerticalBar().setEnabled(false);
					handleGridResize();					
				}else{
					return super.doCommand(command);
				}
				return result;
			}
			@Override
			protected void handleGridResize() {
				if(isGridResizeOn){
					natTable.getVerticalBar().setVisible(false);
					natTable.getVerticalBar().setEnabled(false);
					super.handleGridResize();
				}
			}
		};
		
		FreezeLayer freezeLayer = new FreezeLayer(selectionLayer);
		
		
	    final CompositeFreezeLayer compositeFreezeLayer = new CompositeFreezeLayer(freezeLayer, viewportLayer, selectionLayer);
	    
Re: Hiding scrollbars of NatTable? [message #1013075 is a reply to message #1013062] Fri, 22 February 2013 18:22 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk Fauth
Messages: 1300
Registered: July 2012
Senior Member
As I wrote before, you should look at the ScrollBarHandlerTemplate which activates/deactivates the Scrollbar. At least this is the position I know.

For a quick hack, I would override the ViewportLayer and try to register my own ScrollBarHandlerTemplate.

To do some additional actions after painting there are the OverlayPainters. Never used them before, but AFAIK they are used to be executed after painting.
Re: Hiding scrollbars of NatTable? [message #1013807 is a reply to message #1013075] Sun, 24 February 2013 11:07 Go to previous messageGo to next message
Alex Kipling is currently offline Alex Kipling
Messages: 254
Registered: July 2012
Senior Member
Sweet Dirk, will try overriding the ViewPortLayer!
What I allready tried - was disabling the ScrollBars after every call to the ScrollBarHandlerTemplate method which is responsible for enabling the SCrollbars (recalculateScrollbars() or something)

This worked, but the scrollbars are still enabled and redrawn somewhere else, so that they apear for some milliseconds on cell selection
That makes the scrollbars flicker.

My Idea was - allways disabling them just before we paint the table.
This will guarantee, that the Scrollbars will be disabled when table appears, independantly of stuff, which happened preiviously.
Re: Hiding scrollbars of NatTable? [message #1014340 is a reply to message #1013807] Mon, 25 February 2013 16:07 Go to previous messageGo to next message
Alex Kipling is currently offline Alex Kipling
Messages: 254
Registered: July 2012
Senior Member
Hey Dirk, thnx for advise, but I stuck again.

I created my own viewportLayer, and now I can hide the scrollbars.

Whan I need now - is registering my own scrollbar to control the NatTable.
Can you tell me, which code is responsible for looking at the ScrollBars and repainting the table accodingly?
Re: Hiding scrollbars of NatTable? [message #1014361 is a reply to message #1014340] Mon, 25 February 2013 16:55 Go to previous messageGo to next message
Alex Kipling is currently offline Alex Kipling
Messages: 254
Registered: July 2012
Senior Member
Found it, it was in ScrollBarHandlerTemplate#handleEvent too Smile

There is an interesting behaviour: when doing:
Display.getDefault().addFilter(SWT.KeyDown, new Listener(){
	int cnt = 0;

	@Override
	public void handleEvent(Event event) {
		int y = natTable.getVerticalBar().getSelection();
		
		//getting the table row by pixel
		int row = viewportLayer.getRowPositionByY(cnt+=1000);
		System.out.println("resulted row: "+row+" by using count "+cnt);
		
		viewportLayer.setOriginRowPosition(row);


The row is negative on every second iteration, when cnt is larger than 30000:

cnt 30000 gives row 1500
cnt 31000 gives row -1501
cnt 32000 gives row 1600
and so on...
Re: Hiding scrollbars of NatTable? [message #1014754 is a reply to message #1014361] Tue, 26 February 2013 11:56 Go to previous messageGo to next message
Alex Kipling is currently offline Alex Kipling
Messages: 254
Registered: July 2012
Senior Member
The problem with the negative rows returned from viewportLayer.getRowPositionByY()
is solved, by doing viewportLayer.getScrollableLayer().getRowPositionByY(position);
Re: Hiding scrollbars of NatTable? [message #1014776 is a reply to message #1014754] Tue, 26 February 2013 12:53 Go to previous message
Alex Kipling is currently offline Alex Kipling
Messages: 254
Registered: July 2012
Senior Member
Finally I managed to hide the ScrollBars and to make ViewportLayer using own ScrollBars (ScrollBars of my ScrollableComposite).

All I wanted to do was making the ViewPortLayer use my own scrollbars. This I could to by passing them on vBarListener, hBarListener creation.
But I could not do it by overriding the method, because vBarListener, hBarListener are private. By introducing my own vars - I would lose the functionality, impleneted in the private methods, inside ViewportLayer.

So I had to create my own ViewportLayer by copying the existing.
So I had to copy paste the VerticalScrollBarHandler, HorizontalScrollBarHandler
So I had to copy paste the ScrollBarHandlerTemplate


It would really be much easier, if ViewPortLayer#vBarListener, ViewPortLayer#hBarListener would have been protected.

Can I make a contribution, where those two variables will be changes to protected?
Is somehting like that - accepted?


UPDATE:
The problem of manipulating the scrollbars seems to be interesting for other people too: http://sourceforge.net/projects/nattable/forums/forum/744994/topic/5266231

[Updated on: Tue, 26 February 2013 12:57]

Report message to a moderator

Previous Topic:Decommissioning old web site
Next Topic:Is 1.0.0 actually released?
Goto Forum:
  


Current Time: Wed Oct 01 06:02:26 GMT 2014

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

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