// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Table Component configuration
// Type: Table
//
// This is the main selector when customizing
// a table component. It identifies the 
// sub-components that will be addressed in the
// CSS customization. In the Table Component, it
// is possible to customize the view, controller
// and adapter using CSS.
//
// List of available properties:
// - view: boolean
// - interactor: boolean
// - adapter: boolean
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Table {
  view: true;
  interactor: true;
}

// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Table View configuration
// Type: View
//
// The following list shows all possible properties for
// the table component. 
// This configuration is set in the IlpTableView. 
//
// List of available properties:
// - background: Color
// - gridColor: Color
// - showGrid: boolean
// - showHorizontalLines: boolean
// - showVerticalLines: boolean
// - rowMargin: int
// - columnMargin: int
// - fixedColumnCount: int
// - autoResizeMode: IlpTableResizeMode
// - selectionMode: IlpTableSelectionMode
// - reorderingAllowed: boolean
// - headerRenderer: IlpTableHeaderRenderer
// - defaultRenderer: IlpTableCellRenderer
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
View {
  reorderingAllowed : true;
  autoResizeMode : AUTO_RESIZE_OFF;
  selectionMode : MULTIPLE_OBJECTS_SELECTION;
  fixedColumnCount: 1;
}

// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Table Controller configuration
// Type: Interactor
//
// The Table Controller provides two different
// interactors for the table. The first one handles
// view events and is configured using property
// viewInteractor. The second one can handle events
// in the table header and is configured using 
// property headerInteractor.
//
// You can override the default interactors and 
// customize the new interactors to define actions 
// associated to gestures or keystrokes. It is 
// also possible to configure a pop-up menu factory. 
// All these properties are customized using the 
// bean support provided by the CSS customization
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Interactor {
  headerInteractor: @=headerInt;
  viewInteractor: @=viewInt;
}

#headerInt {
  class: 'ilog.cpl.table.interactor.IlpDefaultTableHeaderInteractor';
  popupMenuFactory: @=headerPopupMenuFactory;
}

#headerPopupMenuFactory {
  class: 'ilog.cpl.table.IlpDefaultTableHeaderMenuFactory';
}

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

#viewPopupMenuFactory {
  class: 'styling.AlarmPopupMenuFactory';
}

#viewAction0 {
  class: 'ilog.cpl.interactor.IlpGestureAction';
  gesture: BUTTON1_DOUBLE_CLICKED;
  action: @=showDetailsAction;
}

#showDetailsAction {
  class: 'styling.ShowDetailsAction';
}

// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Style Sheet configuration
// Type: StyleSheet
// 
// The following list shows all possible properties for
// the style sheet
//
// List of available properties:
// - styleSheetDebugMask: int
// - funtionList: String
//
// Example:
// StyleSheet {
//    styleSheetDebugMask: "DECL_MASK|DECL_VALUE_MASK|FAILED_CONVERSIONS_MASK";
//    functionList: "MediaMapFunction, MediaColorFunction";
// }
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Table header configuration
// Type: attribute
// CSS Classes: business class/attribute
//
// List of available declarations:
// - visible : boolean
// - preferredWidth : int
// - index : int
// - labelVisible : boolean
// - label : String
// - labelFont : Font
// - labelPosition : IlvDirection
// - labelSpacing : int
// - labelInsets : int
// - foreground : Color
// - background : Color
// - iconVisible : boolean
// - icon : Image
// - horizontalAlignment : { Center; Left; Right }
// - verticalAlignment : { Center; Top; Bottom }
// - toolTipText : String
// - sortingMode : IlpSortingMode
// - sortingPriority : int
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

attribute."Alarm/identifier" {
  label: '@|resource("SampleMessages", "label.alarm.identifier")';
  toolTipText: '@|resource("SampleMessages", "desc.alarm.identifier")';
  preferredWidth: 200;
  horizontalAlignment: Center;
  iconVisible: false;
}
attribute."Alarm/creationTime" {
  label: '@|resource("SampleMessages", "label.alarm.creationTime")';
  toolTipText: '@|resource("SampleMessages", "desc.alarm.creationTime")';
  preferredWidth: 250;
  sortingMode: DESCENDING;
}
attribute."Alarm/perceivedSeverity" {
  label: '@|resource("SampleMessages", "label.alarm.perceivedSeverity")';
  toolTipText: '@|resource("SampleMessages", "desc.alarm.perceivedSeverity")';
  preferredWidth: 100;
}
attribute."Alarm/acknowledged" {
  label: '@|resource("SampleMessages", "label.alarm.acknowledged")';
  toolTipText: '@|resource("SampleMessages", "desc.alarm.acknowledged")';
  preferredWidth: 30;
}
attribute."Element/throughput" {
  label: '@|resource("SampleMessages", "label.element.throughput")';
  toolTipText: '@|resource("SampleMessages", "tooltip.element.throughput")';
  preferredWidth: 80;
}
// Hide element type column
attribute."Element/type" {
  visible: false;
}
// Change default order of columns, set name attribute first
attribute."ilog.tgo.model.IltObject/name" {
  index : 0;
  preferredWidth : 130;
}
// Hide column for family attribute
attribute."ilog.tgo.model.IltNetworkElement/family" {
  visible : false;
}
// Set column width
attribute."ilog.tgo.model.IltNetworkElement/type" {
  preferredWidth : 100;
}

// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Accepted class configuration
// Type: object
// CSS Classes: business class
//
// List of available declarations:
// - tableColumnOrder: String
// - tableRowHeight: int
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

