Skip to main content



      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
Eclipse UserFriend
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
Eclipse UserFriend
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
Eclipse UserFriend
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
Eclipse UserFriend
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
Eclipse UserFriend
It worked! Many thanks indeed.
Previous Topic:serialize GEF Diagram
Next Topic:GEF Connector line not appearing using 'ConnectionDragCreationTool'
Goto Forum:
  


Current Time: Tue Apr 22 16:52:59 EDT 2025

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

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

Back to the top