[GRASS-SVN] r65023 - in grass/branches/releasebranch_7_0/gui/wxpython: gui_core lmgr

svn_grass at osgeo.org svn_grass at osgeo.org
Wed Apr 8 05:57:19 PDT 2015


Author: martinl
Date: 2015-04-08 05:57:19 -0700 (Wed, 08 Apr 2015)
New Revision: 65023

Modified:
   grass/branches/releasebranch_7_0/gui/wxpython/gui_core/dialogs.py
   grass/branches/releasebranch_7_0/gui/wxpython/gui_core/forms.py
   grass/branches/releasebranch_7_0/gui/wxpython/gui_core/widgets.py
   grass/branches/releasebranch_7_0/gui/wxpython/lmgr/giface.py
   grass/branches/releasebranch_7_0/gui/wxpython/lmgr/layertree.py
Log:
revert 64921:2
http://lists.osgeo.org/pipermail/grass-dev/2015-April/074699.html


Modified: grass/branches/releasebranch_7_0/gui/wxpython/gui_core/dialogs.py
===================================================================
--- grass/branches/releasebranch_7_0/gui/wxpython/gui_core/dialogs.py	2015-04-07 20:26:31 UTC (rev 65022)
+++ grass/branches/releasebranch_7_0/gui/wxpython/gui_core/dialogs.py	2015-04-08 12:57:19 UTC (rev 65023)
@@ -50,7 +50,7 @@
 from gui_core.gselect import LocationSelect, MapsetSelect, Select, \
                              OgrTypeSelect, GdalSelect, MapsetSelect, \
                              SubGroupSelect
-from gui_core.widgets import SingleSymbolPanel, GListCtrl, SimpleValidator, MapValidator
+from gui_core.widgets import SingleSymbolPanel, GListCtrl, SimpleValidator
 from core.utils import GetValidLayerName, _
 from core.settings import UserSettings, GetDisplayVectSettings
 from core.debug import Debug
@@ -199,7 +199,7 @@
         
         self.element = Select(parent = self.panel, id = wx.ID_ANY, size = globalvar.DIALOG_GSELECT_SIZE,
                               type = 'vector', layerTree = layerTree,
-                              validator = MapValidator())
+                              validator = SimpleValidator(callback = self.ValidatorCallback))
         self.element.SetFocus()
         
         self.warning = _("Name of vector map is missing.")

Modified: grass/branches/releasebranch_7_0/gui/wxpython/gui_core/forms.py
===================================================================
--- grass/branches/releasebranch_7_0/gui/wxpython/gui_core/forms.py	2015-04-07 20:26:31 UTC (rev 65022)
+++ grass/branches/releasebranch_7_0/gui/wxpython/gui_core/forms.py	2015-04-08 12:57:19 UTC (rev 65023)
@@ -1200,20 +1200,11 @@
                                 if maps_param and orig_elem == 'stds':
                                     element_dict = {'raster': 'strds', 'vector': 'stvds', 'raster_3d': 'str3ds'}
                                     elem = element_dict[type_param.get('default')]
