Scripting in ICE using EASE
To open the shell (if you want to use scripting dynamically in ICE), go to Window in the top toolbar, select Show View -> Other...
A window will appear to select the specific view we need. Scroll down until you see a folder called Scripting. Inside that select Script Shell and click OK (it should look like the picture below). The new view will appear at the bottom of your screen.
If you want to use Python integration via Jython, then the next step is to install the Jython tools for EASE. Go to Help in the top toolbar and select Install EASE Components. A window will open displaying the available components to install. Check the box next to EASE Jython Integration and then select Finish. The Jython interpreter and shell will be installed into ICE.
Using the Core and Client Services
After firing up the script shell, the first thing to do is import an ease module that will allow us to control ICE (create items, edit their forms, etc.). A fresh shell should look something like the picture below:
On the left is a handy list of variables, which you can click on to view all of the associated methods. This works especially well when accessing Java classes like we need to do to control ICE.
Your first script
First, you need to import the module from ease 'System/Platform' with the command
This enables the retrieval of OSGi Services that we will use. You can also load modeules with the 'Load an External Module' button in the shell's view. Now we simply need to get the core service of ICE to create, delete, and edit items.
coreService = getService(org.eclipse.ice.core.iCore.ICore); model = coreService.getItem(int(coreService.createItem("Reflectivity Model"))); coreService.processItem(reflectMOdel.getId(), "Calculate Reflectivity", 1);
The first command,
coreService = getService(org.eclipse.ice.core.iCore.ICore);
gets the service from the core of ice to process items. The second command then creates a new item with the core.createItem("item name") command and then gets its reference. I use the int() command to change the returned type of string into a integer for the core.getItem() command. And finally, the
coreService.processItem(reflectModel.getId(), "Calculate Reflectivity", 1);
will process the item from the core. This takes the item id to identify which item to process, the action name for processing (as there can be many different ways to process the same item), and the client id which is usually one. Run these commands and you have just created a new item and processed it all without the touch of a button!