Using global settings
While CSS properties allow you to configure objects for a graphic component, global settings allow you to define a common look and feel for all the graphic components in the application. Global settings are stored in and managed by the class
ilog.tgo.resource.IltSettings. The
IltSettings class stores a predefined look and feel at start up.
There are two ways to set global settings: through the API or through CSS.
How to set global settings through the API
You can assign new global settings or retrieve existing ones by directly calling the static methods IltSettings.SetValue(Object, Object) or IltSettings.GetValue(Object).
IltSettings.SetValue("Alarm.Impact.CriticalHigh.Description", "Critical High");
The setting shown customizes the description text for all Critical High Impact alarms.
String description = (String)
IltSettings.GetValue("Alarm.Impact.CriticalHigh.Description");
You can retrieve the value of the setting using the GetValue method.
How to set global settings through CSS
Global settings defined in CSS allow you to create global state objects, alarm objects or telecom objects in the system and refer to them by their names when you customize them.
To do so, you need first to create a CSS file containing all the global settings.
Settings {
alarm: true;
}
Alarm {
impactSeverities[0]: @+impactSeverity0;
}
Subobject#impactSeverity0 {
class: 'ilog.tgo.model.IltAlarm.ImpactSeverity';
name: "Alarm.Impact.InformationalHigh";
severity: 220;
}
setting."ilog.tgo.model.IltAlarm.ImpactSeverity"[name="Alarm.Impact.Information
alHigh"] {
description: "Informational High";
}
This example shows how to create an impact severity object, then add it to the state system. The creation is enabled by the alarm: true declaration. Next, objects with impact severities of the type created can be customized with a new description message.
Once the global CSS settings file is created, an instance of ilog.tgo.resource.IltSettings, which serves as the global settings root object, is created. The CSS settings file is then assigned to the root object using the setStyleSheets method:
IlpContext context = IltSystem.GetDefaultContext();
IltSettings settingsRoot = new IltSettings(context);
try{
settingsRoot.setStyleSheets( new String[] {"global.css"} );
}
catch (IlvStylingException e) {
e.printStackTrace();
}
The default settings can be restored by passing null to the setStyleSheets method:
IlpContext context = IltSystem.GetDefaultContext();
IltSettings settingsRoot = new IltSettings(context);
try{
settingsRoot.setStyleSheets( null );
}
catch (IlvStylingException e) {
e.printStackTrace();
}
NOTE New objects previously created through the global settings CSS file remain in the system.
Copyright © 2018, Rogue Wave Software, Inc. All Rights Reserved.