-
-                        extraItems = None
-                        if self._giface:
-                            if hasattr(self._giface, "_model"):
-                                extraItems = {_('Graphical Modeler') : self._giface.GetLayerList(p.get('prompt'))}
-                            else:
-                                layers = self._giface.GetLayerList()
-                                if len(layers) > 0:
-                                    mapList = []
-                                    extraItems = {_('Map Display') : mapList}
-                                    for layer in layers:
-                                        if layer.type != p.get('prompt'):
-                                            continue
-                                        mapList.append(str(layer))
+                        
+                        if self._giface and hasattr(self._giface, "_model"):
+                            extraItems = {_('Graphical Modeler') : self._giface.GetLayerList(p.get('prompt'))}
+                        else:
+                            extraItems = None
                         selection = gselect.Select(parent = which_panel, id = wx.ID_ANY,
                                                    size = globalvar.DIALOG_GSELECT_SIZE,
                                                    type = elem, multiple = multiple, nmaps = len(p.get('key_desc', [])),

Modified: grass/branches/releasebranch_7_0/gui/wxpython/gui_core/widgets.py
===================================================================
--- grass/branches/releasebranch_7_0/gui/wxpython/gui_core/widgets.py	2015-04-07 20:26:31 UTC (rev 65022)
+++ grass/branches/releasebranch_7_0/gui/wxpython/gui_core/widgets.py	2015-04-08 12:57:19 UTC (rev 65023)
@@ -14,10 +14,6 @@
  - widgets::CoordinatesValidator
  - widgets::IntegerValidator
  - widgets::FloatValidator
- - widgets::MapValidator
- - widgets::NTCValidator
- - widgets::SimpleValidator
- - widgets::GenericValidator
  - widgets::GListCtrl
  - widgets::SearchModuleWidget
  - widgets::ManageSettingsWidget
@@ -60,8 +56,6 @@
 except ImportError:
     import wx.lib.customtreectrl as CT
 
-from grass.script import core as grass
-
 from grass.pydispatch.signal import Signal
 
 from core        import globalvar
@@ -722,22 +716,7 @@
         """
         return True # Prevent wxDialog from complaining.
 
-class MapValidator(GenericValidator):
-    """Validator for map name input
 
-    See G_legal_filename()
-    """
-    def __init__(self):
-        def _mapNameValidationFailed(ctrl):
-            message = _("Name <%(name)s> is not a valid name for GRASS map. "
-                        "Please use only ASCII characters excluding %(chars)s "
-                        "and space.") % {'name': ctrl.GetValue(), 'chars': '/"\'@,=*~'}
-            GError(message, caption=_("Invalid name"))
-        
-        GenericValidator.__init__(self,
-                                  grass.legal_name,
-                                  _mapNameValidationFailed)
-       
 class SingleSymbolPanel(wx.Panel):
     """Panel for displaying one symbol.
 

Modified: grass/branches/releasebranch_7_0/gui/wxpython/lmgr/giface.py
===================================================================
--- grass/branches/releasebranch_7_0/gui/wxpython/lmgr/giface.py	2015-04-07 20:26:31 UTC (rev 65022)
+++ grass/branches/releasebranch_7_0/gui/wxpython/lmgr/giface.py	2015-04-08 12:57:19 UTC (rev 65023)
@@ -47,16 +47,11 @@
     def __init__(self, tree):
         self._tree = tree
 
-    def __len__(self):
-        return len([layer for layer in self])
-        
     def __iter__(self):
         """Iterates over the contents of the list."""
-        item = self._tree.GetFirstChild(self._tree.root)[0]
-        while item and item.IsOk():
+        for item in self._tree.GetSelectedLayer(multi=True):
             yield Layer(self._tree.GetPyData(item))
-            item = self._tree.GetNextItem(item)
-        
+
     def __getitem__(self, index):
         """Select a layer from the LayerList using the index."""
         return [l for l in self][index]

Modified: grass/branches/releasebranch_7_0/gui/wxpython/lmgr/layertree.py
===================================================================
--- grass/branches/releasebranch_7_0/gui/wxpython/lmgr/layertree.py	2015-04-07 20:26:31 UTC (rev 65022)
+++ grass/branches/releasebranch_7_0/gui/wxpython/lmgr/layertree.py	2015-04-08 12:57:19 UTC (rev 65023)
@@ -45,7 +45,7 @@
 from core.gcmd            import GWarning, GError, RunCommand
 from icons.icon           import MetaIcon
 from web_services.dialogs import SaveWMSLayerDialog
-from gui_core.widgets import MapValidator
+from gui_core.widgets import GenericValidator
 from lmgr.giface import LayerManagerGrassInterfaceForMapDisplay
 from core.giface import Notification
 
@@ -783,6 +783,12 @@
         GUI(parent = self, centreOnParent = False).ParseCommand(['v.colors',
                                                                  'map=%s' % name])
         
+    def _mapNameValidationFailed(self, ctrl):
+        message = _("Name <%(name)s> is not a valid name for GRASS map. "
+                    "Please use only ASCII characters excluding %(chars)s "
+                    "and space.") % {'name': ctrl.GetValue(), 'chars': '/"\'@,=*~'}
+        GError(parent=self, message=message, caption=_("Invalid name"))
+
     def OnCopyMap(self, event):
         """Copy selected map into current mapset"""
         layer = self.GetSelectedLayer()
@@ -810,7 +816,7 @@
                               message = _('Enter name for the new %s in the current mapset:') % label.lower(),
                               caption = _('Make a copy of %s <%s>') % (label.lower(), lnameSrc),
                               defaultValue = lnameSrc.split('@')[0],
-                              validator = MapValidator(),
+                              validator = GenericValidator(grass.legal_name, self._mapNameValidationFailed),
                               size = (700, -1))
         if dlg.ShowModal() == wx.ID_OK:
             lnameDst = dlg.GetValue()



More information about the grass-commit mailing list