| Graphic Components > Tree Component > Configuring the Tree Component > Configuring the Tree Component through a CSS File |
Configuring the Tree Component through a CSS File |
INDEX
PREVIOUS
NEXT
|
You can customize the following features in a CSS file:
The tree configuration can be split accross several CSS files that you can load by:
<tgo xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation = "ilog/cpl/schema/project.xsd" style="configurationFile1.css,configurationFile2.css">
The following code represents an example of configuring a tree using CSS. It is based on the CSS file located in
<installdir>/samples/tree/styling/srchtml/tree.css.html
where <installdir> is the directory where you have installed JViews TGO.
The configuration in CSS is organized as a set of rules that define properties.
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Tree Component configuration
// Type: Tree
// The following list shows all possible properties for
// the tree component.
// - view : enables the tree view configuration
// - interactor: enables the interactor configuration
// - adapter: enables the adapter configuration
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Tree {
view: true;
adapter: true;
}
View {
background: #FFFFDF;
selectionLookAndFeel: Highlight;
}
This rule specifies the elements of the tree component that will be customized. It contains Boolean flags that indicate whether some specific customizable properties are present. For example, the customization of the property adapter is not taken into account unless adapter: true is declared in the Tree rule.
This feature provides powerful cascading possibilities. You can define adapter customizations in a default CSS file and turn them on or off in another CSS file.
The following CSS properties affect the tree component:
This rule specifies the properties that are applied to the tree view.
The following CSS properties affect the appearance of the tree view:
Refer to the class ilog.cpl.tree.renderer.IlpViewRenderer in the ILOG JViews TGO Java API Reference Documentation for more information on configuring the view in a tree component.
This rule controls the configuration of the tree view interactor. The tree view interactor is responsible for handling events that occur in the tree view. You can define an interactor for the tree view or specific interactors for the tree nodes.
Property Name |
Property Type |
|---|---|
viewInteractor | ilog.cpl.interactor.IlpViewInteractor |
Prior to configuring the view interactor, you need to configure the tree component so that the interactor configuration is enabled:
Tree {
interactor: true;
}
After that, you can customize the view interactor in the Interactor rule as illustrated by the following code extract. Refer to The CSS Specification in the Styling documentation for details about the CSS syntax.
Interactor {
viewInteractor: @+viewInt;
}
Subobject#viewInt {
class: 'ilog.cpl.interactor.IlpDefaultViewInteractor;'
popupMenuFactory: @+viewPopupMenuFactory;
action[0]: @+viewAction0;
}
Subobject#viewPopupMenuFactory {
class: 'AlarmPopupMenuFactory';
}
Subobject#viewAction0 {
class: 'ilog.cpl.interactor.IlpGestureAction';
gesture: BUTTON2_CLICKED;
action: @=showDetailsAction;
}
The behavior of the view interactor is determined by the actions that are associated with user gestures and keystrokes. This behavior can also be customized through CSS. You can also configure a pop-up menu to be displayed in the tree view. Please refer to Interacting with the Tree View and Interacting with the Tree Nodes for more information about interactor customization.
When the interactor renderer is enabled, you can also customize interactors for specific tree nodes using CSS selectors to set the value of property interactor. For more information, refer to ilog.cpl.tree.renderer.IlpInteractorRenderer.
This rule controls the configuration of the tree adapter. The tree adapter is responsible for converting the business objects in the data source to representation objects (tree nodes) in the tree component. It provides the following features:
These tree adapter features can be customized through CSS using the following properties:
Property Name |
Property Type |
|---|---|
filter | ilog.cpl.util.IlpFilter |
origins |
list of object identifiers |
comparator | java.util.Comparator |
nodeFactory | ilog.cpl.tree.IlpTreeNodeFactory |
expansionStrategyFactory | ilog.cpl.util.IlpExpansionStrategyFactory |
acceptedClasses |
list of ilog.cpl.model.IlpClass |
excludedClasses |
list of ilog.cpl.model.IlpClass |
Prior to configuring the adapter, you need to configure the tree component so that the adapter configuration is enabled:
Tree {
adapter: true;
}
After that, you can customize each adapter property in the Adapter rule as illustrated by the following code extract. Refer to The CSS Specification in the Styling documentation for details about the CSS syntax.
Adapter {
filter: @+treeFilter;
comparator: @+treeComparator;
expansionStrategyFactory: @+treeExpStrategyFactory;
nodeFactory: @+treeNodeFactory;
origins[0]: ROOT1;
origins[1]: ROOT2;
}
Subobject#treeFilter {
class: MyTreeFilter;
}
Subobject#treeComparator {
class: MyTreeComparator;
}
Subobject#treeExpStrategyFactory {
class: MyTreeExpansionStrategyFactory;
}
Subobject#treeNodeFactory {
class: MyTreeNodeFactory;
adapter: @adapter;
}
You can programmatically modify the CSS configuration of the default tree adapter ( ilog.cpl.tree.IlpContainmentTreeAdapter) by using mutable style sheets through the ilog.cpl.css.IlpMutableStyleSheet API.
| Important |
| The mutable style sheet is set to the adapter as a regular style sheet and is cascaded in the order in which it has been declared. |
To use mutable style sheets:
ilog.cpl.css.IlpMutableStyleSheet and register it yourself through the setStyleSheet() API:
| Note |
Like any style sheet, the mutable style sheet is lost when the setStyleSheet() API is invoked and a new set of style sheets is applied to the adapter.
|
Reapplying a CSS configuration may be a heavy task, as the adapter may be forced to review filters, origins, recreate representation objects, and so on. It is important to use the mutable style sheet with care and to customize it properly to reapply the CSS wisely. To do so, there are two methods available in the ilog.cpl.css.IlpMutableStyleSheet API: setUpdateMask() and setAdjusting().
IlpStylable.UPDATE_COMPONENT_MASK: Only the adapter part is recustomized.
IlpStylable.UPDATE_OBJECTS_MASK: Only the representation object part is recustomized.
IlpStylable.UPDATE_ALL_MASK: Bot the adapter and representation object parts are recustomized.
IlpStylable.UPDATE_NONE_MASK: Nothing is recustomized.
UPDATE_OBJECTS_MASK as there is no need to reapply the CSS configuration for the adapter part:
| Copyright © 1987-2007 ILOG S.A. All rights reserved. Documentation homepage. All rights reserved. Legal terms. | PREVIOUS NEXT |