Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[udig-devel] Null Exception when trying to (in code) load project file into custom map view

Hello, I have a custom MapView (RCP ViewPart) that reads in a udig project and loads the layers in a View.  In works fine when I run it directly in eclipse,  but when I export it via RCP product configuration and tool, I get an exception when I un-package it into the execution environment and run it, 

java.lang.NullPointerException
        at net.refractions.udig.project.element.impl.ProjectElementAdapterImpl.getFileExtension(ProjectElementAdapterImpl.java:365)
        at net.refractions.udig.project.internal.impl.ProjectImpl.generateResourceName(ProjectImpl.java:421)
        at net.refractions.udig.project.internal.impl.ProjectImpl.createNewResource(ProjectImpl.java:393)
        at net.refractions.udig.project.internal.impl.ProjectImpl.doCreation(ProjectImpl.java:343)
        at net.refractions.udig.project.internal.impl.ProjectImpl.createResourceAndAddElement(ProjectImpl.java:334)
        at net.refractions.udig.project.internal.impl.ProjectImpl.access$0(ProjectImpl.java:322)
        at net.refractions.udig.project.internal.impl.ProjectImpl$2.didSet(ProjectImpl.java:150)
        at org.eclipse.emf.ecore.util.EcoreEList.resolve(EcoreEList.java:174)
        at org.eclipse.emf.ecore.util.EObjectWithInverseResolvingEList.resolve(EObjectWithInverseResolvingEList.java:99)
        at org.eclipse.emf.common.util.BasicEList.get(BasicEList.java:354)
        at net.refractions.udig.project.internal.impl.SynchronizedEObjectWithInverseResolvingEList.get(SynchronizedEObjectWithInverseResolvingEList.java:78)
        at org.eclipse.emf.common.util.AbstractEList$EIterator.doNext(AbstractEList.java:709)
        at org.eclipse.emf.common.util.AbstractEList$EIterator.next(AbstractEList.java:696)
        at net.refractions.udig.project.internal.impl.ProjectImpl.getElements(ProjectImpl.java:167)
        at com.provectus.argo6.mapext.view.MapView.createPartControl(MapView.java:109)


My createPartControl for MapView is,

 @Override
    public void createPartControl( Composite parent ) {
        FillLayout fillLayout = new FillLayout();
        fillLayout.type = SWT.VERTICAL;
        parent.setLayout(fillLayout);
        mapviewer = new MapViewer(parent, SWT.SINGLE | SWT.DOUBLE_BUFFERED);
        logger = new Argo6Logger("MapView");
        IMenuManager viewMenu = getViewSite().getActionBars().getMenuManager();
        viewMenu.add(new SetBackgroundFileAction());
        viewMenu.add(new SetBackgroundWMSCAction());

        IToolBarManager toolbar = getViewSite().getActionBars().getToolBarManager();

        toolbar.add(new SetZoomToMapToolAction());
        toolbar.add(new SetZoomToArgoToolAction());

        ProjectRegistry projectRegistry = ProjectPlugin.getPlugin()
.getProjectRegistry();

        String projPath = System.getProperty("user.dir") + "/rcs-map-config.udig";
Project udigProject = projectRegistry.getProject(projPath);

if(udigProject != null) {
/* LINE 109 */ List<IMap> list = udigProject.getElements(IMap.class);
map = (Map)list.get(0);
        mapviewer.setMap(map);
            map.sendCommandASync(new ZoomToArgoCommand());
logger.logText("Opened uDig Map Project from " + projPath);

} else {
logger.logText("Error Loading Map Project from " + projPath);
}
    }


I'm still a little new to RCP plugin development so there may be an issue to do with dependencies that I'm not quite understanding.  My MapView.java class is in my "com.provectus.argo6.mapext" plugin, which contains all required udig plugin dependencies, so my "com.provectus.argo6.product" plugin just needs to include  "com.provectus.argo6.mapext" (and define the extension), and not any additional udig plugins as dependencies, correct?  I apologize, that's more of an RCP question than it is a uDig one.

Thank you to anyone who can help,

Ryan

Back to the top