Styling > Using Cascading Style Sheets > Using Global Settings

While CSS properties allow you to configure objects per 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 above customizes the description text for all Critical High Impact alarms.

String description = (String)
  IltSettings.GetValue("Alarm.Impact.CriticalHigh.Description");

The settings value above is retrieved 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.InformationalHigh"] {
  description: "Informational High";
}

The example above 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 severites 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 assgined 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.

The customization of global settings is discussed in detail in the following sections: