In case of the existing ScriptUtil APIs cannot meet your requirement, you can create your own ScriptUtil from Java in Eclipse by yourself, and then call your custom ScriptUtil from BOY script. The code of this example is availabe in BOY Examples->Miscellaneous->CustomScriptUtil.
This example will create a simple ScriptUtil that popup a "Hello World!" dialog.
The widget plugin will need to have BOY plugin (org.csstudio.opibuilder) as dependecy,
so you need to have BOY plugin and its dependent CSS plugins installed in your
Eclipse environment. You can simply copy BOY plugin and its dependencies from
your CSS plugin folder to your Eclipse dropin
folder. If you are a CSS developer, you just need to
import these plugins into your workspace from your Mercurial repository.
Create a new fragment project with all the default settings.
Use plugin org.csstudio.opibuilder
as host.
In Fragment src folder, creat a package, for example "org.csstudio.opibuilder.customScriptUtilExample". Go to MATNIFEST.MF->Runtime page, export this package. In this package create a Class and static methods which you will call in BOY script. For example:
public class MyScriptUtil { public static void helloWorld(){ ConsoleUtil.writeInfo("Hello World!"); MessageDialog.openInformation(Display.getCurrent().getActiveShell(), "Hello", "MyScriptUtil says: Hello World!"); } }
If you are a CSS developer, now your have finished the fragment project.
You can integrate it into CSS by including this fragment into your CSS build.
Here we will discuss how to add this fragment to an existing CSS.
Open the MANIFEST.MF file and go to the overview tab. Click Export Wizard.
Change the Destination Directory to the any directory you want.
Leave other settings as default and click Finish.
When exporting finished, go to the directory you set and copy the .jar file
to CSS dropins
folder.
Here is the JavaScript example. You can also call it from Python Script.
importPackage(Packages.org.csstudio.opibuilder.customScriptUtilExample); MyScriptUtil.helloWorld();