Property Type

There are several different type of widget properties, such as Boolean, Double, Color, Font and so on. The method widgetController.setPropertyValue(prop_id, value) only accepts certain value types corresponding to the property type. Here is the list of the acceptable value types for each type of property. Property Value Type is the type of the object returned from widgetController.getPropertyValue(prop_id).

Property Type Example Properties
Boolean Property Enabled, Visible
Integer Property Height, Width, X, Y
Double Property Meter.Level HIHI, Meter.Maximum
Combo Property Border Style
String Property Name, PV Name, Text
Color Property Background Color, Foreground Color
Font Property Font
File Path Property Image.Image File, Linking Container.OPI File
PointList Property Polyline.Points, Polygon.Points
Macros Property Macros
ColorMap Property IntensityGraph.Color Map

Boolean Property

Acceptable Value Type
boolean

Property Value Type
Boolean

Examples:
	widgetController.setPropertyValue("enable", false); 
	widgetController.setPropertyValue("visible", true); 	

Integer Property

Acceptable Value Type
int, double

Property Value Type
Integer

Examples:
	widgetController.setPropertyValue("x", 10); 

Double Property

Acceptable Value Type
double, int

Property Value Type
Double

Examples:
	widgetController.setPropertyValue("fill_level", 35.6);

Combo Property

Acceptable Value Type
int - it is the index of the item in the combo box of the property

Property Value Type
Integer

Examples:
	//set border style to line style
	widgetController.setPropertyValue("border_style", 1); 

String Property

Acceptable Value Type
String - allow macros in string
any object(the method toString() will be automatically called)

Property Value Type
String

Examples:
	widgetController.setPropertyValue("text", "Hello, World!");

Color Property

Acceptable Value Type
RGB
String(must be predefined in Color Macro file)

Property Value Type
OPIColor

Examples:
	importPackage(Packages.org.csstudio.opibuilder.scriptUtil);
	
	var ORANGE = ColorFontUtil.getColorFromRGB(255,255,0);
	widgetController.setPropertyValue("foreground_color",ORANGE);
	widgetController.setPropertyValue("background_color", "Major"); //"Major" is a color macro	

Font Property

Acceptable Value Type
FontData
String(must be predefined in Font Macro file)

Property Value Type
OPIFont

Examples:
	importPackage(Packages.org.csstudio.opibuilder.scriptUtil);
		
	var bigFont = ColorFontUtil.getFont("Times New Roman", 20, 1);
	widgetController.setPropertyValue("font", bigFont);	

Macros Property

Acceptable Value Type
MacrosInput

Property Value Type
MacrosInput

Examples:
	importPackage(Packages.org.csstudio.opibuilder.scriptUtil);
	var macroInput = DataUtil.createMacrosInput(true);
	macroInput.put("pv", PVUtil.getString(pvArray[0]));
	widgetController.setPropertyValue("macros", macroInput);

File Path Property

Acceptable Value Type
String - allow url start with http:// or ftp://

org.eclipse.core.runtime.IPath

Property Value Type
org.eclipse.core.runtime.IPath

Examples:
	//load image from relative path
	widgetController.getWidgetModel().setPropertyValue("image_file", "../pictures/fish.gif");
	//load image from url
	widgetController.getWidgetModel().setPropertyValue("image_file", "http://neutrons.ornl.gov/images/sns_aerial.jpg");
	//load image from absolute workspace path
	widgetController.getWidgetModel().setPropertyValue("image_file", "/BOY Examples/widgets/DynamicSymbols/Scared.jpg");
	//load image from local file system
	widgetController.getWidgetModel().setPropertyValue("image_file", "C:\\Users\\5hz\\Pictures\\me.gif");	

PointList Property

Acceptable Value Type
int[]

org.eclipse.draw2d.geometry.PointList

Property Value Type
org.eclipse.draw2d.geometry.PointList

Examples:
	importPackage(Packages.org.csstudio.opibuilder.scriptUtil);
	
	var jsArray = new Array(20,260,34,56,320,230);
	//set the points for a polygon/polyline widget
	widgetController.setPropertyValue("points", DataUtil.toJavaIntArray(jsArray));	

ColorMap Property

Acceptable Value Type
org.csstudio.opibuilder.datadefinition.ColorMap

Property Value Type
org.csstudio.opibuilder.datadefinition.ColorMap

Examples:
	importPackage(Packages.org.csstudio.opibuilder.scriptUtil);
	importPackage(Packages.org.csstudio.opibuilder.datadefinition);
	
	var value = PVUtil.getString(pvArray[0]);
	var colorMap;
	if(value == "Cool")
		colorMap = new ColorMap(ColorMap.PredefinedColorMap.Cool, true, true);
	else if(value == "Hot")
		colorMap = new ColorMap(ColorMap.PredefinedColorMap.Hot, true, true);
	else if(value == "JET")
		colorMap = new ColorMap(ColorMap.PredefinedColorMap.JET, true, true);
	else if(value == "GrayScale")
		colorMap = new ColorMap(ColorMap.PredefinedColorMap.GrayScale, true, true);
	else if(value == "ColorSpectrum")
		colorMap = new ColorMap(ColorMap.PredefinedColorMap.ColorSpectrum, true, true);
	else if(value == "Shaded")
		colorMap = new ColorMap(ColorMap.PredefinedColorMap.Shaded, true, true);	
	
	//set colormap of IntensityGraph			
	widgetController.getChild("IntensityGraph").setPropertyValue(
			"color_map", colorMap);	

Actions Property and Script Property are not changeable from script becaues they are only loaded once during the initialization of widget.