Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » Saving (& Reloading) the ViewPort location
Saving (& Reloading) the ViewPort location [message #143040] Fri, 16 July 2004 19:44 Go to next message
Eclipse UserFriend
Originally posted by: brian.fernandes.codito.com

Hi Guys,

I'm trying to save the viewport location in my diagram - so if you edit and
close your diagram, if you start at the same location the next time you edit
the same diagram.

Saving it is a piece of cake -
calling this method in my editor seems to give me the right location of the
scrollbars.
((FigureCanvas)((ScrollingGraphicalViewer)getGraphicalViewer ()).getControl()
).getViewport().getViewLocation();

However, I dont' know when / where to set the scrollbar location using
((FigureCanvas)((ScrollingGraphicalViewer)getGraphicalViewer ()).getControl()
).getViewport().setViewLocation(viewLocation);
on reload.

I cannot set it at after loading my model , becuase nothing has been drawn
yet - the viewport does not have it's final dimensions.
Seems rather simple - but I couldn't figure out where to call
setViewLocation after loading up a new editor.

Should I do this when the editPart of the last model is activated ?

I got it working to an extent by overriding GraphicalEditor#setFocus - I'm
sure there is a better place than this.
There was another issue with this, even though the diagram loads up with the
correct location, after losing focus, the editor scrolls back to (0,0) ?

Any suggestions appreciated,

Thanks,
Brian.
Re: Saving (& Reloading) the ViewPort location [message #145981 is a reply to message #143040] Mon, 02 August 2004 16:49 Go to previous message
Pratik Shah is currently offline Pratik ShahFriend
Messages: 1077
Registered: July 2009
Senior Member
Another possible way to do this is by adding a RangeModelListener. The
listener will be notified when the range model changes to be big enough to
fit the diagram and you could set the view location then (and remove the
listener once you are done). Of course, you'll get several notifications,
so you'll just have to ignore the ones that don't make sense (for instance,
if the max is less than the value you want to set). Where to add the
listener is your call.

"Brian Fernandes" <brian.fernandes@codito.com> wrote in message
news:cd9aoi$if8$1@eclipse.org...
> Hi Guys,
>
> I'm trying to save the viewport location in my diagram - so if you edit
and
> close your diagram, if you start at the same location the next time you
edit
> the same diagram.
>
> Saving it is a piece of cake -
> calling this method in my editor seems to give me the right location of
the
> scrollbars.
>
((FigureCanvas)((ScrollingGraphicalViewer)getGraphicalViewer ()).getControl()
> ).getViewport().getViewLocation();
>
> However, I dont' know when / where to set the scrollbar location using
>
((FigureCanvas)((ScrollingGraphicalViewer)getGraphicalViewer ()).getControl()
> ).getViewport().setViewLocation(viewLocation);
> on reload.
>
> I cannot set it at after loading my model , becuase nothing has been drawn
> yet - the viewport does not have it's final dimensions.
> Seems rather simple - but I couldn't figure out where to call
> setViewLocation after loading up a new editor.
>
> Should I do this when the editPart of the last model is activated ?
>
> I got it working to an extent by overriding GraphicalEditor#setFocus - I'm
> sure there is a better place than this.
> There was another issue with this, even though the diagram loads up with
the
> correct location, after losing focus, the editor scrolls back to (0,0) ?
>
> Any suggestions appreciated,
>
> Thanks,
> Brian.
>
>
>
>
Previous Topic:Decorations for Labels in GEF editors
Next Topic:ManhattanConnectionRouter and manualy bending
Goto Forum:
  


Current Time: Tue Jul 16 11:03:13 GMT 2024

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

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

Back to the top