final Shell shell = PlatformUI.getWorkbench().getDisplay().getActiveShell();
Object firstElement = selection.getFirstElement();
if (firstElement instanceof JGrassMapsetGeoResource) {
try {
JGrassMapsetGeoResource mapsetResource = (JGrassMapsetGeoResource) firstElement;
File mapsetFile = mapsetResource.getFile();
// create a thread and inside do a syncExec
FileDialog fileDialog = new FileDialog(Display.getDefault().getActiveShell(), SWT.OPEN
| SWT.MULTI);
fileDialog.setFilterExtensions(new String[]{"*.asc", "*.ASC", "*.tif", "*.TIF", "*.tiff",
"*.TIFF", "*.*"});
String selpath = fileDialog.open();
if (selpath == null) {
return;
}
File mapFile = new File(selpath);
if (!mapFile.exists()) {
return;
}
File folder = mapFile.getParentFile();
String[] fileNames = fileDialog.getFileNames();
pm.beginTask("Importing maps...", fileNames.length);
for( int i = 0; i < fileNames.length; i++ ) {
mapFile = new File(folder, fileNames[i]);
/*
* import the file
*/
CoordinateReferenceSystem jGrassCrs = mapsetResource.getLocationCrs();
GridCoverage2D geodata = null;
CoordinateReferenceSystem fileCrs = null;
if (mapFile.getName().toLowerCase().endsWith(".asc")) {
ArcGridReader arcGridReader = new ArcGridReader(mapFile);
geodata = arcGridReader.read(null);