[GRASS-SVN] r59316 - grass/trunk/gui/wxpython/web_services

svn_grass at osgeo.org svn_grass at osgeo.org
Mon Mar 24 12:36:41 PDT 2014


Author: turek
Date: 2014-03-24 12:36:37 -0700 (Mon, 24 Mar 2014)
New Revision: 59316

Modified:
   grass/trunk/gui/wxpython/web_services/dialogs.py
   grass/trunk/gui/wxpython/web_services/widgets.py
Log:
wms fill layer name if it is empty according to selected item

Modified: grass/trunk/gui/wxpython/web_services/dialogs.py
===================================================================
--- grass/trunk/gui/wxpython/web_services/dialogs.py	2014-03-24 18:22:51 UTC (rev 59315)
+++ grass/trunk/gui/wxpython/web_services/dialogs.py	2014-03-24 19:36:37 UTC (rev 59316)
@@ -125,6 +125,7 @@
             self.ws_panels[ws]['panel'] =  WSPanel(parent = self.reqDataPanel,
                                                    web_service = ws)
             self.ws_panels[ws]['panel'].capParsed.connect(self.OnPanelCapParsed)
+            self.ws_panels[ws]['panel'].layerSelected.connect(self.OnLayerSelected)
 
         # buttons
         self.btn_close = wx.Button(parent = self, id = wx.ID_CLOSE)
@@ -145,6 +146,11 @@
         self.settsManager.settingsLoaded.connect(self.OnSettingsLoaded)
         self.settsManager.settingsSaving.connect(self.OnSettingsSaving)
 
+    def OnLayerSelected(self, title):
+
+        if not self.layerName.GetValue().strip():
+            self.layerName.SetValue(title)
+
     def _doLayout(self):
 
         dialogSizer = wx.BoxSizer(wx.VERTICAL)
@@ -331,6 +337,7 @@
         """!Update layer name to web service panel
         """
         lname = event.GetString()
+        lname = lname.encode('ascii', 'replace')
 
         for v in self.ws_panels.itervalues():
             v['panel'].SetOutputLayerName(lname.strip())
@@ -541,7 +548,8 @@
             shutil.copyfile(cap_file, cmd_cap_file)
             lcmd.append('capfile=' + cmd_cap_file)
 
-        layer = ltree.AddLayer(ltype = 'wms', lname = self.layerName.GetValue(), 
+        layer = ltree.AddLayer(ltype = 'wms',
+                               lname = self.active_ws_panel.GetOutputLayerName(), 
                                lchecked = True, lcmd = lcmd)
 
 

Modified: grass/trunk/gui/wxpython/web_services/widgets.py
===================================================================
--- grass/trunk/gui/wxpython/web_services/widgets.py	2014-03-24 18:22:51 UTC (rev 59315)
+++ grass/trunk/gui/wxpython/web_services/widgets.py	2014-03-24 19:36:37 UTC (rev 59316)
@@ -125,6 +125,8 @@
 
         self._layout()
 
+        self.layerSelected = self.list.layerSelected
+
         self.Bind(EVT_CMD_DONE, self.OnCapDownloadDone)
         self.Bind(EVT_CMD_OUTPUT, self.OnCmdOutput)
 
@@ -819,6 +821,9 @@
         """
         self.o_layer_name = name
 
+    def GetOutputLayerName(self):
+        return self.o_layer_name
+
     def GetCapFile(self):
         """!Get path to file where capabilities are saved
         """
@@ -852,6 +857,8 @@
         self.root = None
         self.Bind(wx.EVT_TREE_SEL_CHANGING, self.OnListSelChanging)
 
+        self.layerSelected = Signal('LayersList.layerSelected')
+
     def LoadData(self, cap = None):
         """!Load data into list
         """
@@ -950,6 +957,9 @@
     def OnListSelChanging(self, event):
         """!Do not allow to select items, which cannot be requested from server.
         """
+        def _emitSelected(layer):
+            title = layer.GetLayerData('title')
+            self.layerSelected.emit(title = title)
 
         def _selectRequestableChildren(item, list_to_check, items_to_sel):
 
@@ -971,6 +981,8 @@
             if not self.HasFlag(wx.TR_MULTIPLE):
                 return
 
+            _emitSelected(self.GetPyData(cur_item)['layer'])
+
             items_to_chck = []
             items_to_sel = []
             chck_item = cur_item
@@ -984,7 +996,9 @@
 
             while items_to_sel:
                 self.SelectItem(items_to_sel.pop(), unselect_others=False)
-
+        else:
+            _emitSelected(self.GetPyData(cur_item)['layer'])
+          
     def GetItemCount(self):
         """!Required for listmix.ListCtrlAutoWidthMixin
         """



More information about the grass-commit mailing list