[GRASS-SVN] r59325 - in grass/trunk/gui/wxpython: gui_core web_services

svn_grass at osgeo.org svn_grass at osgeo.org
Tue Mar 25 06:05:39 PDT 2014


Author: turek
Date: 2014-03-25 06:05:29 -0700 (Tue, 25 Mar 2014)
New Revision: 59325

Modified:
   grass/trunk/gui/wxpython/gui_core/widgets.py
   grass/trunk/gui/wxpython/web_services/dialogs.py
   grass/trunk/gui/wxpython/web_services/widgets.py
Log:
wms: add default servers button added

Modified: grass/trunk/gui/wxpython/gui_core/widgets.py
===================================================================
--- grass/trunk/gui/wxpython/gui_core/widgets.py	2014-03-25 11:51:22 UTC (rev 59324)
+++ grass/trunk/gui/wxpython/gui_core/widgets.py	2014-03-25 13:05:29 UTC (rev 59325)
@@ -1005,27 +1005,27 @@
 
         self._layout()
 
+        self.SetSizer(self.settingsSizer)
+        self.settingsSizer.Fit(self)
+
     def _layout(self):
 
-        settingsSizer = wx.StaticBoxSizer(self.settingsBox, wx.HORIZONTAL)
-        settingsSizer.Add(item = wx.StaticText(parent = self,
+        self.settingsSizer = wx.StaticBoxSizer(self.settingsBox, wx.HORIZONTAL)
+        self.settingsSizer.Add(item = wx.StaticText(parent = self,
                                                id = wx.ID_ANY,
                                                label = _("Load settings:")),
                           flag = wx.ALIGN_CENTER_VERTICAL | wx.RIGHT,
                           border  = 5)
-        settingsSizer.Add(item = self.settingsChoice,
+        self.settingsSizer.Add(item = self.settingsChoice,
                           proportion = 1,
                           flag = wx.EXPAND)
-        settingsSizer.Add(item = self.btnSettingsSave,
+        self.settingsSizer.Add(item = self.btnSettingsSave,
                           flag = wx.LEFT | wx.RIGHT,
                           border = 5)
-        settingsSizer.Add(item = self.btnSettingsDel,
+        self.settingsSizer.Add(item = self.btnSettingsDel,
                           flag = wx.RIGHT,
                           border = 5)
 
-        self.SetSizer(settingsSizer)
-        settingsSizer.Fit(self)
-
     def OnSettingsChanged(self, event):
         """!Load named settings"""
         name = event.GetString()
@@ -1037,6 +1037,10 @@
         data = self._settings[name]
         self.settingsChanged.emit(data=data)
 
+    def GetSettings(self):
+        """!Load named settings"""
+        return self._settings.copy()
+       
     def OnSettingsSave(self, event):
         """!Save settings"""
         dlg = wx.TextEntryDialog(parent = self,
@@ -1090,6 +1094,14 @@
         self._settings = settings
         self._saveSettings()
 
+    def AddSettings(self, settings):
+        """!Add settings
+
+        @param settings - dict with all settigs {nameofsetting : settingdata, ....}
+        """
+        self._settings = dict(self._settings.items() + settings.items())
+        self._saveSettings()
+
     def OnSettingsDelete(self, event):
         """!Save settings
         """

Modified: grass/trunk/gui/wxpython/web_services/dialogs.py
===================================================================
--- grass/trunk/gui/wxpython/web_services/dialogs.py	2014-03-25 11:51:22 UTC (rev 59324)
+++ grass/trunk/gui/wxpython/web_services/dialogs.py	2014-03-25 13:05:29 UTC (rev 59325)
@@ -35,9 +35,8 @@
 from core.gconsole    import CmdThread, GStderr, EVT_CMD_DONE, EVT_CMD_OUTPUT
 
 from gui_core.gselect import Select
-from gui_core.widgets import ManageSettingsWidget
 
-from web_services.widgets import WSPanel
+from web_services.widgets import WSPanel, WSManageSettingsWidget
 
 class WSDialogBase(wx.Dialog):
     """!Base class for web service dialogs. 
@@ -82,8 +81,9 @@
 
         settingsFile = os.path.join(GetSettingsPath(), 'wxWS')
 
-        self.settsManager = ManageSettingsWidget(parent=self,
-                                                 settingsFile=settingsFile)
+        self.settsManager = WSManageSettingsWidget(parent=self,
+                                                 settingsFile=settingsFile,
+                                                 default_servers=self.default_servers)
 
         self.settingsBox = wx.StaticBox(parent = self, 
                                         id = wx.ID_ANY,
@@ -143,7 +143,6 @@
         self.layerName.Bind(wx.EVT_TEXT, self.OnOutputLayerName)
 
         self.settsManager.settingsChanged.connect(self.OnSettingsChanged)
-        self.settsManager.settingsLoaded.connect(self.OnSettingsLoaded)
         self.settsManager.settingsSaving.connect(self.OnSettingsSaving)
 
     def OnLayerSelected(self, title):
@@ -303,12 +302,6 @@
         else:
             self.adv_conn.Collapse(True)
 
-    def OnSettingsLoaded(self, settings):
-        """!If settings are empty set default servers
-        """
-        if not settings:
-            self.settsManager.SetSettings(self.default_servers)
-
     def OnClose(self, event):
         """!Close the dialog
         """

Modified: grass/trunk/gui/wxpython/web_services/widgets.py
===================================================================
--- grass/trunk/gui/wxpython/web_services/widgets.py	2014-03-25 11:51:22 UTC (rev 59324)
+++ grass/trunk/gui/wxpython/web_services/widgets.py	2014-03-25 13:05:29 UTC (rev 59325)
@@ -42,6 +42,7 @@
 from web_services.cap_interface import WMSCapabilities, WMTSCapabilities, OnEarthCapabilities
 
 from gui_core.widgets  import GNotebook
+from gui_core.widgets import ManageSettingsWidget
 
 import grass.script as grass
 
@@ -1066,3 +1067,31 @@
             l_st_list.remove(l_st)
 
         return l_st_list
+
+class WSManageSettingsWidget(ManageSettingsWidget):
+    def __init__(self, parent, settingsFile, default_servers):
+
+        ManageSettingsWidget.__init__(self, parent, settingsFile)
+        self.default_servers = default_servers
+
+    def _layout(self):
+
+        self.btnAddDefaultServers = wx.Button(parent=self, id=wx.ID_ANY,
+                                             label=_("Add default servers"))
+        self.btnAddDefaultServers.Bind(wx.EVT_BUTTON, self.OnAddDefaultServers)
+        
+        ManageSettingsWidget._layout(self)
+        self.settingsSizer.Add(item=self.btnAddDefaultServers,
+                               flag=wx.RIGHT,
+                               border=5)
+
+    def OnAddDefaultServers(self, event):
+
+        setts = self.GetSettings()
+        self.servers_to_add = {}
+        for k, v in self.default_servers.iteritems():
+            if k not in setts.iterkeys():
+                self.servers_to_add[k] = v
+
+        if self.servers_to_add:
+            self.AddSettings(self.servers_to_add)



More information about the grass-commit mailing list