Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » Setting scroll position programmatically seems to fail
Setting scroll position programmatically seems to fail [message #646150] Wed, 22 December 2010 06:45 Go to next message
John Bradley is currently offline John Bradley
Messages: 14
Registered: July 2009
Junior Member
I want to click on an item in one editor and have it open a different GEF editor associated with the clicked-on item and position (by scolling) the GEF editor so that the editPart's figure that corresponds to the clicked item is visible: sometimes the code needs to scroll the GEF editor Viewport so that the selected item is visible. I can figure out where to scroll to, but when I invoke scrollVerticalTo() on the ScrollPane to try to do the scroll nothing happens.

Is there a different/better/correct way to do this?
Re: Setting scroll position programmatically seems to fail [message #646153 is a reply to message #646150] Wed, 22 December 2010 06:55 Go to previous messageGo to next message
Devi Vara Prasad Bandaru is currently offline Devi Vara Prasad Bandaru
Messages: 98
Registered: March 2010
Location: Hyderabad
Member

Use this in your graphical editor
getGraphicalViewer().reveal(editpart) 



Re: Setting scroll position programmatically seems to fail [message #646156 is a reply to message #646150] Wed, 22 December 2010 07:12 Go to previous messageGo to next message
John Bradley is currently offline John Bradley
Messages: 14
Registered: July 2009
Junior Member
Many thanks! That does work, but it places the object at the very bottom of the viewing area: a long shot better than nothing but not ideal since the context (above and below) the object is useful for the user to see -- Do I then need to invoke the scrolling after this to get it moved up a bit?
Re: Setting scroll position programmatically seems to fail [message #646160 is a reply to message #646156] Wed, 22 December 2010 08:13 Go to previous messageGo to next message
Devi Vara Prasad Bandaru is currently offline Devi Vara Prasad Bandaru
Messages: 98
Registered: March 2010
Location: Hyderabad
Member

See the below snippet. This tries to scroll the canvas to a point which is 100 units away from the initial bounds(x,y). You can modify it based on your requirement.
			IFigure target = ((GraphicalEditPart)editPart).getFigure();
			FigureCanvas figureCanvas = (FigureCanvas)getGraphicalViewer().getControl();
			figureCanvas.scrollTo(target.getBounds().x - 100 , target.getBounds().y - 100);



Re: Setting scroll position programmatically seems to fail [message #646166 is a reply to message #646150] Wed, 22 December 2010 08:58 Go to previous message
John Bradley is currently offline John Bradley
Messages: 14
Registered: July 2009
Junior Member
It worked! Many thanks indeed.
Previous Topic:serialize GEF Diagram
Next Topic:GEF Connector line not appearing using 'ConnectionDragCreationTool'
Goto Forum:
  


Current Time: Wed Aug 27 04:59:26 EDT 2014

Powered by FUDForum. Page generated in 0.08462 seconds