Accessing a plug-in data source programmatically
The code snippet below shows how to access a plug-in data source programmatically to add the custom data as a read-only layer to the map. Notice the workspace factory is created by using the method EngineContext.createObject(). The object reference of the PlugInWorkspaceFactoryHelper class is passed in as the method argument for the createObject() method.
[Java]
//Declare class variable
addPluginDsLayer(MapBean mapBean, String folderName, String featureClassName){
//Add snippet to add PlugIn DS as a feature layer to the map
IWorkspaceFactory workspaceFactory = (IWorkspaceFactory)
EngineContext.createObject(SimplePointWorkspaceFactoryHelper.class);
IFeatureWorkspace featureWorkspace = (IFeatureWorkspace)
workspaceFactory.openFromFile(folderName, 0);
IFeatureClass featureClass = featureWorkspace.openFeatureClass(featureClassName);
//create a new feature layer and add it to the map
IFeatureLayer featureLayer = new FeatureLayer();
featureLayer.setName(featureClass.getAliasName());
featureLayer.setFeatureClassByRef(featureClass);
mapBean.addLayer((ILayer)featureLayer, 0);
mapBean.refresh(esriViewDrawPhase.esriViewGeography, null, null);
}
You can also open the workspace with IWorkspaceFactory.open. In this case, supply a property set with a single property of DATABASE and the appropriate workspace string.
Development licensing | Deployment licensing |
---|---|
Engine Developer Kit | Engine Runtime |
ArcView | ArcView |
ArcEditor | ArcEditor |
ArcInfo | ArcInfo |