Vision - closing error box popup via scripting

I have tried following as recommended in this post (Auto - Close Error Box).

But i think something has changed in version 8.1 + from 7.9.as it no longer works.

I have manually triggered an error popup from a Vision client, then ran the following code to try understand what windows are currently open:

from java.awt import Window, Frame 
from javax.swing import JFrame

print "Hostname: %s" % system.net.getHostName() 
windows = Window.getWindows()

for wind in windows: 
	print wind
	print "\n"

I get the following output:

Hostname: VMWIN10-OMRON01
javax.swing.JFrame[frame0,1070,596,419x151,invalid,hidden,layout=java.awt.BorderLayout,title=Launching,resizable,normal,defaultCloseOperation=HIDE_ON_CLOSE,rootPane=javax.swing.JRootPane[,0,0,419x151,invalid,layout=javax.swing.JRootPane$RootLayout,alignmentX=0.0,alignmentY=0.0,border=,flags=16777673,maximumSize=,minimumSize=,preferredSize=],rootPaneCheckingEnabled=true]


com.inductiveautomation.ignition.client.util.gui.DefaultPopupWindowParent[frame1,0,0,516x539,invalid,hidden,layout=java.awt.BorderLayout,title=Output Console,resizable,normal,defaultCloseOperation=DO_NOTHING_ON_CLOSE,rootPane=javax.swing.JRootPane[,8,31,500x500,invalid,layout=javax.swing.JRootPane$RootLayout,alignmentX=0.0,alignmentY=0.0,border=javax.swing.plaf.synth.SynthBorder@74a62a7a,flags=16777673,maximumSize=,minimumSize=,preferredSize=],rootPaneCheckingEnabled=true]


com.inductiveautomation.ignition.client.util.gui.DefaultPopupWindowParent[frame2,1101,515,755x468,invalid,layout=java.awt.BorderLayout,title=Error,resizable,normal,defaultCloseOperation=DO_NOTHING_ON_CLOSE,rootPane=javax.swing.JRootPane[,8,31,739x429,invalid,layout=javax.swing.JRootPane$RootLayout,alignmentX=0.0,alignmentY=0.0,border=javax.swing.plaf.synth.SynthBorder@4087f750,flags=16777673,maximumSize=,minimumSize=,preferredSize=],rootPaneCheckingEnabled=true]


com.inductiveautomation.ignition.client.util.gui.DefaultPopupWindowParent[frame3,1272,690,358x296,invalid,hidden,layout=java.awt.BorderLayout,title=Warning,resizable,normal,defaultCloseOperation=DO_NOTHING_ON_CLOSE,rootPane=javax.swing.JRootPane[,8,31,342x257,invalid,layout=javax.swing.JRootPane$RootLayout,alignmentX=0.0,alignmentY=0.0,border=javax.swing.plaf.synth.SynthBorder@175a9932,flags=16777673,maximumSize=,minimumSize=,preferredSize=],rootPaneCheckingEnabled=true]


javax.swing.JFrame[frame4,-8,-8,2576x1320,invalid,layout=java.awt.BorderLayout,title=G1-Line01 - Main Window,resizable,maximized,defaultCloseOperation=DO_NOTHING_ON_CLOSE,rootPane=javax.swing.JRootPane[,8,31,2560x1281,invalid,layout=javax.swing.JRootPane$RootLayout,alignmentX=0.0,alignmentY=0.0,border=javax.swing.plaf.synth.SynthBorder@5dbaff84,flags=16777673,maximumSize=,minimumSize=,preferredSize=],rootPaneCheckingEnabled=true]


com.inductiveautomation.ignition.client.util.gui.DefaultPopupWindowParent[frame5,94,295,2373x865,invalid,layout=java.awt.BorderLayout,title=Diagnostics,resizable,normal,defaultCloseOperation=DO_NOTHING_ON_CLOSE,rootPane=javax.swing.JRootPane[,8,31,2357x826,invalid,layout=javax.swing.JRootPane$RootLayout,alignmentX=0.0,alignmentY=0.0,border=javax.swing.plaf.synth.SynthBorder@180afbb3,flags=16777673,maximumSize=,minimumSize=,preferredSize=],rootPaneCheckingEnabled=true]


javax.swing.JDialog[dialog0,1077,575,405x176,invalid,hidden,layout=java.awt.BorderLayout,APPLICATION_MODAL,title=Update Available,defaultCloseOperation=HIDE_ON_CLOSE,rootPane=javax.swing.JRootPane[,8,31,389x137,invalid,layout=javax.swing.JRootPane$RootLayout,alignmentX=0.0,alignmentY=0.0,border=javax.swing.plaf.synth.SynthBorder@59f3b76a,flags=16777673,maximumSize=,minimumSize=,preferredSize=],rootPaneCheckingEnabled=true]

