Release Notes > JTGO 4.0 Release Notes > New Features > CSS Configuration

It is now possible to customize view and object interactors through a CSS file, along with the graphic component configuration. Each graphic component has its own set of customizable properties. Refer to the Graphic Components User's Documentation for detailed information.

View Interactor

The interactor customization can be enabled or disabled through the interactor selector within the graphic component configuration. For example:

Tree {
  interactor: true;
}

When the interactor selector is enabled, you can create a specific selector where you declare your view interactor configuration, as follows:

Interactor {
  viewInteractor: @+viewInt;
}

The following tables provide a short description of the interactor-related properties of each graphic component.

Network Component

Table 3.5 IlpNetwork
Property 
Description 
name 
Defines the name of the default view interactor. To use this property you must define a toolbar that contains this interactor in the network component.  
viewInteractor 
Defines the default view interactor for the network component. This property accepts a bean that is an instance of IlpViewsViewInteractor or one of its subclasses. 

Note
When customizing the view interactor, you should use either the name or the view interactor instance. The equipment component has the same configuration as the network component.

Tree Component

Table 3.6 IlpTree
Property 
Description 
viewInteractor  
Defines the view interactor. This property accepts a bean that implements IlpViewInteractor.  

Table Component

Table 3.7 IlpTable
Property 
Description 
viewInteractor  
Defines the view interactor.This property accepts a bean that is an instance of IlpDefaultTableViewInteractor or one of its subclasses.  
headerInteractor 
Defines the header interactor. This property accepts a bean that is an instance of IlpDefaultTableHeaderInteractor or one of its subclasses.  

View interactors, as well as pop-up menu factories and actions, are customized as beans. You can either create your own specific view interactor class and use it in the CSS file, or use one of the JTGO classes that support this feature.

To create view interactors, JTGO provides the following classes that can be directly used in the graphic components:

Table 3.8 Properties of View Interactor Classes
Property 
Description  
popupMenuFactory 
Defines the pop-up menu factory.This property accepts a bean that implements IlpPopupMenuFactory. 
action 
Indexed property that defines the interactor actions that should be handled.This property accepts beans that are IlpGestureAction or IlpKeyStrokeAction instances. 

The following example illustrates the use of these properties:

#viewInt {
  class: 'ilog.cpl.table.interactor.IlpDefaultTableViewInteractor';
  popupMenuFactory: @=viewPopupMenuFactory;
  action[0]: @=viewAction0;
}

To create pop-up menus, JTGO provides the class IlpDefaultPopupMenuFactory.

Table 3.9 Pop-up Menus
Property 
Description 
menuItem 
Indexed property that defines the items that will be present in the pop-up menu.This property accepts a bean that is an instance of JMenuItem.  

The following example illustrates the use of this bean to create pop-up menus:

#viewPopupMenuFactory {
  class: 'ilog.cpl.interactor.IlpDefaultPopupMenuFactory';
  menuItem[0]: @+viewItem1;
}
 
#viewItem1 {
  class: 'javax.swing.JMenuItem';
  label: "Item 0";
  action: @+viewItemAction1;
}

The default table header menu factory, ilog.cpl.table.IlpDefaultTableHeaderMenuFactory has the following CSS property:

Table 3.10 Pop-up Menus
Property 
Description 
sortAttributes  
In the Show Attributes menu, this property indicates whether attributes are sorted or arranged according to the default column order. If the value is true (default), attributes are sorted by name; if it is false, attributes are arranged according to the default column order.  

The following example illustrates the use of this bean to configure the table header menu:

Table {
  interactor: true;
}
Interactor {
  headerInteractor: @=headerInt;
}
 
#headerInt {
  class: 'ilog.cpl.table.interactor.IlpDefaultTableHeaderInteractor';
  popupMenuFactory: @=headerPopupMenuFactory;
}
 
#headerPopupMenuFactory {
  class: 'ilog.cpl.table.IlpDefaultTableHeaderMenuFactory';
  sortAttributes: true;
}

To customize gesture or keystroke actions, you can create beans that are instances of the classes IlpGestureAction or IlpKeyStrokeAction. Using these classes, you specify the events and the underlying action that will be performed once these events are recognized by the interactor.

The following example illustrates how you can define a gesture action and a keystroke action in a view interactor:

#viewInt {
  class: 'ilog.cpl.table.interactor.IlpDefaultTableViewInteractor';
  action[0]: @=viewAction0;
  action[1]: @=viewAction1;
}
 
#viewAction0 {
  class: 'ilog.cpl.interactor.IlpGestureAction';
  gesture: BUTTON1_DOUBLE_CLICKED;
  action: @=showDetailsAction;
}
 
#showDetailsAction {
  class: 'ShowDetailsAction';
}
 
#viewAction1 {
  class: 'ilog.cpl.interactor.IlpKeyStrokeAction';
  keyStroke: 'typed a';
  action: @=printDetailsAction;
}

Object Interactor

Besides the view interactor, you can also customize object interactors through CSS. Their configuration can also be accomplished by the use of beans. The principle is the same as for other object properties: You declare an object selector and define the value of the property interactor, as illustrated in the following example:

object."ilog.tgo.model.IltObject" {
  interactor: @+objInter;
}
 
#objInter {
  class: 'ilog.cpl.interactor.IlpDefaultObjectInteractor;
  popupMenuFactory: @+objPopupMenuFactory;
  action[0]: @+objAction0;
}
 
#objPopupMenuFactory {
  class: 'ilog.cpl.interactor.IlpDefaultPopupMenuFactory';
}
 
#objAction0 {
  class: 'ilog.cpl.interactor.IlpGestureAction';
  gesture: BUTTON1_DOUBLE_CLICKED;
  action: @+showDetailsAction;
}

In the network, equipment and table components, you can define interactors to specific decorations or table cells. To customize these interactors, you must specify the object and the attribute to be attached to the interactor. The following example illustrates this feature:

object."ilog.tgo.model.IltObject/name" {
  interactor: @+objNameInteractor;
}
 
#objNameInteractor {
  class: 'ilog.cpl.interactor.IlpDefaultObjectInteractor';
}

Note
To use object interactors, you must customize your view interactor accordingly by setting the property usingObjectInteractor to true.