Skip to main content


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 11:45 Go to next message
John Bradley is currently offline John BradleyFriend
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 11:55 Go to previous messageGo to next message
Devi Vara Prasad Bandaru is currently offline Devi Vara Prasad BandaruFriend
Messages: 100
Registered: March 2010
Location: Hyderabad
Senior 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 12:12 Go to previous messageGo to next message
John Bradley is currently offline John BradleyFriend
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 13:13 Go to previous messageGo to next message
Devi Vara Prasad Bandaru is currently offline Devi Vara Prasad BandaruFriend
Messages: 100
Registered: March 2010
Location: Hyderabad
Senior 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 13:58 Go to previous message
John Bradley is currently offline John BradleyFriend
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: Thu Mar 28 22:48:14 GMT 2024

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

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

Back to the top