[GRASS-SVN] r47498 - grass-addons/grass7/gui/wxpython/wx.wms
svn_grass at osgeo.org
svn_grass at osgeo.org
Mon Aug 8 14:50:17 EDT 2011
Author: sudeepsingh
Date: 2011-08-08 11:50:17 -0700 (Mon, 08 Aug 2011)
New Revision: 47498
Modified:
grass-addons/grass7/gui/wxpython/wx.wms/TODO
grass-addons/grass7/gui/wxpython/wx.wms/addserver.py
grass-addons/grass7/gui/wxpython/wx.wms/wmsmenu.py
Log:
Dialog popups added
Modified: grass-addons/grass7/gui/wxpython/wx.wms/TODO
===================================================================
--- grass-addons/grass7/gui/wxpython/wx.wms/TODO 2011-08-08 13:49:42 UTC (rev 47497)
+++ grass-addons/grass7/gui/wxpython/wx.wms/TODO 2011-08-08 18:50:17 UTC (rev 47498)
@@ -56,23 +56,23 @@
AddServer dialog:
* TODO: Dialog layout doesn't re-size well; Text doesn't fit.
*[done] Quit button quits application and not just closes server editing dialog.
-* Save button should save edits to current server and not create a new
+*[done] Save button should save edits to current server and not create a new
one; "Save as a new" should create a new entry.
-* TODO: check for name duplication before adding a new server to avoid
+*[done] TODO: check for name duplication before adding a new server to avoid
existence of server entries with identical names. That would break
current XML too, as common name is used as ID. ID should be something
more generic. UUID?
*[done] Only server name and URL should be mandatory
-* TODO: StatusBar should provide real info on application state:
+* [done] TODO: StatusBar should provide real info on application state:
editing existing entry; creating a new one; saved successfully; save
failed + popup with error message etc.
-* If a new server is saved successfully, preselect it in servers drop-down list.
+*[Need help] If a new server is saved successfully, preselect it in servers drop-down list.
*[done] Failure to save server list should not wipe existing server list.
This is important! Use copy on success trick (save to temporary file;
in case of success, copy temporary file over original one).
*[done] All fields should accept non-ascii characters.
* TODO: validate user provided URL by doing getCapabilities request.[Can it be validated ?, sometimes a server might be down, so instead we leave it at user to decide if he gives a valid url, as in case he gives something like www.google.com or any other website, the application can handle the wrong responses recieved]
-*[Need help in this, could not figure out the function to preselect something] When server is removed, it should switch dropdown server list to
+*[Need help ] When server is removed, it should switch dropdown server list to
other entry to indicate it's removal.
wmsmenu:
Modified: grass-addons/grass7/gui/wxpython/wx.wms/addserver.py
===================================================================
--- grass-addons/grass7/gui/wxpython/wx.wms/addserver.py 2011-08-08 13:49:42 UTC (rev 47497)
+++ grass-addons/grass7/gui/wxpython/wx.wms/addserver.py 2011-08-08 18:50:17 UTC (rev 47498)
@@ -200,9 +200,11 @@
if(self.selectedServer is not None):
if(not self.selectedServer.servername == newServerName):
if(self.valueExists(self.servers, newServerName)):
- StatusBar_fields = ["ServerName already exists. Please enter a differnet ServerName"]
+ message = "ServerName already exists. Please enter a different ServerName"
+ self.ShowMessage(message, 'Warning')
+ StatusBar_fields = [message]
self.StatusBar.SetStatusText(StatusBar_fields[0], 0)
- print 'Please Enter a different Servername'
+ print message
return
#del self.servers[self.selectedUid]
serverData.servername = newServerName
@@ -226,9 +228,11 @@
self.StatusBar.SetStatusText(StatusBar_fields[0], 0)
Publisher().sendMessage(("update.serverList"), msg)
else:
- StatusBar_fields = ["Update not Successful"]
+ message = "Update not Successful"
+ self.ShowMessage(message, 'Warning')
+ StatusBar_fields = [message]
self.StatusBar.SetStatusText(StatusBar_fields[0], 0)
- print 'update save not successful'
+ print message
else:
uid = str(uuid.uuid4())
@@ -245,9 +249,13 @@
self.StatusBar.SetStatusText(StatusBar_fields[0], 0)
Publisher().sendMessage(("update.serverList"), msg)
else:
- StatusBar_fields = ["Save not Successful"]
+ message = "Save not successful"
+ self.ShowMessage(message, 'Warning')
+ StatusBar_fields = [message]
self.StatusBar.SetStatusText(StatusBar_fields[0], 0)
- print "False returned by addServerInfo, save not successful"
+ print message
+
+
'''
f = open('serverList.txt','a')
f.write(newServerName+" "+newUrl+ " "+newUserName+" "+newPassword+"\n")
@@ -259,9 +267,13 @@
self.__update_URL_List()
#Update_Url_List(newServerName+" "+newUrl)
else:
- StatusBar_fields = ["Please Fill servername and url fields"]
+ message = "Please fill servername and url fields"
+ self.ShowMessage(message, 'Warning')
+ StatusBar_fields = [message]
self.StatusBar.SetStatusText(StatusBar_fields[0], 0)
- print "Please Fill servername and url fields"
+ print message
+
+
self.editOn = False
if(event):
event.Skip()
@@ -269,9 +281,11 @@
def OnRemove(self, event): # wxGlade: ServerAdd.<event_handler>
print '-------------------------------------------------------------------> OnRemove'
if(self.selectedUid == None):
- StatusBar_fields = ["No Server selected....Remove Unsuccessful"]
+ message = "No Server selected....Remove Unsuccessful"
+ self.ShowMessage(message, 'Warning')
+ StatusBar_fields = [message]
self.StatusBar.SetStatusText(StatusBar_fields[0], 0)
- print 'No Uid is selected....Remove Unsuccessful'
+ print message
return
else:
if(removeServerInfo(self.soup, self.selectedUid)):
@@ -282,9 +296,11 @@
if(len(self.servers) > 0):
self.ServerList.SetSelection(0)
else:
- StatusBar_fields = ["Remove Unsuccessful"]
+ message = "Remove Unsuccessful"
+ self.ShowMessage(message, 'Warning')
+ StatusBar_fields = [message]
self.StatusBar.SetStatusText(StatusBar_fields[0], 0)
- print 'remove unsuccessful'
+ print message
return
#print self.servers
@@ -371,6 +387,9 @@
#wxGlade methods ends
#Sudeeps methods start
+ def ShowMessage(self, message, type = 'Warning'):
+ wx.MessageBox(message, type)
+
def __populate_URL_List(self, ComboBox):
self.servers, self.map_servernameTouid = getAllRows(self.soup)
for key, value in self.servers.items():
@@ -408,38 +427,48 @@
def allFieldsValid(self, newServerName, newUrl, newUserName, newPassword):
if(newServerName.count(self.name_url_delimiter)>0):
- StatusBar_fields = ["Warning: UserName cannot consist of "+self.name_url_delimiter]
+ message = "Warning: UserName cannot consist of "+self.name_url_delimiter
+ StatusBar_fields = [message]
self.StatusBar.SetStatusText(StatusBar_fields[0], 0)
+ self.ShowMessage(message, 'Warning')
print "Warning: UserName cannot consist of "+self.name_url_delimiter
print "Please give another username, save failed..."
return False
if(newUrl.count(self.name_url_delimiter)>0):
+ message = "Warning: URL cannot consist of "+self.name_url_delimiter
StatusBar_fields = ["Warning: URL Delimiter conflict. Edit config file"]
self.StatusBar.SetStatusText(StatusBar_fields[0], 0)
+ self.ShowMessage(message, 'Warning')
print "Warning: URL cannot consist of "+self.name_url_delimiter
print "Change in config file required to use different character as delimeter which doesnot appears in url"
return False
character = '>'
if(newServerName.count(character) > 0 or newUrl.count(character) > 0 or newUserName.count(character) > 0 or newPassword.count(character) > 0):
- StatusBar_fields = [character+' is not allowed in a Field']
+ message = character+' is not allowed in a Field'
+ self.ShowMessage(message, 'Warning')
+ StatusBar_fields = [message]
self.StatusBar.SetStatusText(StatusBar_fields[0], 0)
- print character+' is not allowed in a Field'
+ print message
return False
character = '<'
if(newServerName.count(character) > 0 or newUrl.count(character) > 0 or newUserName.count(character) > 0 or newPassword.count(character) > 0):
- StatusBar_fields = [character+' is not allowed in a Field']
+ message = character+' is not allowed in a Field'
+ self.ShowMessage(message, 'Warning')
+ StatusBar_fields = [message]
self.StatusBar.SetStatusText(StatusBar_fields[0], 0)
- print character+' is not allowed in a Field'
+ print message
return False
character = '&'
if(newServerName.count(character) > 0 or newUrl.count(character) > 0 or newUserName.count(character) > 0 or newPassword.count(character) > 0):
- StatusBar_fields = [character+' is not allowed in a Field']
+ message = character+' is not allowed in a Field'
+ self.ShowMessage(message, 'Warning')
+ StatusBar_fields = [message]
self.StatusBar.SetStatusText(StatusBar_fields[0], 0)
- print character+' is not allowed in a Field'
+ print message
return False
return True
Modified: grass-addons/grass7/gui/wxpython/wx.wms/wmsmenu.py
===================================================================
--- grass-addons/grass7/gui/wxpython/wx.wms/wmsmenu.py 2011-08-08 13:49:42 UTC (rev 47497)
+++ grass-addons/grass7/gui/wxpython/wx.wms/wmsmenu.py 2011-08-08 18:50:17 UTC (rev 47498)
@@ -147,7 +147,11 @@
def OnGetCapabilities(self, event): # wxGlade: wmsFrame.<event_handler>
if(self.selectedURL == "No server selected"):
- print 'no url selected\n returning...\n'
+ message = 'No Server selected'
+ self.ShowMessage(message, 'Warning')
+ StatusBar_fields = [message]
+ self.StatusBar.SetStatusText(StatusBar_fields[0], 0)
+ print message
return
self.usernameInput.Enable()
@@ -166,14 +170,18 @@
response = urlopen(req)
xml = response.read()
if(not isValidResponse(xml)):
- StatusBar_fields = ["Invalid GetCapabilities response"]
+ message = "Invalid GetCapabilities response"
+ self.ShowMessage(message, 'Warning')
+ StatusBar_fields = [message]
self.StatusBar.SetStatusText(StatusBar_fields[0], 0)
- print 'Not a valid Get Capabilities reponse'
+ print message
return
if(isServiceException(xml)):
- StatusBar_fields = ["Service Exception in Get Capabilities"]
+ message = 'Service Exception in Get Capabilities'
+ self.ShowMessage(message, 'Warning')
+ StatusBar_fields = [message]
self.StatusBar.SetStatusText(StatusBar_fields[0], 0)
- print 'Service Exception in Get Capabilities'
+ print message
return
#for testing pruposes
#f=open('in1.xml','r')
@@ -206,8 +214,13 @@
message = 'Successful'
print message
- StatusBar_fields = [message]
- self.StatusBar.SetStatusText(StatusBar_fields[0], 0)
+ if(not message=='Successful'):
+ self.ShowMessage(message, 'Warning')
+ StatusBar_fields = [message]
+ self.StatusBar.SetStatusText(StatusBar_fields[0], 0)
+ else:
+ StatusBar_fields = [message]
+ self.StatusBar.SetStatusText(StatusBar_fields[0], 0)
#Sudeep's Code Ends
event.Skip()
@@ -219,8 +232,9 @@
#url = self.urlInput.GetValue()
print self.selectedURL
if(self.selectedURL == "No server selected"):
- message = 'no url selected\n returning...\n'
+ message = 'No server selected'
print message
+ self.ShowMessage(message, 'Warning')
StatusBar_fields = [message]
self.StatusBar.SetStatusText(StatusBar_fields[0], 0)
return
@@ -245,6 +259,7 @@
if(isServiceException(image)):
message = 'Service Exception has occured'
+ self.ShowMessage(message, 'Warning')
print message
StatusBar_fields = [message]
self.StatusBar.SetStatusText(StatusBar_fields[0], 0)
@@ -255,7 +270,8 @@
if(imghdr.what('./map.png') != 'png'):
#print 'uiui'
#print imghdr.what('./map.png')
- message = 'Not a valid PNG Image, Unable to display, returning'
+ message = 'Not a valid PNG Image, Unable to display Map'
+ self.ShowMessage(message, 'Warning')
print message
StatusBar_fields = [message]
self.StatusBar.SetStatusText(StatusBar_fields[0], 0)
@@ -286,8 +302,14 @@
print message
print message
- StatusBar_fields = [message]
- self.StatusBar.SetStatusText(StatusBar_fields[0], 0)
+ if(message != 'Successful'):
+ self.ShowMessage(message, 'Warning')
+ StatusBar_fields = [message]
+ self.StatusBar.SetStatusText(StatusBar_fields[0], 0)
+ else:
+ StatusBar_fields = [message]
+ self.StatusBar.SetStatusText(StatusBar_fields[0], 0)
+
#Sudeep's Code Ends
event.Skip()
@@ -393,6 +415,10 @@
Publisher().sendMessage(("WMS_Menu_Close"), msg)
self.Destroy()
return
+
+ def ShowMessage(self, message, type = 'Warning'):
+ wx.MessageBox(message, type)
+
# end of class wmsFrame
#Sudeep's Code Starts
More information about the grass-commit
mailing list