[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
gnue common/src/GConnections.py common/src/GLog...
From: |
Jason Cater |
Subject: |
gnue common/src/GConnections.py common/src/GLog... |
Date: |
Fri, 01 Mar 2002 23:10:25 -0500 |
CVSROOT: /home/cvs
Module name: gnue
Changes by: Jason Cater <address@hidden> 02/03/01 23:10:24
Modified files:
common/src : GConnections.py GLoginHandler.py
forms/src/uidrivers/wx: UIdriver.py
Log message:
added error information to Login Dialogs on failed dialogs
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/common/src/GConnections.py.diff?cvsroot=OldCVS&tr1=1.28&tr2=1.29&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/common/src/GLoginHandler.py.diff?cvsroot=OldCVS&tr1=1.3&tr2=1.4&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/forms/src/uidrivers/wx/UIdriver.py.diff?cvsroot=OldCVS&tr1=1.157&tr2=1.158&r1=text&r2=text
Patches:
Index: gnue/common/src/GConnections.py
diff -c gnue/common/src/GConnections.py:1.28
gnue/common/src/GConnections.py:1.29
*** gnue/common/src/GConnections.py:1.28 Mon Jan 21 13:50:02 2002
--- gnue/common/src/GConnections.py Fri Mar 1 23:10:24 2002
***************
*** 189,201 ****
GDebug.printMesg(5,'Getting new data connection to %s' %
connection_name)
while attempts:
try:
# Ask the UI to prompt for our login data
loginData = self._loginHandler.getLogin(
[connection_name,
self.getConnectionParameter(connection_name,'comment',''),
! dataObject.getLoginFields()])
# Add the parameters from the Connections Definition File
loginData.update(self.getConnectionParameters(connection_name))
--- 189,203 ----
GDebug.printMesg(5,'Getting new data connection to %s' %
connection_name)
+ errortext = None
while attempts:
try:
+
# Ask the UI to prompt for our login data
loginData = self._loginHandler.getLogin(
[connection_name,
self.getConnectionParameter(connection_name,'comment',''),
! dataObject.getLoginFields()], errortext)
# Add the parameters from the Connections Definition File
loginData.update(self.getConnectionParameters(connection_name))
***************
*** 215,220 ****
--- 217,223 ----
# Oops, they must have entered an invalid user/password.
# Those silly users.
attempts = attempts - 1
+ errortext = string.replace("%s" % error,'\n','')
if not attempts:
# Four times is plenty...
Index: gnue/common/src/GLoginHandler.py
diff -c gnue/common/src/GLoginHandler.py:1.3
gnue/common/src/GLoginHandler.py:1.4
*** gnue/common/src/GLoginHandler.py:1.3 Sun Aug 12 15:55:26 2001
--- gnue/common/src/GLoginHandler.py Fri Mar 1 23:10:24 2002
***************
*** 22,28 ****
# GConnections.py
#
# DESCRIPTION:
! # Class that handles prompting user for login information
# (design to be subclassed by the UI portion).
#
# NOTES:
--- 22,28 ----
# GConnections.py
#
# DESCRIPTION:
! # Class that handles prompting user for login information
# (design to be subclassed by the UI portion).
#
# NOTES:
***************
*** 34,59 ****
#
# If user stops the login process (cancel button?), raise this exception
#
! class UserCanceledLogin(Exception):
pass
! class LoginHandler:
# The client app can set any default values for the needed parameters.
defaults = {}
#
! # getLogin is passed an list consisting of:
# Connection Name
! # Connection Comments/Description
! # List of Fields to Input:
# Attribute Name, Label/Description, Is Password?
#
# It should return a dictionary of {Attribute Name: Inputted Value}
#
! def getLogin(self, requiredFields):
pass
--- 34,59 ----
#
# If user stops the login process (cancel button?), raise this exception
#
! class UserCanceledLogin(Exception):
pass
! class LoginHandler:
# The client app can set any default values for the needed parameters.
defaults = {}
#
! # getLogin is passed an list consisting of:
# Connection Name
! # Connection Comments/Description
! # List of Fields to Input:
# Attribute Name, Label/Description, Is Password?
#
# It should return a dictionary of {Attribute Name: Inputted Value}
#
! def getLogin(self, requiredFields, errortext=None):
pass
Index: gnue/forms/src/uidrivers/wx/UIdriver.py
diff -c gnue/forms/src/uidrivers/wx/UIdriver.py:1.157
gnue/forms/src/uidrivers/wx/UIdriver.py:1.158
*** gnue/forms/src/uidrivers/wx/UIdriver.py:1.157 Fri Mar 1 14:05:48 2002
--- gnue/forms/src/uidrivers/wx/UIdriver.py Fri Mar 1 23:10:24 2002
***************
*** 115,121 ****
global _EVENTPROCESSOR
_EVENTPROCESSOR = self.dispatchEvent
! global _PROMPTFORRECORD
_PROMPTFORRECORD = self.promptForRecordNumber
self.forms = {}
--- 115,121 ----
global _EVENTPROCESSOR
_EVENTPROCESSOR = self.dispatchEvent
! global _PROMPTFORRECORD
_PROMPTFORRECORD = self.promptForRecordNumber
self.forms = {}
***************
*** 1012,1034 ****
def __init__(self):
self._wxapp = getWxApp()
self.dlg = None
!
! def getLogin(self, loginData):
if 1: # TODO: This is left here to prevent me from having to unindent
this code
# TODO: Since the UI stuff is currently being gutted I'm not
wasting the time
# TODO: to do the right thing
if len(loginData[1]):
! loginMesg = 'Login required for "%s"' % (loginData[1])
else:
loginMesg = 'Login required for %s' % (loginData[0])
! self.dlg = wxDialog(NULL, -1, "GNU Enterprise: Login")
self.dlg.SetAutoLayout(true)
!
bmp = wxImage(os.environ['INSTALL_PREFIX']+'/'+GConfig.get('smallPNG'),
wxBITMAP_TYPE_PNG).ConvertToBitmap()
self.textctrlList = []
- messageField = wxStaticText(self.dlg, 1010, str(loginMesg))
labelList = []
dlgWidth = max(bmp.GetWidth(), messageField.GetSize().GetWidth()+20)
--- 1012,1035 ----
def __init__(self):
self._wxapp = getWxApp()
self.dlg = None
!
! def getLogin(self, loginData, errortext=None):#"Invalid username/password"):
if 1: # TODO: This is left here to prevent me from having to unindent
this code
# TODO: Since the UI stuff is currently being gutted I'm not
wasting the time
# TODO: to do the right thing
if len(loginData[1]):
! loginMesg = 'Login required for\n"%s"' % (loginData[1])
else:
loginMesg = 'Login required for %s' % (loginData[0])
! self.dlg = wxDialog(NULL, -1, "GNU Enterprise: Login to %s" %
loginData[0])
self.dlg.SetAutoLayout(true)
!
bmp = wxImage(os.environ['INSTALL_PREFIX']+'/'+GConfig.get('smallPNG'),
wxBITMAP_TYPE_PNG).ConvertToBitmap()
+ messageField = WrappedStaticText(self.dlg, -1, str(loginMesg), 300,
style=wxALIGN_CENTER)
+
self.textctrlList = []
labelList = []
dlgWidth = max(bmp.GetWidth(), messageField.GetSize().GetWidth()+20)
***************
*** 1039,1084 ****
ySpacing = 0
fieldLabelWidth = 0
! for prompt in loginData[2]:
! s = wxStaticText(self.dlg, 1010, '%s:' % prompt[1])
labelList.append(s)
! if prompt[2]:
! t = wxTextCtrl(self.dlg, -1,"",wxPoint(1, 1), wxSize(150, 20),
style=wxTE_PASSWORD|wxTE_PROCESS_ENTER)
else:
! t = wxTextCtrl(self.dlg, -1,"",wxPoint(1, 1), wxSize(150, 20),
style=wxTE_PROCESS_ENTER)
!
myID = len(self.textctrlList)
self.textctrlList.append(t)
EVT_CHAR(t, LoginFieldHandler(self, myID).loginFieldEventTrap)
! fieldLabelWidth = max(fieldLabelWidth, \
! s.GetSize().GetWidth() +
t.GetSize().GetWidth() + 10)
dlgWidth = max(dlgWidth, \
! s.GetSize().GetWidth() + t.GetSize().GetWidth() + 10)
xSpacing = max(xSpacing, s.GetSize().GetWidth())
ySpacing = max(ySpacing, s.GetSize().GetHeight())
ySpacing = max(ySpacing, t.GetSize().GetHeight())
! loginButton = wxButton(self.dlg,19998,'Login')
! cancelButton = wxButton(self.dlg,19999,'Cancel')
! EVT_BUTTON(self.dlg, 19998, self.loginButtonEventTrap)
! EVT_BUTTON(self.dlg, 19999, self.loginCancelEventTrap)
! dlgWidth = max(dlgWidth, loginButton.GetSize().GetWidth() +
cancelButton.GetSize().GetWidth() + 6) + 20
! dlgHeight += max(loginButton.GetSize().GetHeight(),
cancelButton.GetSize().GetHeight()) - 6
firstY = bmp.GetHeight() + messageField.GetSize().GetHeight() + 50
lastY = firstY
xSpacing += 10 # Add whitespace between widgets
ySpacing += 6 # Add whitespace between widgets
xPos = dlgWidth/2 - fieldLabelWidth/2
!
# Move the fields and labels into position
for i in range(0, len(self.textctrlList)):
--- 1040,1099 ----
ySpacing = 0
fieldLabelWidth = 0
! for prompt in loginData[2]:
! s = wxStaticText(self.dlg, -1, '%s:' % prompt[1])
labelList.append(s)
! if prompt[2]:
! t = wxTextCtrl(self.dlg, -1,"",wxPoint(1, 1), wxSize(150, 20),
! style=wxTE_PASSWORD|wxTE_PROCESS_ENTER)
else:
! t = wxTextCtrl(self.dlg, -1,"",wxPoint(1, 1), wxSize(150, 20),
! style=wxTE_PROCESS_ENTER)
!
myID = len(self.textctrlList)
self.textctrlList.append(t)
EVT_CHAR(t, LoginFieldHandler(self, myID).loginFieldEventTrap)
! fieldLabelWidth = max(fieldLabelWidth,
! s.GetSize().GetWidth() + t.GetSize().GetWidth() + 10)
dlgWidth = max(dlgWidth, \
! s.GetSize().GetWidth() + t.GetSize().GetWidth() + 20)
xSpacing = max(xSpacing, s.GetSize().GetWidth())
ySpacing = max(ySpacing, s.GetSize().GetHeight())
ySpacing = max(ySpacing, t.GetSize().GetHeight())
! loginId = wxNewId()
! cancelId = wxNewId()
!
! loginButton = wxButton(self.dlg,loginId,'Login')
! cancelButton = wxButton(self.dlg,cancelId,'Cancel')
! EVT_BUTTON(self.dlg, loginId, self.loginButtonEventTrap)
! EVT_BUTTON(self.dlg, cancelId, self.loginCancelEventTrap)
! dlgWidth = max(dlgWidth, loginButton.GetSize().GetWidth() +
cancelButton.GetSize().GetWidth() + 6) + 20
! dlgHeight += max(loginButton.GetSize().GetHeight(),
cancelButton.GetSize().GetHeight()) - 6
+ if errortext:
+ errorField = WrappedStaticText(self.dlg, -1, str(errortext), 300,
+ style=wxALIGN_CENTER)
+ errorField.SetForegroundColour(wxColour(223,0,0))
+
+ dlgWidth = max(dlgWidth, errorField.GetSize().width+10)
+ dlgHeight += errorField.GetSize().height + 6
+
+
firstY = bmp.GetHeight() + messageField.GetSize().GetHeight() + 50
lastY = firstY
xSpacing += 10 # Add whitespace between widgets
ySpacing += 6 # Add whitespace between widgets
xPos = dlgWidth/2 - fieldLabelWidth/2
!
# Move the fields and labels into position
for i in range(0, len(self.textctrlList)):
***************
*** 1087,1092 ****
--- 1102,1112 ----
self.textctrlList[i].SetPosition(wxPoint(xPos + xSpacing, lastY))
lastY = lastY + ySpacing
+ if errortext:
+ errorField.SetPosition(
+ wxPoint(dlgWidth/2 - errorField.GetSize().width/2,
+ lastY+3))
+
# Set the focus to the first text entry field
self.textctrlList[0].SetFocus()
***************
*** 1094,1105 ****
wxStaticBitmap(self.dlg,-1, bmp,
wxPoint((dlgWidth-bmp.GetWidth())/2, 12),
wxSize(bmp.GetWidth(), bmp.GetHeight()))
!
# Move the various widgets into position
messageField.SetPosition(
wxPoint(dlgWidth/2 - messageField.GetSize().GetWidth()/2,
30 + bmp.GetHeight()))
!
cancelButton.SetPosition(
wxPoint(dlgWidth - 10 - cancelButton.GetSize().GetWidth(),
dlgHeight - 10 - max(loginButton.GetSize().GetHeight(),
--- 1114,1125 ----
wxStaticBitmap(self.dlg,-1, bmp,
wxPoint((dlgWidth-bmp.GetWidth())/2, 12),
wxSize(bmp.GetWidth(), bmp.GetHeight()))
!
# Move the various widgets into position
messageField.SetPosition(
wxPoint(dlgWidth/2 - messageField.GetSize().GetWidth()/2,
30 + bmp.GetHeight()))
!
cancelButton.SetPosition(
wxPoint(dlgWidth - 10 - cancelButton.GetSize().GetWidth(),
dlgHeight - 10 - max(loginButton.GetSize().GetHeight(),
***************
*** 1113,1128 ****
self.loginButton = loginButton
self.dlg.SetSize(wxSize(dlgWidth, dlgHeight))
!
self.dlg.Refresh()
self.dlg.Fit()
self.dlg.Raise()
self.dlg.CenterOnScreen()
!
# If user cancels, this will be set to 0
self._completed = 0
self.dlg.ShowModal()
!
if not self._completed:
raise GLoginHandler.UserCanceledLogin
--- 1133,1148 ----
self.loginButton = loginButton
self.dlg.SetSize(wxSize(dlgWidth, dlgHeight))
!
self.dlg.Refresh()
self.dlg.Fit()
self.dlg.Raise()
self.dlg.CenterOnScreen()
!
# If user cancels, this will be set to 0
self._completed = 0
self.dlg.ShowModal()
!
if not self._completed:
raise GLoginHandler.UserCanceledLogin
***************
*** 1183,1188 ****
--- 1203,1236 ----
self.app.loginCompleted(1)
else:
event.Skip()
+
+
+
+ class WrappedStaticText(wxStaticText):
+ def __init__(self, parent, id, label, width, *args, **params):
+ wxStaticText.__init__(self, parent, id, "bah!", *args, **params)
+
+
+ textSoFar = ""
+ thisLine = ""
+ for part in string.split(label,'\n'):
+ for word in string.split(part):
+ self.SetLabel(thisLine + word)
+ if self.GetSize().width > width:
+ textSoFar += thisLine + " \n"
+ thisLine = word + " "
+ else:
+ thisLine += word + " "
+
+ textSoFar += thisLine + " \n"
+ thisLine = ""
+
+ if len(textSoFar):
+ self.SetLabel(string.replace(textSoFar,' \n','\n')[:-1])
+ else:
+ self.SetLabel("")
+
+
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- gnue common/src/GConnections.py common/src/GLog...,
Jason Cater <=