[GRASS-SVN] r54930 - grass/trunk/gui/wxpython/web_services
svn_grass at osgeo.org
svn_grass at osgeo.org
Tue Feb 5 06:20:08 PST 2013
Author: martinl
Date: 2013-02-05 06:20:07 -0800 (Tue, 05 Feb 2013)
New Revision: 54930
Modified:
grass/trunk/gui/wxpython/web_services/dialogs.py
grass/trunk/gui/wxpython/web_services/widgets.py
Log:
wxGUI/web services: fix default buttons
overwrite temp cap files
(patch provided by Stepan Turek)
Modified: grass/trunk/gui/wxpython/web_services/dialogs.py
===================================================================
--- grass/trunk/gui/wxpython/web_services/dialogs.py 2013-02-05 14:04:23 UTC (rev 54929)
+++ grass/trunk/gui/wxpython/web_services/dialogs.py 2013-02-05 14:20:07 UTC (rev 54930)
@@ -97,7 +97,6 @@
self.btn_connect = wx.Button(parent = self,
id = wx.ID_ANY, label = _("&Connect"))
self.btn_connect.SetToolTipString(_("Connect to the server"))
- self.btn_connect.SetDefault()
if not self.server.GetValue():
self.btn_connect.Enable(False)
@@ -367,8 +366,6 @@
password = self.password.GetValue())
self.ws_panels[ws]['panel'].Hide()
- self.btn_add.SetDefault()
-
def OnPanelCapParsed(self, event):
"""!Called when panel has downloaded and parsed capabilities file.
"""
@@ -381,14 +378,25 @@
self.Layout()
self.Fit()
+ def _getConnectedWS(self):
+ """
+ @return list of found web services on server (identified as keys in self.ws_panels)
+ """
+ conn_ws = []
+ for ws, data in self.ws_panels.iteritems():
+ if data['panel'].IsConnected():
+ conn_ws.append(ws)
+
+ return conn_ws
+
def UpdateDialogAfterConnection(self):
"""!Update dialog after all web service panels downloaded and parsed capabilities data.
"""
- avail_ws = {}
- for ws, data in self.ws_panels.iteritems():
+ avail_ws = {}
+ conn_ws = self._getConnectedWS()
- if data['panel'].IsConnected():
- avail_ws[ws] = data
+ for ws in conn_ws:
+ avail_ws[ws] = self.ws_panels[ws]
self.web_service_sel = []
self.rb_choices = []
@@ -466,6 +474,7 @@
self.SetTitle(_("Add web service layer"))
self.gmframe = gmframe
+ self.btn_connect.SetDefault()
def _createWidgets(self):
@@ -488,6 +497,16 @@
# bindings
self.btn_add.Bind(wx.EVT_BUTTON, self.OnAddLayer)
+ def UpdateDialogAfterConnection(self):
+ """!Connect to the server
+ """
+ WSDialogBase.UpdateDialogAfterConnection(self)
+
+ if self._getConnectedWS():
+ self.btn_add.SetDefault()
+ else:
+ self.btn_connect.SetDefault()
+
def OnAddLayer(self, event):
"""!Add web service layer.
"""
@@ -569,6 +588,7 @@
self._setRevertCapFiles(ws_cap_files)
self.LoadCapFiles(ws_cap_files = self.revert_ws_cap_files, cmd = cmd)
+ self.btn_ok.SetDefault()
def __del__(self):
for f in self.revert_ws_cap_files.itervalues():
@@ -593,10 +613,10 @@
self.btn_apply.Enable(False)
self.run_btns.append(self.btn_apply)
- self.btn_save = wx.Button(parent = self, id = wx.ID_ANY, label = _("&Save"))
- self.btn_save.SetToolTipString(_("Revert changes"))
- self.btn_save.Enable(False)
- self.run_btns.append(self.btn_save)
+ self.btn_ok = wx.Button(parent = self, id = wx.ID_ANY, label = _("&OK"))
+ self.btn_ok.SetToolTipString(_("Apply changes and close dialog"))
+ self.btn_ok.Enable(False)
+ self.run_btns.append(self.btn_ok)
def _doLayout(self):
@@ -606,13 +626,13 @@
flag = wx.ALL | wx.ALIGN_CENTER,
border = 10)
- self.btnsizer.Add(item = self.btn_save, proportion = 0,
+ self.btnsizer.Add(item = self.btn_ok, proportion = 0,
flag = wx.ALL | wx.ALIGN_CENTER,
border = 10)
# bindings
self.btn_apply.Bind(wx.EVT_BUTTON, self.OnApply)
- self.btn_save.Bind(wx.EVT_BUTTON, self.OnSave)
+ self.btn_ok.Bind(wx.EVT_BUTTON, self.OnSave)
def LoadCapFiles(self, ws_cap_files, cmd):
"""!Parse cap files and update dialog.
@@ -678,6 +698,15 @@
event = gUpdateMap()
wx.PostEvent(display, event)
+ def UpdateDialogAfterConnection(self):
+ """!Connect to the server
+ """
+ WSDialogBase.UpdateDialogAfterConnection(self)
+ if self._getConnectedWS():
+ self.btn_ok.SetDefault()
+ else:
+ self.btn_connect.SetDefault()
+
def OnApply(self, event):
self._apply()
@@ -775,8 +804,8 @@
self.btn_close = wx.Button(parent = self, id = wx.ID_CLOSE)
self.btn_close.SetToolTipString(_("Close dialog"))
- self.btn_save = wx.Button(parent = self, id = wx.ID_ANY, label = _("&Save layer"))
- self.btn_save.SetToolTipString(_("Add web service layer"))
+ self.btn_ok = wx.Button(parent = self, id = wx.ID_ANY, label = _("&Save layer"))
+ self.btn_ok.SetToolTipString(_("Add web service layer"))
# statusbar
self.statusbar = wx.StatusBar(parent = self, id = wx.ID_ANY)
@@ -817,7 +846,7 @@
flag = wx.ALL | wx.ALIGN_CENTER,
border = 10)
- self.btnsizer.Add(item = self.btn_save, proportion = 0,
+ self.btnsizer.Add(item = self.btn_ok, proportion = 0,
flag = wx.ALL | wx.ALIGN_CENTER,
border = 10)
@@ -835,7 +864,7 @@
# bindings
self.btn_close.Bind(wx.EVT_BUTTON, self.OnClose)
- self.btn_save.Bind(wx.EVT_BUTTON, self.OnSave)
+ self.btn_ok.Bind(wx.EVT_BUTTON, self.OnSave)
self.Bind(EVT_CMD_DONE, self.OnCmdDone)
self.Bind(EVT_CMD_OUTPUT, self.OnCmdOutput)
Modified: grass/trunk/gui/wxpython/web_services/widgets.py
===================================================================
--- grass/trunk/gui/wxpython/web_services/widgets.py 2013-02-05 14:04:23 UTC (rev 54929)
+++ grass/trunk/gui/wxpython/web_services/widgets.py 2013-02-05 14:20:07 UTC (rev 54930)
@@ -35,8 +35,8 @@
from core import globalvar
from core.debug import Debug
-from core.gcmd import GWarning, GMessage
-from core.gconsole import CmdThread, EVT_CMD_DONE
+from core.gcmd import GWarning, GMessage, GError
+from core.gconsole import CmdThread, GStderr, EVT_CMD_DONE, EVT_CMD_OUTPUT
from web_services.cap_interface import WMSCapabilities, WMTSCapabilities, OnEarthCapabilities
@@ -107,6 +107,7 @@
}
}
+ self.cmdStdErr = GStderr(self)
self.cmd_thread = CmdThread(self)
self.cap_file = grass.tempfile()
@@ -119,6 +120,7 @@
self._layout()
self.Bind(EVT_CMD_DONE, self.OnCapDownloadDone)
+ self.Bind(EVT_CMD_OUTPUT, self.OnCmdOutput)
def __del__(self):
self.cmd_thread.abort(abortall =True)
@@ -417,11 +419,19 @@
@param password - password for connection
"""
self._prepareForNewConn(url, username, password)
- cap_cmd = ['r.in.wms', '-c', ('capfile_output=%s' % self.cap_file)] + self.ws_cmdl
+ cap_cmd = ['r.in.wms', '-c', ('capfile_output=%s' % self.cap_file), '--overwrite'] + self.ws_cmdl
self.currentPid = self.cmd_thread.GetId()
- self.cmd_thread.RunCmd(cap_cmd)
+ self.cmd_thread.RunCmd(cap_cmd, stderr = self.cmdStdErr)
+ def OnCmdOutput(self, event):
+ """!Print cmd output according to debug level.
+
+ @todo Replace with error dialog
+ """
+ if Debug.GetLevel() != 0:
+ Debug.msg(1, event.text)
+
def _prepareForNewConn(self, url, username, password):
"""!Prepare panel for new connection
"""
More information about the grass-commit
mailing list