How to select a tag in the Tag Browse Tree through scripting

As the title says, I have a view with a Tag Browse Tree component. On that view, I have a parameter called tagPath and I want to be able to pass in a path and it be selected in the Tag Browse Tree automatically… There is a selection property on the component, but it looks like it’s just read-only… When I paste a valid tag path in there, nothing happens (ie tag selection doesn’t change, folders don’t expand/collapse, etc).

Is there a way to do this? The desired behavior would be like the Table component’s row selection or column selection properties, where when you pass in a value, it’ll visibly select that row/column.

1 Like

Did you paste it directly on the selection property ?
It doesn't work like that if the doc is to be trusted. The selection property should be an object, with 2 keys: mode and values. That last one is where you'd paste the selected value.

If that doesn't work, make sure you're using the format it expects. The easiest way to do that would be to select a tag in the tree in preview mode, see what the selection property looks like, and reproduce it.

That’s exactly what I tried, just selecting something in the tree and seeing the format it appears in. The tree is capable of multiselect so the values property is a list. In my case, the mode is set to single and I’m setting values[0] when the view loads. That part is working, it just doesn’t affect the TBT component in any way.

image

@pturmel made the introspect script that finds all available methods from a component. I ran it on the TagBrowseTree in Perspective but I don't see anything available that would let you select a path.

Python Type: <type 'com.inductiveautomation.perspective.gateway.script.ComponentModelScriptWrapper$SafetyWrapper'>
Java Type:   <type 'com.inductiveautomation.perspective.gateway.script.ComponentModelScriptWrapper$SafetyWrapper'>
  M: getSibling(<type 'java.lang.String'>)
    returns <type 'com.inductiveautomation.perspective.gateway.api.PerspectiveElement'>
  M: <type 'java.lang.String'> getName()
  M: getParent()
    returns <type 'com.inductiveautomation.perspective.gateway.api.Component'>
  M: <type 'void'> print(<type 'java.lang.String'>)
  M: <type 'java.util.Collection'> getChildren()
  M: getSession()
    returns <type 'com.inductiveautomation.perspective.gateway.api.Session'>
  M: getPage()
    returns <type 'com.inductiveautomation.perspective.gateway.api.Page'>
  M: getChild(<type 'java.lang.String'>)
    returns <type 'com.inductiveautomation.perspective.gateway.api.PerspectiveElement'>
  M: <type 'boolean'> refreshBinding(<type 'java.lang.String'>)
  M: getPropertyTreeOf(<type 'com.inductiveautomation.perspective.common.api.PropertyType'>)
    returns <type 'com.inductiveautomation.perspective.gateway.property.PropertyTree'>
  M: getView()
    returns <type 'com.inductiveautomation.perspective.gateway.api.View'>
  M: <type 'void'> requestTooltip()
  M: <type 'void'> focus()
  M: <type 'void'> removeTooltip()

From Type:   <type 'java.lang.Object'>
  M: <type 'void'> wait(<type 'long'>)
  M: <type 'void'> wait(<type 'long'>,<type 'int'>)
  M: <type 'void'> wait()
  M: <type 'boolean'> equals(<type 'java.lang.Object'>)
  M: <type 'java.lang.String'> toString()
  M: <type 'int'> hashCode()
  M: <type 'java.lang.Class'> getClass()
  M: <type 'void'> notify()
  M: <type 'void'> notifyAll()

From python dir():
  Method     __class__ <type 'java.lang.Class'>
  Method     __copy__ <type 'builtin_function_or_method'>
  Method     __deepcopy__ <type 'builtin_function_or_method'>
  Method     __delattr__ <type 'builtin_function_or_method'>
  Property   __doc__ <type 'str'> The most base type
  Method     __ensure_finalizer__ <type 'builtin_function_or_method'>
  Method     __eq__ <type 'builtin_function_or_method'>
  Method     __format__ <type 'builtin_function_or_method'>
  Method     __getattribute__ <type 'builtin_function_or_method'>
  Method     __hash__ <type 'builtin_function_or_method'>
  Method     __init__ <type 'instancemethod'>
  Method     __ne__ <type 'builtin_function_or_method'>
  Method     __new__ <type 'builtin_function_or_method'>
  Method     __reduce__ <type 'builtin_function_or_method'>
  Method     __reduce_ex__ <type 'builtin_function_or_method'>
  Method     __repr__ <type 'builtin_function_or_method'>
  Method     __setattr__ <type 'builtin_function_or_method'>
  Method     __str__ <type 'builtin_function_or_method'>
  Method     __subclasshook__ <type 'builtin_function_or_method'>
  Method     __unicode__ <type 'builtin_function_or_method'>
  Property   children <type 'java.util.Collections$EmptyList'> []
  Method     class <type 'java.lang.Class'>
  Property   name <type 'unicode'> TagBrowseTree
  Property   page <type 'com.inductiveautomation.perspective.gateway.script.PageScriptWrapper$SafetyWrapper'> com.inductiveautomation.perspective.gateway.script.PageScriptWrapper$SafetyWrapper@6ae6c234
  Property   parent <type 'com.inductiveautomation.perspective.gateway.script.ComponentModelScriptWrapper$SafetyWrapper'> com.inductiveautomation.perspective.gateway.script.ComponentModelScriptWrapper$SafetyWrapper@13e9d8ba
  Property   session <type 'com.inductiveautomation.perspective.gateway.script.SessionScriptWrapper$SafetyWrapper'> com.inductiveautomation.perspective.gateway.script.SessionScriptWrapper$SafetyWrapper@137b9461
  Property   view <type 'com.inductiveautomation.perspective.gateway.script.ViewModelScriptWrapper$SafetyWrapper'> com.inductiveautomation.perspective.gateway.script.ViewModelScriptWrapper$SafetyWrapper@1ba2a0a6

I think the component lets information flow one way only.

If that is the case, big sad. I feel like this should be a feature, I know this component is new (v8.1.16) so hopefully in the future, this functionality gets added.

2 Likes