Alarm Status Table: Change the Ack-button font(size)

Hi Everyone,

Does anybody know how to change the font(size) on the Ack-button of the default Alarm Status Table?
My customer is not happy with the default font size…

Thanks!

I don’t see an easy way to change the font on the ack button, but I do see a property to disable it. Then, you could make a button on the side that reads from the “Selected Alarms” property on the table, and runs system.alarm.acknowledge() for each item.

It would look really similar to the code snippet at the bottom of this page:

It is possible, although not very human-readable, to drill from the Ignition component reference down to the underlying Swing button and change the font. Keep in mind that there’s no guarantee this will work between versions - any changes made to the underlying objects will break low-level scripting like this.

from java.awt import Font
largeFont = Font("Dialog", Font.BOLD, 24)
table = event.source.parent.getComponent('Alarm Status Table')
table.getComponent(0).getComponent(1).getComponent(0).getComponent(0).setFont(largeFont)

4 Likes

Thanks Paul, this works!

Is there any info on this subject, because the next item is the table header on a Alarm Journal component, which you cannot change using a property of the component.

+1 for this feature : I would like to change the table header font (bold style) of the Alarm Journal component ? @PGriffith could you please post a script to achieve it ?

1 Like

You’ll need to drill into the Ignition component to get the underlying Jidesoft table object (I’d suggest making a recursive getComponents() function) but once you’ve got it, you can just execute:

from java.awt import Font
header = table.getTableHeader()
header.setFont(header.getFont().deriveFont(Font.BOLD))

:clap::clap::clap: Thanks

@PGriffith, I’m looking for the underlying dataset of the alarm journal component to be able to export data to excel.
Any Idea to access to it ???

… and for the alarm status component too…

There’s this function to write simple Excel files: https://docs.inductiveautomation.com:8443/display/DOC78/system.dataset.exportExcel

Though I wonder how this question is related to setting a font on a button…

Hi. I tried drilling down using getComponents() however I can never seem to find the Jidesoft table object to modify the heading font. The closest thing that I could find was columnHeader as part of a JScrollPane object. Do you mind sharing the sequence of getComponent functions in order to access the header? I’m using version 7.9.7 by the way.

Thanks.

I think it’s worth noting for future people who have similar questions that Ignition’s API documentation is available online and details these components rather thoroughly.

That said, although it is available online, I don’t know how to access the latest version of it without googling an Ignition-API-specific string. For example, googling the following:

“ignition AlarmExpressionParseContext.AlarmExpressionPropResolver”

yields as its first result, this.

From there, you can click “All Classes” (or index if you don’t mind waiting for your browser to catch up), and find the component you’re looking for. Now, using @mazeyrat 's question as an example, we can find the alarmjournaltable in the list of “All Classes” and click it to see what it’s made of.

There are a lot more methods listed here than what you see in the ignition manual under Alarm Journal Table. I don’t see a means in the regular manual to even access the full list of alarms in the alarm journal table (since the question was asked, I’m assuming that “selected alarms” wasn’t enough). I haven’t tested the API functions, but I’m gonna guess that “getAlarms()” gets the contents of the alarm journal.

Now, tbh I do not know that this tool can be used to find paths through getComponent commands to different components… so for fun I wrote this script for drilling through components:

#this script is used on a button, and prints the complete list of "getComponents" for an object to the console.
def recursiveScan(codeString):
	i = 0
	try:
		while (1):
			newCodeString = codeString + ".getComponent(" + str(i) + ")"
			print newCodeString
			exec(newCodeString)
			recursiveScan(newCodeString)
			i+=1
	except:
		print "NO COMPONENT"
		return



myObject = event.source.parent.getComponent('Alarm Journal') #replace with your object
recursiveScan("print myObject")
4 Likes

This is how deep I had to go, getTableHeader() doesn’t work!

See below my code:

from java.awt import Font
largeFont = Font(“Dialog”, Font.PLAIN, 18)

table = system.gui.getParentWindow(event).getComponentForPath(‘Root Container.Alarm Journal’)
table.getComponent(0).getComponent(0).getComponent(1).getComponent(0).getComponent(3).getComponent(0).setFont(largeFont)

1 Like

When you change font size for the buttons (ACK and Shelve) in the Alarm Status Table, then the three icons on the bottom right are so small…, especially on the touch screen…
How can we change the icons size too?

I recently developed a way to double the size of all the footer buttons including those icons:
Here is the necessary code that is designed to run from the root window's internalFrameOpened event handler:

