[udig-devel] Re: About deleting a layer from catalog

Jesse Eichar jeichar at refractions.net
Thu Jul 26 15:36:54 PDT 2007


Very odd.  As far as I can tell that should work.  Have you tried  
debugging the uDIg code to see why it isn't working.  If you have  
uDig RC10 SDK the source code is shipped with the SDK so you can  
debug it.

Jesse

On Jul 26, 2007, at 2:13 PM, Schmitt, Magna (CIP) wrote:

> Hello:
> I called remove(IService) on the local catalog to remove a service  
> but the layer i would like to delete is not a 'shapefile' but a  
> 'gridfile'.
> To add a layer of that type, we had created a plugin to create a  
> service for this type of layer
> http://svn.geotools.org/udig/community/lavila/plugins/ 
> org.cgiar.cip.diva.catalog.addingridfiles this depends on this  
> other plugin: http://svn.geotools.org/udig/community/lavila/plugins/ 
> org.cgiar.cip.diva.utils
> so we can add programmatically gridfiles to the map editor.
> The problem is to delete them from catalog, so far i have this  
> implemented (thanks to you)   but it does not work because the  
> program does not know which type of service the gridfile is :
> private void removeFromCatalog(){
> 		IStructuredSelection sel = (IStructuredSelection)  
> LayersView.getViewer().getSelection();
>         for( Iterator iter = sel.iterator(); iter.hasNext(); ) {
>             Object o = iter.next();
>             if (o instanceof IService)
>                 remove((IService) o);
>             if (o instanceof GridfileGeoResource)
>                 remove((GridfileGeoResource) o);
>             if (o instanceof IGeoResource)
>                 remove((IGeoResource) o);
>
>         }
> 	}
>
> 	private void remove( IGeoResource service ) {
>         try {
>             remove(service.service(null));
>         } catch (IOException e) {
>             CatalogUIPlugin.log(null, e);
>         }
>     }
> 	
> 	private void remove( IService service ) {
>         CatalogPlugin.getDefault().getCatalogs()[0].remove(service);
>     }
>
> So, the question is how can I get the service to remove a file from  
> catalog?
> Thanks again,
> Magna
> _______________________________________________
> User-friendly Desktop Internet GIS (uDig)
> http://udig.refractions.net
> http://lists.refractions.net/mailman/listinfo/udig-devel



More information about the udig-devel mailing list