ILOG
Welcome, Guest | Sign In


Blogs | Forums | Worldwide sites | Contact us

title element1
Product Info
Features
Tutorial
Datasheet
Supported platforms
Technical Forum
Solutions
Customers
News & Events
Press releases
Trial & Purchase
Demos
Evals
Contact info
Tutorial  

ILOG Views Controls

ILOG Studio includes a scripting language to help design graphical user interfaces. ILOG Script is very useful for coding callback functions, especially if they are not complex. In our example, the application behavior is so simple that it can be coded easily and quickly using ILOG Script. This scripting language is Java Script compliant, and very easy to understand and use. You will find all the information about the language in the ILOG Script Reference Manual. We will see here a simple code implementation, just to show how it can be used directly in the Studio editor.

First, you need to launch a specific version of ILOG Studio, called jsstudio (for Java Script Studio). This Studio editor is the same as the Studio editor we use in the previous steps. The only difference is the integration of ILOG Script scripting language. Once the editor is launched, reload your application file tutorial.iva. It will load the corresponding panel files (MainPanel and SecondPanel).

Double-click on the MainPanel icon to edit this panel, and double-click on the "Open" button to edit it. Click on the "Callbacks" tab. You will see that this page is a little different from what we have seen:

On the right, you now have a toggle that indicates if the callback is to be coded in ILOG Script. If the toggle is checked, the button on its right becomes active.

Press this button. It opens a text editor subwindow in ILOG Studio (this subwindow can be detached), which lets you enter your ILOG Script code. At the beginning, it contains a default code that just prints a message, with the "writeln" ILOG Script function:

Note that a parameter obj is passed to the function. It is an identifier of the graphic object that triggered the callback. Remove the existing line to code the same behavior as you did in C++ in the previous step. This time, you will use ILOG Script instead of C++. ILOG Script is much easier. The ILOG Script API gives you access to ILOG Views classes. It is not as rich as the C++ API, but it is enough for the basic needs of a user interface. In this example, showing the second panel and updating the toggle indicator is easy enough to be done in ILOG Script.

  var panel = obj.container;

First, let's get an identifier of the panel containing the object. Every gadget has a "container" property that identifies it.

  var second = Application.SecondPanel;

Get an identifier on the second panel to make it visible. In this line, Application is a predefined object that identifies the current application. As ILOG Script is an interpreted language, the classes can be updated dynamically. The Application class has been automatically updated with two new properties, according to the creation of the two panels (MainPanel and SecondPanel).

  second.visible = true;

Now you just have to make the second panel visible by changing its visible property. That's it!

  panel.ToggleIndicator.state = true;

You can update the toggle indicator just as easily. Remember it was called 'ToggleIndicator', and as ILOG Script is dynamic, our MainPanel class has been updated with a new property for every gadget contained in the panel. You just have to change its state to "true", without having to redraw the object. ILOG Script will do this for you.

static function ClosePress(obj)
{
  var panel = obj.container;
  var second = Application.SecondPanel;
  second.visible = false;
  panel.ToggleIndicator.state = false;
}

Proceed the same way for the ClosePress callback, and you're done.

No code generation is necessary. And no C++ coding was needed. ILOG Script is a fully interpreted language. We can test our application right now, without exiting ILOG Studio. Switch to the application window in Studio and press the "Test" button  
You should see the application running properly.

Conclusion
This small example shows that the use of ILOG Script for basic needs saves a lot of time and labour. This scripting language can be used to manage gadgets and panels easily. It isn't as fast as C++ because it's an interpreted language, but execution speed is not a key point in user interface development. It's much easier to use, the syntax is very easy to learn, and you can directly test your application within the editor.

Learn More
    Features  
    Charts  
    Maps  
    Graph Layout  
    Controls  
    Data Access  
    Gantt Chart  
     
ILOG JViews Diagrammer
(includes Graph Layout)
ILOG JViews Maps
ILOG JViews Gantt
ILOG JViews Charts
ILOG JViews Telecom Graphic Objects
ILOG JViews Maps for Defense
Customer Spotlight
   
     
 
 
element3