| Saving (& Reloading) the ViewPort location [message #143040] | 
Fri, 16 July 2004 15:44   | 
 
Eclipse User  | 
 | 
 | 
   | 
 
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 12:49   | 
 
Eclipse User  | 
 | 
 | 
   | 
 
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. 
> 
> 
> 
>
 |  
 |  
  | 
Powered by 
FUDForum. Page generated in 0.03212 seconds