Hei Benjamin,

how about not splitting the class (i.e. avoiding to break anything), but 
just add the second class for programmatical access? Maybe this could 
even go into the core.apitools package.

If you feel like creating such a class, I can add it.

cheers,
stefan

Benjamin Gudehus wrote:
> Hi!
> 
> If you just want to load shapefiles, you can use ShapefileReader 
> directly to load a shapefile into a FeatureCollection.
> 
> ShapefileReader reader = new ShapefileReader();
> FeatureCollection features = reader.read(new 
> DriverProperties(shapefilePath));
> Layer layer = context.getLayerManager().addLayer("Category Name", "Layer 
> Name", features);
> 
> DataSourceQuery: The monitor parameter is a TaskMonitor and used to 
> report progress and check cancel requests. Connection needs this 
> TaskMonitor, so you need to put the call into the run() method in the 
> (threaded) PlugIn to receive a monitor (public void run(TaskMonitor 
> monitor, PlugInContext context)).
> 
> If you don't want to use the run() / ThreadedPlugIn, you could maybe 
> create a com.vividsolutions.jump.task.DummyTaskMonitor and use it 
> monitor instead? (I didn't test this)
> 
> connection = dataSourceQuery.getDataSource().getConnection()
> connection.executeQuery(query, exceptions, new DummyTaskMonitor())
> 
> ----------
> 
> BTW: Maybe we should split LoadDatasetPlugIn into two PlugIns (I had 
> this idea a few weeks ago).
> 
> One called LoadDatasetPlugIn without dialog, which loads datasets into 
> the LayerManager.
> 
> LoadDatasetPlugIn datasetPlugIn = new LoadDatasetPlugIn();
> datasetPlugIn.setFilepath("~/shapefiles/world.shp");
> datasetPlugIn.setType("shapefile");
> datasetPlugIn.setCategory("Category Name");
> datasetPlugIn.setLayerName("Layer Name");
> datasetPlugIn.execute();
> 
> Another called LoadDatasetsDialogPlugIn with a dialog, which shows a 
> JFileChooser and uses the LoadDatasetPlugIn.
> 
> With LoadDatasetPlugIn one can programmatically load datasets. 
> LoadDatasetsDialogPlugIn is used in the workbench (File > Open...).
> 
> Greetings from rainy Hanover.
> 
> 
> 2010/5/26 Stefan Steiniger <sst...@geo.uzh.ch <mailto:sst...@geo.uzh.ch>>
> 
>     does it help you too look into this class:
> 
>     com.vividsolutions.jump.workbench.datasource.AbstractLoadDatasetPlugIn
> 
>     I think it is not used anymore...
> 
>     stefan
> 
>     Hernan Arellano wrote:
>      > Hi all!  i'm working on a project, with OpenJump 1.3.1, that it
>     needs to
>      > load a set of ESRI Shapefiles from a path to any category of the map.
>      >
>      > I`ve seen the following code to load a shapefile, of the method
>     "open"
>      > from DataSourceFileLayerLoader class. The problem is that this uses a
>      > monitor of a dialog that i haven´t, and i tried use this code but i
>      > couldn`t make the dataset.
>      >
>      > **************
>      > Connection connection =
>     dataSourceQuery.getDataSource().getConnection();
>      >     try {
>      >       FeatureCollection dataset =
>      > dataSourceQuery.getDataSource().installCoordinateSystem(
>      >           connection.executeQuery(dataSourceQuery.getQuery(),
>      > exceptions, monitor),
>      >
>      > CoordinateSystemRegistry.instance(workbenchContext.getBlackboard()));
>      >       if (dataset != null) {
>      >         LayerManager layerManager =
>     workbenchContext.getLayerManager();
>      >         Layer layer = new Layer(layerName,
>      >           layerManager.generateLayerFillColor(), dataset,
>     layerManager);
>      >         Category category =
>      > TaskUtil.getSelectedCategoryName(workbenchContext);
>      >         layerManager.addLayerable(category.getName(), layer);
>      >         layer.setName(layerName);
>      >         layer.setDataSourceQuery(dataSourceQuery);
>      > *****************
>      >
>      > ¿ How can i load a shapefile by code in a simple way without an
>      > OpenFileWizard ? .
>      >
>      > Thanks in advance!
>      >
>      >
>     ------------------------------------------------------------------------
>      >
>      >
>      >
>     ------------------------------------------------------------------------
>      >
>      >
>     
> ------------------------------------------------------------------------------
>      >
>      >
>      >
>      >
>     ------------------------------------------------------------------------
>      >
>      > _______________________________________________
>      > Jump-pilot-devel mailing list
>      > Jump-pilot-devel@lists.sourceforge.net
>     <mailto:Jump-pilot-devel@lists.sourceforge.net>
>      > https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel
> 
>     
> ------------------------------------------------------------------------------
> 
>     _______________________________________________
>     Jump-pilot-devel mailing list
>     Jump-pilot-devel@lists.sourceforge.net
>     <mailto:Jump-pilot-devel@lists.sourceforge.net>
>     https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel
> 
> 
> 
> ------------------------------------------------------------------------
> 
> ------------------------------------------------------------------------------
> 
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> Jump-pilot-devel mailing list
> Jump-pilot-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel

------------------------------------------------------------------------------

_______________________________________________
Jump-pilot-devel mailing list
Jump-pilot-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel

Reply via email to