[Gvsig_english] Creating a new View in the Project Window

Bruno Gomes semog15 at gmail.com
Mon Apr 26 17:54:48 CEST 2010


well, this can me util for someone, i resolve me probleme doing:

IWindow iwin = PluginServices.getMDIManager().getActiveWindow();

            MapControl mapControl = null;
            View vista = null;
            if(iwin instanceof View)
                mapControl = ((View) iwin).getMapControl();
            else
                if(iwin instanceof ProjectWindow){
                     vista = new View();
                     ProjectView pv = ProjectFactory.createView("view 1");

                     vista.initialize();
                     vista.setModel(pv);

                     Project p = new Project();
                     ((Project) p).addDocument(pv);
                     ((ProjectWindow) iwin).setProject(p);


                     mapControl = vista.getMapControl();
                     PluginServices.getMDIManager().addWindow(vista);
                }

Best regards.
On Fri, Apr 23, 2010 at 1:12 AM, Bruno Gomes <semog15 at gmail.com> wrote:

> I need to add a new layer to the current ProjectWindow, my code looks like:
>
> IWindow iwin = PluginServices.getMDIManager().getActiveWindow();
>
>                 if(iwin instanceof ProjectWindow){
>
>                      View vista = new View();
>                      ProjectView pvb = new ProjectView();
>
>                      vista.initialize();
>                      vista.setModel(pvb);
>                      PluginServices.getMDIManager().addWindow(vista);
>                 }
>
> But i get a error[1] when i try to set the view model.
> How should i set the ProjectView? Any ideas?
>
> java.lang.NullPointerException
>     at
> com.iver.cit.gvsig.project.documents.view.gui.View.setModel(View.java:172)
>
>
>
> --
> Bruno Gomes
>

Well, for further reference, i olve the problem by doing:

IWindow iwin = PluginServices.getMDIManager().getActiveWindow();

            MapControl mapControl = null;
            View vista = null;
            if(iwin instanceof View)
                mapControl = ((View) iwin).getMapControl();
            else
                if(iwin instanceof ProjectWindow){

                     vista = new View();
                     ProjectView pv = ProjectFactory.createView("view 1");


                     vista.initialize();
                     vista.setModel(pv);


                     Project p = new Project();
                     ((Project) p).addDocument(pv);
                     ((ProjectWindow) iwin).setProject(p);


                     mapControl = vista.getMapControl();
                     PluginServices.getMDIManager().addWindow(vista);
                }

-- 
Bruno Gomes
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://listserv.gva.es/pipermail/gvsig_internacional/attachments/20100426/99140ea0/attachment.htm 


More information about the Gvsig_internacional mailing list