Hi,
Is there any option to change the background color of tag browse tree?
I was able to from a button using scripting:
from java.awt import Color
from javax.swing import JViewport
from com.inductiveautomation.ignition.client.util.gui.tree import AutoscrollingJTree
tagBrowseTree = event.source.parent.getComponent('Tag Browse Tree')
for component in tagBrowseTree.getComponents():
if isinstance(component, JViewport):
for subComponent in component.getComponents():
if isinstance(subComponent, AutoscrollingJTree):
subComponent.background = Color.green
break
break
The preceding code produces the following result:
The code just loops through the tag browser's subcomponents until it finds the autoscrollingJTree, and applies the specified color.
Edit: this works from a button's actionPerformed script too, but the code is much simpler:
from java.awt import Color
tagBrowseTree = event.source.parent.getComponent('Tag Browse Tree')
tagBrowseTree.getComponent(0).getComponent(0).background = Color.orange
Output:
Hi,
Is it possible to change the font color, icons present in that too?
I'm not sure. Since I last answered this, I've discovered the getTree
method that is arguably better, but I don't know why the setForeground
method doesn't work with it:
from java.awt import Color
tagBrowseTree = event.source.parent.getComponent('Tag Browse Tree').getTree()
tagBrowseTree.background = Color.orange
I couldn't find an intuitive way to do this, but the below approach works. This script is designed for the propertyChange event handler of the tag browse tree:
if event.propertyName == 'rootNodePath':
from java.awt import Color
component = event.source.getTree().getCellRenderer()
textNonSelectionColorField = component.getClass().getDeclaredField('textNonSelectionColor')
textNonSelectionColorField.setAccessible(True)
textNonSelectionColorField.set(component, Color.blue)
Result:
It looks like there are at least two approaches that could work here. It is possible that something similar to the above approach could be employed on the following renderer fields: 'folderIcon', 'closedFolderIcon', 'folderIconSelected', 'closedFolderIconSelected', 'standardTag', 'standardTagSelected', 'udtTag', 'udtTagSelected', 'udtInstance', 'errorIcon', 'loadingIcon', 'atomic', and 'atomicSelected'
Another approach could be to directly overwrite the icons in their respective jar files. It looks like they all live here: [...]/.ignition/cache/resources/platform/client-api-8.1.xx.jar/[...]/images/tags/
Hi Justinedwards,
Thank you for your support. Now i am able to change the font and background color.