try {
pm.beginTask("Removing maps...", toList.size());
for( Object object : toList ) {
if (object instanceof JGrassMapGeoResource) {
JGrassMapGeoResource mr = (JGrassMapGeoResource) object;
String type = mr.getType();
if (type.equals(JGrassConstants.GRASSBINARYRASTERMAP)) {
String[] mapsetpathAndMapname = JGrassCatalogUtilities
.getMapsetpathAndMapnameFromJGrassMapGeoResource(mr);
try {
removeGrassRasterMap(mapsetpathAndMapname[0], mapsetpathAndMapname[1]);
((JGrassMapsetGeoResource) mr.parent(new NullProgressMonitor())).removeMap(
mapsetpathAndMapname[1], JGrassConstants.GRASSBINARYRASTERMAP);
IMap activeMap = ApplicationGIS.getActiveMap();
List<ILayer> mapLayers = activeMap.getMapLayers();
String mapName = mr.getTitle();
List<ILayer> toRemove = new ArrayList<ILayer>();
for( int i = 0; i < mapLayers.size(); i++ ) {
String layerName = mapLayers.get(i).getName();
if (layerName.equals(mapName)) {
// remove it from layer list