[Gvsig_desarrolladores] [gvSIG-devel] Proposed change to MDIManager API

Benjamin Ducke benjamin.ducke en oxfordarch.co.uk
Dom Jul 10 13:32:15 CEST 2011



----- Original Message -----
> Hi,
> 
> Reviewing old gvSIG bug, i found this one.
> 
> http://forge.osor.eu/tracker/index.php?func=detail&aid=12265&group_id=89&atid=732
> 
> It's a bit annoying and it happens many times. There are many
> approaches that if not solve it at least will minimize the number of
> times that it happens. A resume of what it's happening is that many
> times developers use the sentence below to get the view with the hope
> that the active window is a view, but this not happens always, and an
> exception is thrown.
> 
> View view = (View)PluginServices.getMDIManager().getActiveWindow();
> 
> Probably a good programming practice will be set the view in the
> constructor or something like that, but anyway can be useful create a
> new method like getViewWindows() in MDIManager, that returns the View
> if it's active or a selection dialog with all the View Windows if none
> of then is active. As it implies an API change i think that some
> discussion is needed.
> 

I think the best solution may be to search for all occurences

(View)PluginServices.getMDIManager().getActiveWindow();

and replace them with the code suggested in the OSOR ticket:

View view = null;
IWindow iwindow = PluginServices.getMDIManager().getActiveWindow(
);
if (iwindow instanceof View) {
  view = (View) iwindow;
}

If after that code block View is still null, then we have lost
track of the active view. In that case, a message window should
appear which asks the user to select the view the operation should
be applied to.

Ben

> Feel free to comment the bug or send your opinions to this thread.
> 
> bests
> 
> 
> -- Francisco Puga
> Grupo de Desarrollo
> Cartolab - Laboratorio de Ingeniería Cartográfica.
> http://www.cartolab.es
> 
> ETS Ingeniería de Caminos, Canales y Puertos
> Universidade da Coruña
> Campus de Elviña - 15071 A Coruña (España)
> (34)981167000 ext. 5493
> _______________________________________________ gvSIG-desktop-devel
> mailing list
> gvSIG-desktop-devel en lists.forge.osor.eu
> https://lists.forge.osor.eu/listinfo/gvsig-desktop-devel


------
Files attached to this email may be in ISO 26300 format (OASIS Open Document Format). If you have difficulty opening them, please visit http://iso26300.info for more information.



Más información sobre la lista de distribución gvSIG_desarrolladores