Source Code
alarmStatusTable = system.gui.getParentWindow(event).getComponentForPath('Root Container.Alarm Status Table') #From the parent window's internalFrameOpened event handler
from java.awt import Dimension, GridLayout, Image, Font
from javax.swing import JButton, ImageIcon
from com.jidesoft.swing import JideToggleButton
def setButtonSizes(alarmStatusTable):
	from java.awt import Color
	from com.jidesoft.swing import TristateCheckBox
	if alarmStatusTable.componentCount > 0:
		for component in alarmStatusTable.getComponents():
			if 'AlarmStatusTable$FooterPanel$ButtonPanel' in str(component.__class__):
				component.setPreferredSize(Dimension((2*component.getPreferredSize().width), (2*component.getPreferredSize().height)))
				component.setLayout(GridLayout(1, 3))
			elif 'AlarmStatusTable$FooterPanel$UtilityPanel' in str(component.__class__):
				component.setPreferredSize(Dimension((2*component.getPreferredSize().width), (2*component.getPreferredSize().height)))
				component.setLayout(GridLayout(1, 4))
			elif 'AlarmStatusTable$FooterPanel' in str(component.__class__):
				component.setPreferredSize(Dimension(component.getPreferredSize().width, (2*component.getPreferredSize().height)))		
			elif isinstance(component, JButton) and 'JideToggleButton' not in str(component.__class__) and 'SynthScrollBar' not in str(component.__class__):
				component.setPreferredSize(Dimension((2*component.getPreferredSize().width), (2*component.getPreferredSize().height)))
				componentFont = component.getFont()
				doubleFont = Font(componentFont.getFamily(), componentFont.getStyle(), (2*componentFont.getSize()))
				component.setFont(doubleFont)
			elif isinstance(component, JideToggleButton) and 'JideToggleButton' in str(component.__class__):
				component.setPreferredSize(Dimension((2*component.getPreferredSize().width), (2*component.getPreferredSize().height)))
				icon = component.getIcon()
				iconWidth = icon.getIconWidth()
				iconHeight = icon.getIconHeight()
				doubleImage = icon.getImage().getScaledInstance(iconWidth*2, iconHeight*2, Image.SCALE_SMOOTH)
				doubleIcon = ImageIcon(doubleImage)
				component.setIcon(doubleIcon)
			setButtonSizes(component)
setButtonSizes(alarmStatusTable)

The code locates the necessary components and makes the size adjustments. Where needed, the layouts are changed in the parent panels to accommodate the larger components.

Here is the before and after comparison:

Edit: Here is dynamic version that will change the size of the footer table buttons by whatever multiplication factor is put in the first line of code. This allows the buttons to be scaled both bigger or smaller. Examples: A 0.5 setting would make the buttons half size, while a setting of 3 would triple the size, etc.

Dynamic Script
multiplicationFactor = 1.5
alarmStatusTable = system.gui.getParentWindow(event).getComponentForPath('Root Container.Alarm Status Table') #From the parent window's internalFrameOpened event handler
from java.awt import Dimension, GridLayout, Image, Font
from javax.swing import JButton, ImageIcon
from com.jidesoft.swing import JideToggleButton
def setButtonSizes(alarmStatusTable):
	from java.awt import Color
	from com.jidesoft.swing import TristateCheckBox
	if alarmStatusTable.componentCount > 0:
		for component in alarmStatusTable.getComponents():
			if 'AlarmStatusTable$FooterPanel$ButtonPanel' in str(component.__class__):
				component.setPreferredSize(Dimension(int(float(multiplicationFactor)*float(component.getPreferredSize().width)), int(float(multiplicationFactor)*float(component.getPreferredSize().height))))
				component.setLayout(GridLayout(1, 3))
			elif 'AlarmStatusTable$FooterPanel$UtilityPanel' in str(component.__class__):
				component.setPreferredSize(Dimension(int(float(multiplicationFactor)*float(component.getPreferredSize().width)), int(float(multiplicationFactor)*float(component.getPreferredSize().height))))
				component.setLayout(GridLayout(1, 4))
			elif 'AlarmStatusTable$FooterPanel' in str(component.__class__):
				component.setPreferredSize(Dimension(component.getPreferredSize().width, int(float(multiplicationFactor)*float(component.getPreferredSize().height))))		
			elif isinstance(component, JButton) and 'JideToggleButton' not in str(component.__class__) and 'SynthScrollBar' not in str(component.__class__):
				component.setPreferredSize(Dimension(int(float(multiplicationFactor)*float(component.getPreferredSize().width)), int(float(multiplicationFactor)*float(component.getPreferredSize().height))))
				componentFont = component.getFont()
				doubleFont = Font(componentFont.getFamily(), componentFont.getStyle(), int(float(multiplicationFactor)*float(componentFont.getSize())))
				component.setFont(doubleFont)
			elif isinstance(component, JideToggleButton) and 'JideToggleButton' in str(component.__class__):
				component.setPreferredSize(Dimension(int(float(multiplicationFactor)*float(component.getPreferredSize().width)), int(float(multiplicationFactor)*float(component.getPreferredSize().height))))
				icon = component.getIcon()
				iconWidth = float(icon.getIconWidth())
				iconHeight = float(icon.getIconHeight())
				doubleImage = icon.getImage().getScaledInstance(int(iconWidth*float(multiplicationFactor)), int(iconHeight*float(multiplicationFactor)), Image.SCALE_SMOOTH)
				doubleIcon = ImageIcon(doubleImage)
				component.setIcon(doubleIcon)
			setButtonSizes(component)
setButtonSizes(alarmStatusTable)
3 Likes

Very interesting the multiplication factor, I absolutely will try it in my projects! Great work, thanks for sharing.

1 Like