I've developed a way to accomplish this, but to me, it seems quite complicated, so in the code below, I have been unusually detailed in my comments to make it easier to modify this code if needed.
Here is the code for the Alarm Status Table's onAcknowledge extension function that will make notes optional when they not required by the tag:
label = self.getComponent(0).getComponent(1).getComponent(0).getComponent(2)#This label is for the Notes Required Alert
slideOverPane = self.getComponent(0).getComponent(0)#Responsible for expanding slide up notes panel
jideTable = self.getComponent(0).getComponent(0).getComponent(1).getComponent(0).getComponent(3).getComponent(0)#this is the table that contains the selection checkboxes
def clearNoteReqAlert():#Resets Notes Required alert notification
if slideOverPane.isExpanded():#Check to see if the notes panel is already visible; if so, process notes, but if not, make it so
textArea = self.getComponent(0).getComponent(0).getComponent(0).getComponent(0).getComponent(1).getComponent(0).getComponent(5).getComponent(0).getComponent(0).getComponent(0)#gets text area component
notes = textArea.getText()#gets the notes from the notes textbox
if "ackNotesReqd=true" in str(alarms) and len(notes) < 1:#If notes are required, and none are present: stop the loop, alert the operator, and wait for notes
label.setText('Acknowledgement Notes Required')
system.util.invokeLater(clearNoteReqAlert, 3000)#Reset note alert automatically after 3 seconds
else:#if notes are present, or if notes are NOT required: acknowledge the alarm and apply notes if they are present
for alarm in alarms:
eventID = 
eventID.append(str(alarm.get('EventId')))#get the event id for the alarm in the form of a string array
for row in range(jideTable.getRowCount()):#loops through and deselects all checkboxes after alarms have been acknowledged
jideTable.setValueAt(False, row, 0)
textArea.setText('')#Clears notes text area after alarms have been acknowledged
slideOverPane.collapse()#hides slide over pane
slideOverPane.expand()#expand the slide over pane
buttonPanel = self.getComponent(0).getComponent(1).getComponent(0)#the notes panel lives in this component
notesPanelField = buttonPanel.getClass().getDeclaredField('notesPanel')#access the notes panel field
notesPanelField.setAccessible(True)#set the protected field to accessable
notesPanel = notesPanelField.get(buttonPanel)#get the notes panel
popupHolderPanel = self.getComponent(0).getComponent(0).getComponent(0).getComponent(0)#This panel should contain the notes panel, but it isn't automatically set
for specificMethod in popupHolderPanel.getClass().getDeclaredMethods():#Get the protected method that sets the panel
if specificMethod.name == 'setContents':
method = specificMethod
method.invoke(popupHolderPanel, [notesPanel])#set the panel
Explination of the code:
First, the above code checks to see if the notes panel is open at acknowledgement, and if it isn't, it opens it without any regard for whether or not notes are required. No acknowledgements will take place with the first button press.
• Note: For reasons that are unknown to me, the acknowledgement notes panel is stored in the footer of the alarm table in a protected field and has to be added to the popup holder panel the first time it is expanded. The above code does this using the setContents method of the PopupHolderPanel, but for reasons that are also unknown to me, this method cannot be accessed directly. For these reasons, this step of the process seems much more complicated than it should be, but if there is a simpler way to invoke this action, I haven't found it yet.
Once the notes panel is opened, if the acknowledgement button is pressed, the code checks to see if acknowledgement notes are required. If notes are required, the code enforces the policy in the normal way, but if notes are not required, the alarms will be acknowledged whether or not notes have been typed. That said, if notes have been typed, the notes will be applied to the acknowledged tags.
Once the alarms have been acknowledged, the checkboxes are unchecked, and the notes panel is cleared and closed.
• Implemented much simpler way to check for alarm note requirements
• Changed the way the the setContents method is obtained after testing on a different system and discovering a discrepancy in the method index
for loop for better efficiency