Script window fails to open after adding dynamic property

I am trying to add a dynamic property to an object. My code looks like this on a button referencing a paintable canvas:

[code]canvas = event.source.parent.getComponent(‘Paintable Canvas’)

props = canvas.getDynamicProps()
props.put(‘Test property’, ‘Test value’)
canvas.setDynamicProps(props)
print (canvas.getDynamicProps().get(‘imgHeight’).value)[/code]

When I go to preview mode and click the button, it seems to execute (I get output in the console), but my designer loses the ability to open script functions. When I try and re-open the script to change something, I get the following error:

[quote]Exception in thread “AWT-EventQueue-2” java.lang.ArrayStoreException: java.lang.String
at java.util.AbstractCollection.toArray(Unknown Source)
at com.inductiveautomation.factorypmi.application.binding.util.DynamicPropertyUtil.getProperties(DynamicPropertyUtil.java:51)
at com.inductiveautomation.vision.api.client.components.model.AbstractVisionComponent.getProperties(AbstractVisionComponent.java:145)
at com.inductiveautomation.factorypmi.application.binding.util.BindUtilities.getProperties(BindUtilities.java:489)
at com.inductiveautomation.factorypmi.application.binding.util.BindUtilities.getAllProperties(BindUtilities.java:504)
at com.inductiveautomation.factorypmi.designer.property.configurators.comptree.ComponentPropertyTreeModel.createPropertyChildren(ComponentPropertyTreeModel.java:94)
at com.inductiveautomation.factorypmi.designer.property.configurators.comptree.ComponentPropertyTreeModel.access$000(ComponentPropertyTreeModel.java:35)
at com.inductiveautomation.factorypmi.designer.property.configurators.comptree.ComponentPropertyTreeModel$ComponentNode.loadChildren(ComponentPropertyTreeModel.java:151)
at com.inductiveautomation.ignition.client.util.gui.tree.AbstractLazyLoadingTreeNode.checkChildren(AbstractLazyLoadingTreeNode.java:28)
at com.inductiveautomation.ignition.client.util.gui.tree.AbstractLazyLoadingTreeNode.getChildCount(AbstractLazyLoadingTreeNode.java:49)
at javax.swing.tree.DefaultTreeModel.getChildCount(Unknown Source)
at com.jidesoft.swing.TreeSearchable.populateTreePaths0(Unknown Source)
at com.jidesoft.swing.TreeSearchable.populateTreePaths0(Unknown Source)
at com.jidesoft.swing.TreeSearchable.populateTreePaths0(Unknown Source)
at com.jidesoft.swing.TreeSearchable.populateTreePaths(Unknown Source)
at com.jidesoft.swing.TreeSearchable.getTreePathes(Unknown Source)
at com.jidesoft.swing.TreeSearchable.getElementCount(Unknown Source)
at com.jidesoft.swing.Searchable.findFromCursor(Unknown Source)
at com.jidesoft.swing.SearchableBar.initComponents(Unknown Source)
at com.jidesoft.swing.SearchableBar.(Unknown Source)
at com.jidesoft.swing.SearchableBar.(Unknown Source)
at com.inductiveautomation.ignition.designer.gui.SearchUtility$CustomBar.(SearchUtility.java:87)
at com.inductiveautomation.ignition.designer.gui.SearchUtility.install(SearchUtility.java:56)
at com.inductiveautomation.ignition.designer.gui.SearchUtility.install(SearchUtility.java:52)
at com.inductiveautomation.ignition.designer.gui.SearchUtility.install(SearchUtility.java:46)
at com.inductiveautomation.factorypmi.designer.property.configurators.comptree.ComponentPropertyTreePanel.(ComponentPropertyTreePanel.java:72)
at com.inductiveautomation.factorypmi.designer.eventhandling.PropertyDialog.(PropertyDialog.java:48)
at com.inductiveautomation.factorypmi.designer.property.configurators.DBBrowserPanel$KeyPanel.(DBBrowserPanel.java:406)
at com.inductiveautomation.factorypmi.designer.property.configurators.DBBrowserPanel.initComponents(DBBrowserPanel.java:95)
at com.inductiveautomation.factorypmi.designer.property.configurators.DBBrowserPanel.(DBBrowserPanel.java:82)
at com.inductiveautomation.factorypmi.designer.eventhandling.DBBrowserBuilder.initComponents(DBBrowserBuilder.java:93)
at com.inductiveautomation.factorypmi.designer.eventhandling.DBBrowserBuilder.(DBBrowserBuilder.java:77)
at com.inductiveautomation.factorypmi.designer.eventhandling.ActionConfigPanel.(ActionConfigPanel.java:66)
at com.inductiveautomation.factorypmi.designer.eventhandling.ComponentScriptEditor.initComponents(ComponentScriptEditor.java:251)
at com.inductiveautomation.factorypmi.designer.eventhandling.ComponentScriptEditor.(ComponentScriptEditor.java:132)
at com.inductiveautomation.factorypmi.designer.eventhandling.ComponentScriptEditor.(ComponentScriptEditor.java:116)
at com.inductiveautomation.factorypmi.designer.workspace.WindowWorkspace$Handler.configureEventHandlers(WindowWorkspace.java:2714)
at com.inductiveautomation.factorypmi.designer.workspace.WindowWorkspace$Handler.configureEventHandlers(WindowWorkspace.java:2705)
at com.inductiveautomation.factorypmi.designer.workspace.WindowWorkspace$Handler.handleConfigActions(WindowWorkspace.java:2700)
at com.inductiveautomation.factorypmi.designer.workspace.WindowWorkspace$Handler.access$2000(WindowWorkspace.java:1984)
at com.inductiveautomation.factorypmi.designer.workspace.WindowWorkspace$Handler$11.actionPerformed(WindowWorkspace.java:2156)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at com.jidesoft.plaf.basic.BasicJideButtonListener.mouseReleased(Unknown Source)
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)
[/quote]

I can’t open any scripting until I restart my designer. If I don’t try and put a new property in, commenting out the line that does so, like this:

[code]canvas = event.source.parent.getComponent(‘Paintable Canvas’)

props = canvas.getDynamicProps()
#props.put(‘Test property’, ‘Test value’)
canvas.setDynamicProps(props)
print (canvas.getDynamicProps().get(‘imgHeight’).value)[/code]

it will execute just fine and the designer keeps working as expected.

While I’m sure there is an error in my code, it seems like it shouldn’t break the designer…

Seems the issue was because I was not providing the property as a com.inductiveautomation.factorypmi.application.binding.DynamicPropertyDescriptor. I figured out how to do so, but would still have liked to have seen an error message rather than not being able to open scripting windows.

getDynamicProps() is not documented in the manual. It is visible only in the javadocs (or reflection), along with the signatures that shows its data types. It’s kinda’ like leaving the well-marked highway for some off-roading in your favorite 4x4. There aren’t signs for every rock and rut.