00001 #!/usr/local/bin/python 00002 # 00003 # Copyright 2003 00004 # by 00005 # The Board of Trustees of the 00006 # Leland Stanford Junior University. 00007 # All rights reserved. 00008 # 00009 00010 __facility__ = "Online" 00011 __abstract__ = "End Run Comments dialog" 00012 __author__ = "S. Tuvi <STuvi@SLAC.Stanford.edu>" 00013 __date__ = ("$Date: 2005/08/03 20:27:12 $").split(' ')[1] 00014 __version__ = "$Revision: 2.4 $" 00015 __release__ = "$Name: R04-12-00 $" 00016 __credits__ = "SLAC" 00017 00018 import LATTE.copyright_SLAC 00019 00020 from qt import * 00021 import sys 00022 from rcEndRunDlg import rcEndRunDlg 00023 from rcComplStatus import rcCompletionStatus 00024 00025 00026 class rcEndRunDlgImpl(rcEndRunDlg): 00027 00028 def __init__(self, parent = None, name = None, fl = 0): 00029 rcEndRunDlg.__init__(self, parent, name, fl) 00030 QObject.connect(self.comboComplStatus, SIGNAL("activated(const QString&)"), self.complStatusChanged) 00031 QObject.connect(self.CANCEL,SIGNAL("clicked()"),self.cancel) 00032 QObject.connect(self.OK,SIGNAL("clicked()"),self.ok) 00033 00034 self.__parent = parent 00035 self.__compl = rcCompletionStatus() 00036 00037 def initialize(self, secMan, loginId): 00038 self.__secMan = secMan 00039 self.__loginId = loginId 00040 combo = self.comboComplStatus 00041 combo.clear() 00042 csDict = self.__compl.getAll() 00043 csStrList = csDict.values() 00044 csStrList.sort() 00045 for csStr in csStrList: 00046 combo.insertItem(csStr) 00047 app = self.__parent.getApp() 00048 while app.__class__.__name__ != 'userApplication': 00049 app = app.getApp() 00050 curComplStatusStr = app.getCompletionStatusStr() 00051 combo.setCurrentText(curComplStatusStr) 00052 self.comments.getWidget().clearDisplay() 00053 self.comments.getWidget().clearHistory() 00054 self.comments.getWidget().setReadOnly(0) 00055 self.txtPassword.setEnabled(0) 00056 self.txtPassword.clear() 00057 00058 def complStatusChanged(self, complStatusStr): 00059 if self.__parent.getApp().__class__.__name__ == 'userSuite': 00060 curComplStatus = self.__parent.getApp().getApp().getCompletionStatusStr() 00061 else: 00062 curComplStatus = self.__parent.getApp().getCompletionStatusStr() 00063 if curComplStatus != complStatusStr: 00064 self.txtPassword.setEnabled(1) 00065 else: 00066 self.txtPassword.setEnabled(0) 00067 00068 def getNewCompletionStatus(self, curComplStatusStr): 00069 csStr = self.getCompletionStatusStr() 00070 for (cv, cs) in self.__compl.getAll().items(): 00071 if cs == csStr: 00072 if cs != curComplStatusStr: 00073 return (cv, cs) 00074 return (None, None) 00075 00076 def ok(self): 00077 if self.txtPassword.isEnabled(): 00078 res = self.__secMan.authenticateUser(self.__loginId, str(self.txtPassword.text()).strip()) 00079 if res != 0: 00080 QMessageBox.critical( self, "Authentication Error", 00081 "Incorrect Password", 00082 QMessageBox.Ok + QMessageBox.Default ) 00083 return 00084 self.comments.getWidget().flushComment() 00085 QDialog.done(self, QDialog.Accepted) 00086 00087 def cancel(self): 00088 self.comments.getWidget().clearHistory() 00089 QDialog.done(self, QDialog.Rejected) 00090 00091 def getCompletionStatusStr(self): 00092 return str(self.comboComplStatus.currentText()) 00093 00094 def enterComment(self, comment, addToHistory=0, source='system'): 00095 self.comments.getWidget().enterComment(comment, addToHistory, source) 00096 00097 def clearHistory(self): 00098 self.comments.getWidget().clearHistory() 00099