Catalog Plug-in ServicesThe Catalog plugin provides the following services:
The Catalog plugin supports several formats right out of the box and is easily extended for custom content.
Background InformationWe are going to launch right into technical details here – if you require additional background information please consider the following references:
The above references do no cover any additional ground beyond what is needed for normal eclipse plug-in development. Most of the above documentation is writen from the perspective of IDE development. The only additional restriction to watch out for is limit yourself to plug-ins available using a Rich Client Platform application. Common mistakes:
Overview of the CatalogPluginCatalogPlugin provides the following (from AbstractUIPlugin):
CatalogPlugin explicitly provides for the following:
Code Example – Use of ID and Logpublic void static countCatalog(){ CatalogPlugin catalog = CatalogPlugin.getDefault(); try { return catalog.getCatalogs().length; } catch( Throwable t ){ catalog.getLog( new Status( IStatus.WARNING, CatalogPlugin.ID, IStatus.OK, null, t) ); return 0; } } The above example makes use of CatalogPlugin, any problems are reported using the CatalogPlugin ID to the logging system. Overview of IResolveCatalog uses the model of a “handle� to allow access to spatial resources. The handle idea is captured by the IResolve class, this has the same design as the normal Eclipse IResource class. It makes use of the following design element:
With this in mind let us explore the core responsibilities of IResolve:
IResolve handles can form a tree using following methods:
Finally, just because a handle exists does not mean the real resource resources exists or is working. A service may be down, or a shapefile may not be created yet. Here is how to check on the status of a IResolve:
Note: Methods that are blocking make use of a IProgressMonitor, and throw an IOException in the event of a problem. This allows for both feedback during the operation, and strongly indicates to calling code that blocking input/output will occur. Lets quickly work with an example (to make this real) Code Example – Use of canResolve and resolve methodspublic count shapes( File shapefile ){ CatalogPlugin catalog = CatalogPlugin.getDefault(); IServiceFactory factory = catalog.getServiceFactory(); for( IResolve resolve : factory.aquire( shapefile.toUrl() ) ){ if( resolve.canResolve( DataStore.class ) ){ DataStore shape = resolve.resolve( DataStore.class ); String typeName = shape.getTypeNames()[0]; return shape.getFeatureSource( typeName ).count(); } } return 0; } Note: Remember this is Java 5, there is less casting then you may expect Comparison with IResourceIResolve offers the following advantages over normal Eclipse IResource:
Catalog APINow that the role and use of IResolve is known we can begin to describe the uDig Catalog API in some detail. The Catalog API is split between three abstractions:
It is also time to introduce an additional design element:
IGeoResource OverviewLets start with the most specific, and the most useful member of the Catalog API. IGeoResource represents real information, the kind you can display on screen or work with. Here are a few examples to get us started with:
The IGeoResource implementation does not place any restrictions on the interface used to represent the external resource. That said here are our top contenders for most popular interface:
IGeoResource and IGeoResourceInfoIGeoResource has the following extensions to IResolve:
Resolution Manager (Pending)Just because we know how to do a few tricks with Shapefiles, turn them into a FeatureSource does not mean you are left out of the game. You can teach the uDig catalog system new tricks. The ResolutionManager processes an extention point binding IResolve to new classes, you can use this facility to integrate your own functionality with the uDig application. |
(c) Copyright (c) 2004,2005 Refractions Research Inc. and others. |