rcEndRunDlgImpl.py

Go to the documentation of this file.
00001 #!/usr/local/bin/python
00002 #
00003 #                               Copyright 2005
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__     = "2005/07/23 00:08:27"
00014 __updated__  = "$Date: 2005/09/22 00:29:30 $"
00015 __version__  = "$Revision: 1.5 $"
00016 __release__  = "$Name: HEAD $"
00017 __credits__  = "SLAC"
00018 
00019 import LICOS.copyright_SLAC
00020 
00021 from qt import *
00022 import sys
00023 from rcEndRunDlg   import rcEndRunDlg
00024 from rcComplStatus import rcCompletionStatus
00025 
00026 
00027 class rcEndRunDlgImpl(rcEndRunDlg):
00028   """!\brief End run dialog class.
00029 
00030   This class is based on the rcCommentPanel class
00031   (the import is done in rcEndRunDlg.ui) which provides
00032   the operator with the means of entering comments at the
00033   end of the run.
00034 
00035   The operator can also override the completion status here.
00036   """
00037 
00038   Accepted = QDialog.Accepted
00039 
00040   def __init__(self, parent = None, name = None, fl = 0):
00041     """!\brief rcEndRunDlgImpl constructor.
00042 
00043     \param parent Parent GUI
00044     \param name   GUI name
00045     \param fl     GUI flags
00046     """
00047     rcEndRunDlg.__init__(self, parent, name, fl)
00048     QObject.connect(self.comboComplStatus, SIGNAL("activated(const QString&)"), self.complStatusChanged)
00049     QObject.connect(self.CANCEL,SIGNAL("clicked()"),self.cancel)
00050     QObject.connect(self.OK,SIGNAL("clicked()"),self.ok)
00051 
00052     self.__parent = parent
00053     self.__compl = rcCompletionStatus()
00054 
00055   def initialize(self, secMan, loginId, app):
00056     """!\brief Initialize the dialog.
00057 
00058     \param secMan  Security manager
00059     \param loginId Operator's login id.
00060     """
00061     self.__secMan  = secMan
00062     self.__loginId = loginId
00063     self.__app     = app
00064     combo = self.comboComplStatus
00065     combo.clear()
00066     csDict = self.__compl.getAll()
00067     csStrList = csDict.values()
00068     csStrList.sort()
00069     for csStr in csStrList:
00070       combo.insertItem(csStr)
00071     curComplStatusStr = self.__app.getCompletionStatusStr()
00072     combo.setCurrentText(curComplStatusStr)
00073     self.comments.getWidget().clearDisplay()
00074     self.comments.getWidget().clearHistory()
00075     self.comments.getWidget().setReadOnly(0)
00076     self.txtPassword.setEnabled(0)
00077     self.txtPassword.clear()
00078 
00079   def complStatusChanged(self, complStatusStr):
00080     """!\brief Signal that the completion status has been changed by the operator.
00081 
00082     \param complStatusStr The new completion status string.
00083     """
00084     curComplStatus = self.__app.getCompletionStatusStr()
00085     if curComplStatus != complStatusStr:
00086       self.txtPassword.setEnabled(1)
00087     else:
00088       self.txtPassword.setEnabled(0)
00089 
00090   def getNewCompletionStatus(self, curComplStatusStr):
00091     """!\brief Retrieve the new completion status value and string.
00092 
00093     \param curComplStatusStr Current completion status string
00094 
00095     \return A tuple of new completion status value and string or
00096             A tuple of two Nones if the completion status have
00097             not been modified.
00098     """
00099     csStr = self.getCompletionStatusStr()
00100     for (cv, cs) in self.__compl.getAll().items():
00101       if cs == csStr:
00102         if cs != curComplStatusStr:
00103           return (cv, cs)
00104     return (None, None)
00105 
00106   def ok(self):
00107     """!\brief The user accepted the dialog.
00108 
00109     """
00110     if self.txtPassword.isEnabled():
00111       res = self.__secMan.authenticateUser(self.__loginId, str(self.txtPassword.text()).strip())
00112       if res != 0:
00113         QMessageBox.critical( self, "Authentication Error",
00114                         "Incorrect Password",
00115                         QMessageBox.Ok + QMessageBox.Default )
00116         return
00117     self.comments.getWidget().flushComment()
00118     QDialog.done(self, QDialog.Accepted)
00119 
00120   def cancel(self):
00121     """!\brief The user rejected the dialog.
00122 
00123     """
00124     self.comments.getWidget().clearHistory()
00125     QDialog.done(self, QDialog.Rejected)
00126 
00127   def getCompletionStatusStr(self):
00128     """!\brief Retrieve the completion status selected in the dialog.
00129 
00130     \return Selected completion status string.
00131     """
00132     return str(self.comboComplStatus.currentText())
00133 
00134   def enterComment(self, comment, addToHistory=0, source='system'):
00135     """!\brief Enter a comment programmatically.
00136 
00137     This can be called from a user script to add to comments.
00138     The text is prepended with \a source to indicate that it is a
00139     machine generated comment.
00140 
00141     \param comment      The text of the comment to be entered
00142     \param addtoHistory Whether this comment will be persistent or not
00143     \param source       The text to be prepended before the comment
00144 
00145     """
00146     self.comments.getWidget().enterComment(comment, addToHistory, source)
00147 
00148   def clearHistory(self):
00149     """!\brief Clear the comment history.
00150 
00151     """
00152     self.comments.getWidget().clearHistory()
00153 

Generated on Thu Apr 27 20:52:43 2006 for LICOS L02-01-00 by doxygen 1.4.6-NO