The widget to which a script is attached can be accessed in the script via widgetController object. widgetController object provided the methods to get or set any of its properties, host external objects or special methods to a speific widget.
public java.lang.Object getPropertyValue(java.lang.String prop_id)
prop_id
- the property id. In most cases, it is the lower case of the property name.
var x = widgetController.getPropertyValue("x"); //get x position of the widget
public void setPropertyValue(java.lang.String prop_id, java.lang.Object value)
prop_id
- the property id. In most cases, it is the lower case of the property name.
value
- the value. It must be the allowed input type corresponding to the property type.
See Property TypewidgetController.setPropertyValue("x", 20); //set x position of the widget to 20.
public void setPropertyValue(java.lang.String prop_id, java.lang.Object value, boolean forceFire)
prop_id
- the property id.value
- the value.forceFire
- If true, the property will be
set again even if the new value is same as old value. If false and the new value is same as
the old value, it will be ignored.widgetController.setPropertyValue( "opi_file", widgetController.getPropertyValue("opi_file"), true); //reload OPI in linking container.
public void setExternalObject(java.lang.String name, java.lang.Object var)
name
- the name of the object.var
- the object.public java.lang.Object getExternalObject(java.lang.String name)
This is an example which uses these two methods to remember if the dialog has been poped before.
importPackage(Packages.org.eclipse.jface.dialogs); importPackage(Packages.org.csstudio.platform.data); importPackage(Packages.java.lang); var flagName = "popped"; if(widgetController.getExternalObject(flagName) == null){ widgetController.setExternalObject(flagName, false); } var b = widgetController.getExternalObject(flagName); if(ValueUtil.getDouble(pvArray[0].getValue()) > 80){ if( b == false){ widgetController.setExternalObject(flagName, true); MessageDialog.openWarning( null, "Warning", "The temperature you set is too high!"); } }else if (b == true){ widgetController.setExternalObject(flagName, false); }
public void executeAction(int index)
index
- the index of the action in the actions list.public AbstractBaseEditPart getChild(java.lang.String name)
name
- the name of the child widget
var child = widgetController.getChild("gauge_2"); //get the gauge widget whose name is gauge_2 child.setPropertyValue("enable", false); //child is a widgetController