Browse Source

wxGUI: print warning when map is not found

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@44728 15284696-431f-4ddb-bdfa-cd5b030d7da7
Martin Landa 14 years ago
parent
commit
864585ff42
2 changed files with 18 additions and 14 deletions
  1. 15 9
      gui/wxpython/gui_modules/layertree.py
  2. 3 5
      gui/wxpython/gui_modules/utils.py

+ 15 - 9
gui/wxpython/gui_modules/layertree.py

@@ -47,7 +47,7 @@ from debug import Debug as Debug
 from icon import Icons as Icons
 from icon import Icons as Icons
 from preferences import globalSettings as UserSettings
 from preferences import globalSettings as UserSettings
 from vdigit import haveVDigit
 from vdigit import haveVDigit
-from gcmd import GError
+from gcmd import GWarning
 try:
 try:
     import subprocess
     import subprocess
 except:
 except:
@@ -1328,13 +1328,19 @@ class LayerTree(treemixin.DragAndDrop, CT.CustomTreeCtrl):
         # set layer text to map name
         # set layer text to map name
         if dcmd:
         if dcmd:
             self.GetPyData(layer)[0]['cmd'] = dcmd
             self.GetPyData(layer)[0]['cmd'] = dcmd
-            mapname = self._getLayerName(layer)
-            if not mapname:
-                GError(parent = self,
-                       message = _("Map <%s> not found.") % utils.GetLayerNameFromCmd(dcmd))
+            mapText  = self._getLayerName(layer)
+            mapName  = utils.GetLayerNameFromCmd(dcmd)
+            mapLayer = self.GetPyData(layer)[0]['maplayer']
+            self.SetItemText(layer, mapName)
+            
+            if not mapText or \
+                    (mapLayer and \
+                         not grass.find_file(name = mapName, element = mapLayer.GetType())['fullname']):
+                propwin.Hide()
+                GWarning(parent = self,
+                         message = _("Map <%s> not found.") % mapName)
                 return
                 return
-            self.SetItemText(layer, mapname)
-        
+            
         # update layer data
         # update layer data
         if params:
         if params:
             self.SetPyData(layer, (self.GetPyData(layer)[0], params))
             self.SetPyData(layer, (self.GetPyData(layer)[0], params))
@@ -1350,9 +1356,9 @@ class LayerTree(treemixin.DragAndDrop, CT.CustomTreeCtrl):
                 render = UserSettings.Get(group = 'display', key = 'autoRendering', subkey = 'enabled')
                 render = UserSettings.Get(group = 'display', key = 'autoRendering', subkey = 'enabled')
                 self.mapdisplay.MapWindow.ZoomToMap(layers = [mapLayer,],
                 self.mapdisplay.MapWindow.ZoomToMap(layers = [mapLayer,],
                                                     render = render)
                                                     render = render)
-        
+
+        # update nviz session        
         if self.mapdisplay.toolbars['nviz'] and dcmd:
         if self.mapdisplay.toolbars['nviz'] and dcmd:
-            # update nviz session
             mapLayer = self.GetPyData(layer)[0]['maplayer']
             mapLayer = self.GetPyData(layer)[0]['maplayer']
             mapWin = self.mapdisplay.MapWindow
             mapWin = self.mapdisplay.MapWindow
             if len(mapLayer.GetCmd()) > 0:
             if len(mapLayer.GetCmd()) > 0:

+ 3 - 5
gui/wxpython/gui_modules/utils.py

@@ -75,7 +75,7 @@ def GetTempfile(pref=None):
 def GetLayerNameFromCmd(dcmd, fullyQualified = False, param = None,
 def GetLayerNameFromCmd(dcmd, fullyQualified = False, param = None,
                         layerType = None):
                         layerType = None):
     """!Get map name from GRASS command
     """!Get map name from GRASS command
-
+    
     @param dcmd GRASS command (given as list)
     @param dcmd GRASS command (given as list)
     @param fullyQualified change map name to be fully qualified
     @param fullyQualified change map name to be fully qualified
     @param force parameter otherwise 'input'/'map'
     @param force parameter otherwise 'input'/'map'
@@ -131,12 +131,10 @@ def GetLayerNameFromCmd(dcmd, fullyQualified = False, param = None,
                         findType = 'cell'
                         findType = 'cell'
                     else:
                     else:
                         findType = layerType
                         findType = layerType
-                    result = grass.find_file(mapname, element=findType)
+                    mapset = grass.find_file(mapname, element=findType)['mapset']
                 except AttributeError, e: # not found
                 except AttributeError, e: # not found
                     return ''
                     return ''
-                if result:
-                    mapset = result['mapset']
-                else:
+                if not mapset:
                     mapset = grass.gisenv()['MAPSET']
                     mapset = grass.gisenv()['MAPSET']
             else:
             else:
                 mapset = grass.gisenv()['MAPSET']
                 mapset = grass.gisenv()['MAPSET']