That old script is overdue for a refactor:
# Written for the propertyChange event handler of an alarm status table
# The component running event only fires once when its component is first initialized
# It won't fire in the designer unless preview mode is on prior to opening the window
if event.propertyName == 'componentRunning':
# Returns the first nested component of a given class
# container = The object containing nested components to be recursively searched
# className = the __name__ of the class given as a string
def findComponentOfClass(container, className):
for component in container.components:
if component.__class__.__name__ == className:
return component
else:
foundComponent = findComponentOfClass(component, className)
if foundComponent:
return foundComponent
# Recursively find the inner table
innerTable = findComponentOfClass(event.source, 'AlarmStatusTable$1')
# Iterate through the table columns and conditionally change the header values in some way
columnModel = innerTable.columnModel
for column in xrange(innerTable.columnCount):
tableColumn = columnModel.getColumn(column)
if tableColumn.headerValue == 'Label':
tableColumn.headerValue = 'Custom Alarm Name'
# Repaint the table header
innerTable.tableHeader.repaint()
This script was written for the propertyChange
event handler of the Alarm Status table itself. Simply right click on the alarm status table in the designer. Then, click on "Scripting" in the popup that appears, and place the script in the propertyChange event handler:
Result: