[GRASS-SVN] r64922 - in grass/branches/releasebranch_7_0/gui/wxpython: gui_core lmgr
svn_grass at osgeo.org
svn_grass at osgeo.org
Wed Mar 25 13:30:45 PDT 2015
Author: martinl
Date: 2015-03-25 13:30:45 -0700 (Wed, 25 Mar 2015)
New Revision: 64922
Modified:
grass/branches/releasebranch_7_0/gui/wxpython/gui_core/dialogs.py
grass/branches/releasebranch_7_0/gui/wxpython/gui_core/widgets.py
grass/branches/releasebranch_7_0/gui/wxpython/lmgr/layertree.py
Log:
wxGUI: implement MapValidator
update NewVectorDialog and OnCopyMap to use this validator
(merge r64876 from trunk)
Modified: grass/branches/releasebranch_7_0/gui/wxpython/gui_core/dialogs.py
===================================================================
--- grass/branches/releasebranch_7_0/gui/wxpython/gui_core/dialogs.py 2015-03-25 20:26:02 UTC (rev 64921)
+++ grass/branches/releasebranch_7_0/gui/wxpython/gui_core/dialogs.py 2015-03-25 20:30:45 UTC (rev 64922)
@@ -50,7 +50,7 @@
from gui_core.gselect import LocationSelect, MapsetSelect, Select, \
OgrTypeSelect, GdalSelect, MapsetSelect, \
SubGroupSelect
-from gui_core.widgets import SingleSymbolPanel, GListCtrl, SimpleValidator
+from gui_core.widgets import SingleSymbolPanel, GListCtrl, SimpleValidator, MapValidator
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 = SimpleValidator(callback = self.ValidatorCallback))
+ validator = MapValidator())
self.element.SetFocus()
self.warning = _("Name of vector map is missing.")
Modified: grass/branches/releasebranch_7_0/gui/wxpython/gui_core/widgets.py
===================================================================
--- grass/branches/releasebranch_7_0/gui/wxpython/gui_core/widgets.py 2015-03-25 20:26:02 UTC (rev 64921)
+++ grass/branches/releasebranch_7_0/gui/wxpython/gui_core/widgets.py 2015-03-25 20:30:45 UTC (rev 64922)
@@ -14,6 +14,10 @@
- widgets::CoordinatesValidator
- widgets::IntegerValidator
- widgets::FloatValidator
+ - widgets::MapValidator
+ - widgets::NTCValidator
+ - widgets::SimpleValidator
+ - widgets::GenericValidator
- widgets::GListCtrl
- widgets::SearchModuleWidget
- widgets::ManageSettingsWidget
@@ -56,6 +60,8 @@
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
@@ -716,7 +722,22 @@
"""
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/layertree.py
===================================================================
--- grass/branches/releasebranch_7_0/gui/wxpython/lmgr/layertree.py 2015-03-25 20:26:02 UTC (rev 64921)
+++ grass/branches/releasebranch_7_0/gui/wxpython/lmgr/layertree.py 2015-03-25 20:30:45 UTC (rev 64922)
@@ -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 GenericValidator
+from gui_core.widgets import MapValidator
from lmgr.giface import LayerManagerGrassInterfaceForMapDisplay
from core.giface import Notification
@@ -783,12 +783,6 @@
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()
@@ -816,7 +810,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 = GenericValidator(grass.legal_name, self._mapNameValidationFailed),
+ validator = MapValidator(),
size = (700, -1))
if dlg.ShowModal() == wx.ID_OK:
lnameDst = dlg.GetValue()
More information about the grass-commit
mailing list