Index: trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/main/java/org/gvsig/app/extension/ViewSimpleSelectionControl.java
===================================================================
--- trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/main/java/org/gvsig/app/extension/ViewSimpleSelectionControl.java	(revision 0)
+++ trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/main/java/org/gvsig/app/extension/ViewSimpleSelectionControl.java	(revision 41066)
@@ -0,0 +1,188 @@
+/**
+ * gvSIG. Desktop Geographic Information System.
+ *
+ * Copyright (C) 2007-2013 gvSIG Association.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 3
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ *
+ * For any additional information, do not hesitate to contact us
+ * at info AT gvsig.com, or visit our website www.gvsig.com.
+ */
+/* CVS MESSAGES:
+ *
+ * $Id: ViewSelectionControls.java 38702 2012-08-09 18:40:20Z jjdelcerro $
+ * $Log$
+ * Revision 1.16  2007-03-06 16:34:02  caballero
+ * Exceptions
+ *
+ * Revision 1.15  2007/01/04 07:24:32  caballero
+ * isModified
+ *
+ * Revision 1.14  2006/12/27 11:08:56  fdiaz
+ * Arreglado el metodo hasVectorLayers para que no se pare en los grupos de capas cuando estos no tienen capas vectoriales.
+ *
+ * Revision 1.13  2006/09/25 16:54:12  caballero
+ * invert selection
+ *
+ * Revision 1.12  2006/09/20 13:17:40  jaume
+ * *** empty log message ***
+ *
+ * Revision 1.11  2006/09/20 10:56:56  sbayarri
+ * Refactorizaci�n clases View y ProjectView
+ *
+ * Revision 1.10  2006/09/15 10:40:03  caballero
+ * extensibilidad de documentos
+ *
+ * Revision 1.9  2006/09/11 16:14:15  fjp
+ * Invertir seleccion. Falta subirlo al branch de la 1.0
+ *
+ * Revision 1.8  2006/09/11 06:53:13  fjp
+ * Antes del parto
+ *
+ * Revision 1.7  2006/09/04 16:26:54  fjp
+ * Seleccionar por pol�gono
+ *
+ * Revision 1.6  2006/08/29 07:56:27  cesar
+ * Rename the *View* family of classes to *Window* (ie: SingletonView to SingletonWindow, ViewInfo to WindowInfo, etc)
+ *
+ * Revision 1.5  2006/08/29 07:21:08  cesar
+ * Rename com.iver.cit.gvsig.fmap.Fmap class to com.iver.cit.gvsig.fmap.MapContext
+ *
+ * Revision 1.4  2006/08/29 07:13:53  cesar
+ * Rename class com.iver.andami.ui.mdiManager.View to com.iver.andami.ui.mdiManager.IWindow
+ *
+ * Revision 1.3  2006/08/18 08:40:04  jmvivo
+ * Actualizado para que el isEnabled tenga en cuenta que las capas esten 'avialable'
+ *
+ * Revision 1.2  2006/07/27 06:20:28  jaume
+ * *** empty log message ***
+ *
+ * Revision 1.1  2006/07/26 09:53:05  jaume
+ * separadas las herramientas de selecci�n del viewControls al ViewSelectionControls
+ *
+ *
+ */
+package org.gvsig.app.extension;
+
+import org.gvsig.andami.IconThemeHelper;
+import org.gvsig.andami.PluginServices;
+import org.gvsig.andami.plugins.Extension;
+import org.gvsig.andami.ui.mdiManager.IWindow;
+import org.gvsig.app.project.documents.AbstractDocument;
+import org.gvsig.app.project.documents.view.ViewDocument;
+import org.gvsig.app.project.documents.view.gui.DefaultViewPanel;
+import org.gvsig.app.project.documents.view.gui.IView;
+import org.gvsig.fmap.mapcontext.MapContext;
+import org.gvsig.fmap.mapcontext.layers.FLayer;
+import org.gvsig.fmap.mapcontext.layers.FLayers;
+import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect;
+import org.gvsig.fmap.mapcontrol.MapControl;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * Extension that handles the simple selection tool
+ *
+ */
+public class ViewSimpleSelectionControl extends Extension {
+    
+    private static final Logger logger = LoggerFactory
+            .getLogger(ViewSimpleSelectionControl.class);
+    
+	public void initialize() {
+		registerIcons();
+	}
+
+	private void registerIcons(){
+		IconThemeHelper.registerIcon("action", "selection-simple-select", this);
+	}
+
+	public void execute(String actionCommand) {
+	    
+	    IView view = this.getView();
+	    if (view == null) {
+	        logger.info("Didn't find the view.", new Exception("Didn't find the view"));
+	        return;
+	    }
+	    
+		MapControl mapCtrl = view.getMapControl();
+		logger.debug("Comand : " + actionCommand);
+		if (actionCommand.equalsIgnoreCase("selection-simple-select-view")) {
+			mapCtrl.setTool("pointSelection");
+			view.getViewDocument().setModified(true);
+		} 
+	}
+	
+	public boolean isEnabled() {
+	    return isVisible();
+	}
+
+	public boolean isVisible() {
+	    
+	    IView view = getView();
+	    if (view != null) {
+	        MapContext mapa = view.getMapControl().getMapContext();
+	        if (hasVectorLayers(mapa.getLayers())) {
+	            if (singleActiveInEditing(mapa)) {
+	                return false;
+	            } else {
+	                return true;
+	            }
+	        } else {
+	            return false;
+	        }
+	    } else {
+	        return false;
+	    }
+	}
+
+	private boolean singleActiveInEditing(MapContext mapa) {
+	    
+	    FLayer[] lyrs = mapa.getLayers().getActives();
+	    if (lyrs != null && lyrs.length == 1) {
+	        return lyrs[0].isEditing();
+	    } else {
+	        return false;
+	    }
+    }
+
+    private boolean hasVectorLayers(FLayers layers) {
+		for (int i = 0; i < layers.getLayersCount(); i++) {
+			FLayer lyr =layers.getLayer(i);
+			if (lyr instanceof FLayers){
+				if (hasVectorLayers((FLayers) lyr)){
+					return true;
+				}
+			} else if (lyr instanceof FLyrVect) {
+				return true;
+			}
+		}
+		return false;
+	}
+	
+	private IView getView() {
+	    
+	    IView resp = null;
+	    IWindow f = PluginServices.getMDIManager().getActiveWindow();
+
+        if (f != null && f instanceof IView) {
+            resp = (IView) f;
+        }
+        return resp;
+	}
+	
+}
Index: trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/main/java/org/gvsig/app/extension/ViewSelectionControls.java
===================================================================
--- trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/main/java/org/gvsig/app/extension/ViewSelectionControls.java	(revision 41065)
+++ trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/main/java/org/gvsig/app/extension/ViewSelectionControls.java	(revision 41066)
@@ -108,7 +108,6 @@
 	}
 
 	private void registerIcons(){
-		IconThemeHelper.registerIcon("action", "selection-simple-select", this);
 		IconThemeHelper.registerIcon("action", "selection-select-by-rectangle", this);
 		IconThemeHelper.registerIcon("action", "selection-select-by-polygon", this);
 		IconThemeHelper.registerIcon("action", "selection-clear", this);
@@ -121,10 +120,6 @@
 			mapCtrl.setTool("rectSelection");
 			((AbstractDocument)vista.getModel()).setModified(true);
 			
-		} else if (actionCommand.equalsIgnoreCase("selection-simple-select-view")) {
-			mapCtrl.setTool("pointSelection");
-			((AbstractDocument)vista.getModel()).setModified(true);
-			
 		} else if (actionCommand.equalsIgnoreCase("selection-select-by-polygon")) {
 			mapCtrl.setTool("polSelection");
 			((AbstractDocument)vista.getModel()).setModified(true);
Index: trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/main/resources-plugin/config.xml
===================================================================
--- trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/main/resources-plugin/config.xml	(revision 41065)
+++ trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/main/resources-plugin/config.xml	(revision 41066)
@@ -529,16 +529,8 @@
       description="Extensi�n encargada de gestionar la vista."
       active="true"
       priority="30">
+
       <action 
-        name="selection-simple-select-view"
-        label="_Simple_select" 
-        position="300700000" 
-        action-command="selection-simple-select-view" 
-        icon="selection-simple-select"
-        tooltip="_Simple_select" 
-        accelerator=""
-        />
-      <action 
         name="selection-select-by-rectangle-view"
         label="Select_by_rectangle" 
         position="301200000" 
@@ -557,12 +549,7 @@
         accelerator=""
         />
 
-
       <menu 
-        name="selection-simple-select-view"
-        text="Selection/Simple" 
-        />
-      <menu 
         name="selection-select-by-rectangle-view"
         text="Selection/Select_by_rectangle" 
         />
@@ -572,13 +559,40 @@
         />
 
       <tool-bar name="view_selection" position="6">
-        <selectable-tool name="selection-simple-select-view" />
         <selectable-tool name="selection-select-by-rectangle-view" />
         <selectable-tool name="selection-select-by-polygon" />
       </tool-bar>
 
     </extension>
     
+    
+    
+    <extension class-name="org.gvsig.app.extension.ViewSimpleSelectionControl"
+      description="Extensi�n encargada de gestionar la herramienta de selecci�n simple."
+      active="true"
+      priority="30">
+      <action 
+        name="selection-simple-select-view"
+        label="_Simple_select" 
+        position="300700000" 
+        action-command="selection-simple-select-view" 
+        icon="selection-simple-select"
+        tooltip="_Simple_select" 
+        accelerator=""
+        />
+
+      <menu 
+        name="selection-simple-select-view"
+        text="Selection/Simple" 
+        />
+
+      <tool-bar name="view_selection" position="6">
+        <selectable-tool name="selection-simple-select-view" />
+      </tool-bar>
+
+    </extension>    
+    
+    
     <extension class-name="org.gvsig.app.extension.ViewSelectionByTheme"
       description="Extensi�n encargada de la selecci�n por tema."
       active="true"