object."Alarm" {
  tableColumnOrder: "identifier, creationTime, acknowledged, perceivedSeverity";
  tableRowHeight: 25;
}
object."Element" {
  tableColumnOrder: "name, graphicRepresentation, throughput, function, family";
}

object."ilog.tgo.model.IltLink/media" {
  iconVisible: true;
  labelVisible: false;
}

// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Table cell configuration
// Type: object
// CSS Classes: business class/attribute
// Pseudoclasses: :selected and :focus
//
// Please refer to the User's Manual for a complete list 
// of properties.
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

// Highlight name attribute if it is selected or has focus
object."ilog.tgo.model.IltObject/name":selected {
  labelForeground: red;
}
object."ilog.tgo.model.IltObject/name":focus {
  labelForeground: blue;
}
object."ilog.tgo.model.IltObject/name" {
  labelForeground: black;
}

// Define horizontal alignment
object."Element/throughput" {
  horizontalAlignment: Center;
}

// Auxiliary maps which associate the perceived severity
// attribute with colors and text
#perceivedSeverityBackgroundMap {
  class: 'ilog.cpl.util.IlpOrderedValueMap';
  keyClass: 'java.lang.Integer';
  valueClass: 'java.awt.Color';
  keys: "0, 1, 2, 3, 4, 5";
  values: "#FFFFFF, #C0C0C0, #FFCC00, #FFB200, #FF0000, #FF0000";
}

#perceivedSeveritySelectionBackgroundMap {
  class: 'ilog.cpl.util.IlpOrderedValueMap';
  keyClass: 'java.lang.Integer';
  valueClass: 'java.awt.Color';
  keys: "0, 1, 2, 3, 4, 5";
  values: "null, #DBDBDB, #FFFF99, #FFCC66, #FF9999, #FF9999";
}

#perceivedSeverityLabelMap {
  class: 'ilog.cpl.util.IlpIndexedValueMap';
  keyClass: 'java.lang.Integer';
  valueClass: 'java.lang.String';
  keys[0]: 0;
  keys[1]: 1;
  keys[2]: 2;
  keys[3]: 3;
  keys[4]: 4;
  keys[5]: 5;
  values[0]: '@|resource("SampleMessages", "label.alarm.perceivedSeverity.cleared")';
  values[1]: '@|resource("SampleMessages", "label.alarm.perceivedSeverity.indeterminate")';
  values[2]: '@|resource("SampleMessages", "label.alarm.perceivedSeverity.warning")';
  values[3]: '@|resource("SampleMessages", "label.alarm.perceivedSeverity.minor")';
  values[4]: '@|resource("SampleMessages", "label.alarm.perceivedSeverity.major")';
  values[5]: '@|resource("SampleMessages", "label.alarm.perceivedSeverity.critical")';
}

#perceivedSeverityImageMap {
  class: 'ilog.cpl.util.IlpOrderedValueMap';
  keyClass: 'java.lang.Integer';
  valueClass: 'java.awt.Image';
  keys: "0, 1, 2, 3, 4, 5";
  values: "cleared.png, indeterminate.png, warning.png, minor.png, major.png, critical.png";
}

// Auxiliary values for date format
#labelDateFormat {
  class: 'ilog.cpl.util.text.IlpSimpleDateFormat';
  pattern: '@|resource("SampleMessages", "label.pattern.alarm.creationTime")';
}
#toolTipDateFormat {
  class: 'ilog.cpl.util.text.IlpSimpleDateFormat';
  pattern: '@|resource("SampleMessages", "tooltip.pattern.alarm.creationTime")';
}

// Configuring all table columns to change its background according to the
// perceivedSeverity attribute
object."Alarm/*"[perceivedSeverity] {
  labelBackground: '@|valuemap(@=perceivedSeverityBackgroundMap, @perceivedSeverity)';
}
object."Alarm/*"[perceivedSeverity]:selected {
  labelBackground: '@|valuemap(@=perceivedSeveritySelectionBackgroundMap, @perceivedSeverity)';
}

// Configuring perceived severity to change its color and label according to 
// the severity value.
object."Alarm/perceivedSeverity" {
  label: '@|valuemap(@=perceivedSeverityLabelMap, @perceivedSeverity)';
  toolTipText: '@|valuemap(@=perceivedSeverityLabelMap, @perceivedSeverity)+" "+@|resource("SampleMessages", "label.alarm")';
}

// Configuring identifier to change its color according to the alarm severity.
object."Alarm/identifier" {
  label: @identifier;
  labelSpacing: 10;
  toolTipText: @identifier;
  iconVisible: true;
  icon: '@|valuemap(@=perceivedSeverityImageMap, @perceivedSeverity)';
}

// Configuring creationTime to change its color according to the alarm severity.
object."Alarm/creationTime" {
  label: '@|format(@=labelDateFormat, @creationTime)';
  toolTipText: '@|format(@=toolTipDateFormat, @creationTime)';
}

// Configuring acknowledged to change its color according to the alarm severity
// and to have an icon according to its state
object."Alarm/acknowledged" {
  labelVisible: false;
  icon: '@|image("ilog/tgo/check.png")';
  horizontalAlignment: CENTER;
}
object."Alarm/acknowledged"[acknowledged=true] {
  iconVisible: true;
  toolTipText: '@|resource("SampleMessages", "label.alarm.acknowledgedState")';
}
object."Alarm/acknowledged"[acknowledged=false] {
  iconVisible: false;
  toolTipText: '@|resource("SampleMessages", "label.alarm.unacknowledgedState")';
}