Double click on power table

Hi guys,
I’m currently using the onDoubleClick extension function and it works wonderful, I was asked if it’s possible to double click on different columns and get different results. I tried looking at it and tested a few things and nothing worked… I figured If I use:

if colName == ‘x’:
open window1
elif colName == ‘Y’:
open window2
else:
open window3

is that functionality not available because when I do the same if statement with 1 == 1 it works fine but will not with colName or colIndex.

The easiest way to debug this is probably to work with print statements. Add a print to your code like this:

print colName, colIndex

Then when you double click, you should be able to see the print in the console window in the designer (or in the debug tools in the client). At that point, you can find if the handler reacts, and what the columns are numbered or named.

I can’t see anything wrong with your pseudo-code. Do note however, that python is case-sensitive. So “X” isn’t equal to “x”.

@Sanderd17
Good call on the print option, it always good to go back to basic debuging :grin:

07:02:18.660 [AWT-EventQueue-0] ERROR Vision.Components.AdvancedTable - Error invoking extension method.
com.inductiveautomation.ignition.common.script.JythonExecException: Traceback (most recent call last):
  File "<extension-method onDoubleClick>", line 29, in <module>
NameError: name 'colIndex' is not defined

	at org.python.core.Py.NameError(Py.java:260)
	at org.python.core.PyFrame.getname(PyFrame.java:257)
	at org.python.pycode._pyx18.f$0(<extension-method onDoubleClick>:29)
	at org.python.pycode._pyx18.call_function(<extension-method onDoubleClick>)
	at org.python.core.PyTableCode.call(PyTableCode.java:165)
	at org.python.core.PyCode.call(PyCode.java:18)
	at org.python.core.Py.runCode(Py.java:1275)
	at com.inductiveautomation.ignition.common.script.ScriptManager.runCode(ScriptManager.java:634)
	at com.inductiveautomation.vision.api.client.components.model.ExtensionFunction.invoke(ExtensionFunction.java:138)
	at com.inductiveautomation.factorypmi.application.components.VisionAdvancedTable$7.onClick(VisionAdvancedTable.java:365)
	at com.inductiveautomation.ignition.client.util.gui.CommonMouseAdapter.mouseReleased(CommonMouseAdapter.java:72)
	at java.awt.AWTEventMulticaster.mouseReleased(Unknown Source)
	at java.awt.Component.processMouseEvent(Unknown Source)
	at javax.swing.JComponent.processMouseEvent(Unknown Source)
	at java.awt.Component.processEvent(Unknown Source)
	at java.awt.Container.processEvent(Unknown Source)
	at java.awt.Component.dispatchEventImpl(Unknown Source)
	at java.awt.Container.dispatchEventImpl(Unknown Source)
	at java.awt.Component.dispatchEvent(Unknown Source)
	at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
	at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
	at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
	at java.awt.Container.dispatchEventImpl(Unknown Source)
	at java.awt.Window.dispatchEventImpl(Unknown Source)
	at java.awt.Component.dispatchEvent(Unknown Source)
	at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
	at java.awt.EventQueue.access$500(Unknown Source)
	at java.awt.EventQueue$3.run(Unknown Source)
	at java.awt.EventQueue$3.run(Unknown Source)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
	at java.awt.EventQueue$4.run(Unknown Source)
	at java.awt.EventQueue$4.run(Unknown Source)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
	at java.awt.EventQueue.dispatchEvent(Unknown Source)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.run(Unknown Source)
Caused by: org.python.core.PyException: Traceback (most recent call last):
  File "<extension-method onDoubleClick>", line 29, in <module>
NameError: name 'colIndex' is not defined

I tried it for rowIndex as well and same thing happened. I don’t think I have to import anything since these are local function parameters…
I’m a bit confused now :thinking::spy:

ok i’m about 101.96% sure the the issue is onDoubleClick extention function because I just tested this on onMouseClick and it works fine.

It works perfectly for me. Could you try with minimal code (just that print line)?

And if that doesn’t work, try it on a different system (different version of Ignition, different java version, …). Note that Ignition doesn’t support the latest java version. Best stay with the LTS version 1.8 now.

1 Like

Consider putting print dir() at the beginning of your function body to verify what names really are local to the function.

1 Like

@Sanderd17
That’s so weird how it works on onMouseClick but not onDoubleClick…
I deleted everything and all was left was the print command and still said the same thing…
If this wasn’t working on onMouseClick then I’d say its possible to have an issue with java version or Ignition version maybe…I’m still going to try it on a different java version and see what happens. Currently my client is using 1.8.0_171 and I’m not planning on moving away from 1.8 anytime soon lol…

@pturmel
I put the print dir() right under the def onDoubleClick():
and I got:

['colIndex', 'colName', 'event', 'rowIndex', 'self', 'value']

OK, update…
I opened a completely new table and used the testDate to populate it and ran the print colName,colIndex and it prints it fine…
This poor table might just be done with me and and all my scripts I’ve done to it… LOL (Even though I don’t think I’m doing anything crazy :grin:)

I’m just going to recreate this table in a fresh table and see if this behavior keeps happening.
just to make it more clear, as far as scripting I have propertyChange, configureCell and onDoubleClick used in this table
propertyChange:

if event.propertyName == 'data':
	from com.jidesoft.grid import TableUtils
	from javax.swing import JTable
	table = event.source.getTable()
	table.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS)
	TableUtils.autoResizeAllColumns(table)

configureCell:

	color = self.data.getValueAt(rowIndex,"COLOR")
	if color == 'RED': 
		return {'background': 'red','foreground' : 'white'}
	elif color == 'YELLOW': 
		return {'background': 'yellow','foreground' : 'black'}
	elif color == 'GREEN': 
		return {'background': '0,217,0','foreground' : 'black'}
	else:
		return {'background': 'BLACK','foreground' : 'white'}

onDoubleClick

	sourceWindowPath = 'windowPath'
	popUp = 'popupPath'
	table = system.gui.getWindow(sourceWindowPath).getRootContainer().getComponent('Table')
	value = table.data
	
	partNumber = value.getValueAt(table.selectedRow,"Part")
	window = system.nav.openWindow(popUp, {'partNumber' : partNumber})
	system.nav.centerWindow(window)

I don’t see how any of those three can interfere with each other do you?