Customizing Alarm status table

Hi,

Is it possible to customize the Alarm Status Table, f.eks. changig name of colums etc.?

Are you using the Alarm Status Table in Vision or Perspective?

Hi,

I am using the Alarm Status Table in Vision.

I recently developed a way to accomplish this. Here is the code:

def columnLabeler(alarmStatusTable):
	if alarmStatusTable.componentCount > 0:
		for table in alarmStatusTable.getComponents():
			if 'AlarmStatusTable$1' in str(table.__class__):
				tableHeaders= table.getTableHeader()
				columnModel = table.getColumnModel()
				for column in range(table.columnCount):
					tableColumn = columnModel.getColumn(column)
					tableColumn.setHeaderValue("Custom Column Name " + str(column + 1))
				tableHeaders.repaint()
			columnLabeler(table)
alarmStatusTable = event.source.parent.getComponent('Alarm Status Table')
columnLabeler(alarmStatusTable)

The code finds the table within the component, and then loops through the columns using normal jtable methods to apply custom headers. This version is written for the actionPerformed event handler of a button in the same container as the Alarm Status Table.

The preceding code produces the following result:
image

One thing that is interesting about the code is that even if the client hides and reshows the column, the table remembers the replacement name. That said, the code will have to be ran from either an onInternalFrameOpened event script or something that works in this way, because if the window is closed, the table will not remember the next time the window is opened.

2 Likes

Updated header using the list and also this script is written in the same visionWindowOpened event handler (see below screenshot).

def columnLabeler(alarmStatusTable):
    lstCustomHeaders = ['Active Time','Current State','Tag Name','Description','Alarm State','Priority','Events','Ack By','Ack Notes']
    if alarmStatusTable.componentCount > 0:
        for table in alarmStatusTable.getComponents():
            if 'AlarmStatusTable$1' in str(table.__class__):
                tableHeaders= table.getTableHeader()
                columnModel = table.getColumnModel()
                for column in range(table.columnCount):
                    tableColumn = columnModel.getColumn(column)
                    custColName = lstCustomHeaders[column]
                    tableColumn.setHeaderValue(str(custColName))
                    

                tableHeaders.repaint()
            columnLabeler(table)
alarmStatusTable = system.gui.getParentWindow(event).getComponentForPath('Root Container.Alarm Status Table')
columnLabeler(alarmStatusTable)

In the past, I've done many component manipulations using the internalFrameOpened event handler, but I no longer prefer this way. Presently, I prefer to call my scripts from the component they affect using the componentRunning propertyChange event handler:

Example:

if event.propertyName == 'componentRunning`:
	#Manipulate the component here

This event handler only runs once when the component is initialized, and perhaps more importantly, it can't run before the component instance exists. Personally, I've never had a problem with running component initialization scripts from internalFrameOpened, but I've seen problems of the aforementioned nature from the visionWindowOpened event handler, so I would be wary of manipulating a component in this manner from there.

2 Likes

Ok, Thank you @justinedwards.jle for the information and your help.

1 Like