However it seems this output and all the Windows printed out is actually the same whether i have the error popup there or not…
For instance, a window with title = “Error” is there regardless.

I’ve used the following logic to close the error popup, which seems to work, but it is frustrating that the “Error” window still shows up after closing it, which makes it hard to write scripts to detect these popups properly.

for wind in Window.getWindows(): 
	if isinstance(wind,JFrame): 
		logger.debug(wind.getTitle())
		if wind.getTitle() == 'Error': 
			wind.dispose()

Is there a better Java class or something to detect the error popups more accurately…?

According to the docs, that’s expeced behavior:

There is, however, an isActive() function.

for wind in Window.getWindows(): 
	if isinstance(wind,JFrame): 
		logger.debug(wind.getTitle())
		if wind.getTitle() == 'Error' and wind.isActive(): 
			wind.dispose()

You could use the first half of my code here to statically retrieve the error & warning panels:

That returns an ErrorPanel, which is a JPanel, so you should be able to walk up from it to the JWindow.

Thanks Paul, where do i find the latest Java SDK for Ignition?
I keep coming back to here which is not what i want.
https://docs.inductiveautomation.com/display/SE/Ignition+SDK+Programmers+Guide

I’ve tried using the .parent property to “go up the chain”, which gives me the following component heirachy":


13:18:10.327 [AWT-EventQueue-0] DEBUG Tamaki Scripting - ErrorPanel type: <type 'com.inductiveautomation.ignition.client.util.gui.errors.ErrorPanel'>
13:18:10.329 [AWT-EventQueue-0] INFO Tamaki Scripting - Errors: [com.inductiveautomation.ignition.client.util.gui.errors.DisplayableError@4369c17f]
13:18:10.334 [AWT-EventQueue-0] DEBUG Tamaki Scripting - ParentPanel type: <type 'javax.swing.JPanel'>
13:18:10.338 [AWT-EventQueue-0] DEBUG Tamaki Scripting - ParentPanel2 type: <type 'javax.swing.JLayeredPane'>
13:18:10.341 [AWT-EventQueue-0] DEBUG Tamaki Scripting - ParentPanel3 type: <type 'javax.swing.JRootPane'>
13:18:10.345 [AWT-EventQueue-0] DEBUG Tamaki Scripting - ParentPanel4 type: <type 'com.inductiveautomation.ignition.client.util.gui.DefaultPopupWindowParent'>
13:18:10.353 [AWT-EventQueue-0] DEBUG Tamaki Scripting - ParentPanel5 type: <type 'NoneType'>

Looks like i was able to close it with the dispose() method on the parentPanel4 component.

If anyone in the future is interested in the final code, looks something like this. I intend to actually log the error to a database or something when closing these automatically, so we can try and diagnose the root cause. This is only intended to clear popups from dashboard TV screens that are not easy to access.

from java.awt import Window, Frame 
from javax.swing import JFrame 
from com.inductiveautomation.ignition.client.util.gui import ErrorUtil
from org.apache.commons.lang3.reflect import FieldUtils

logger = system.util.getLogger("Script Debugging")
scriptName = "dashboardClearErrors"
dashboardHosts = ["G1-1-S001","G1-1-S002","G1-1-S003","G1-1-S004","G1-1-S005","VMWIN10-OMRON01"]


clientName = system.net.getHostName()

if clientName in dashboardHosts:
	logger.debug(scriptName + " - host (%s) in list, attempting to detect errors" % (clientName))
	

	errorPanel = FieldUtils.readStaticField(ErrorUtil, "errorPanel", True)
	warningPanel = FieldUtils.readStaticField(ErrorUtil, "warningPanel", True)
	errors = FieldUtils.readField(errorPanel, "errors", True)
	warnings = FieldUtils.readField(warningPanel, "errors", True)
	
	# errorPanel is of type jPanel which is a child of jWindow component. 
	jWindow = errorPanel.parent.parent.parent.parent	
	####logger.debug("jWindow type: %s" % (type(jWindow)))
		
	if len(errors) > 0:
		# Something there, need to close popup.
		# NOTE: errorPanel component still exists if errors = 0, so need this check
		jWindow.dispose()
		logger.info("Attempting to close error popup using jWindow component")
		for error in errors:
			## TO DO: Log errors to SQL database for future reference. Include hostname
			logger.warn("Error title: %s, Message: %s, Exception: %s" % (error.title, error.message, error.exception))
		# end for
	# end if

Versioned Javadocs are linked on our SDK examples Github page:

1 Like