skip to main content
Programmers documentation > Graphic components > Table component > Table component services
 
Table component services
Describes the services that are available for a table: view services and adapter services.
*Introduction to table component services
*Lists the different services available for a table.
*Selecting the accepted class of objects
*Describes how to set the accepted class, which allows you to define the class of objects to be displayed in the table component.
*Filling the table with business objects
*Describes how to populate a table with business objects.
*Interacting with the table view
*Describes how to use interactors to associate the behavior of the table with specific actions.
*Interacting with the table cells
*Describes how to use object interactors to associate behavior with business objects.
*Handling the selection
*Describes how to set different kinds of selection models to the table.
*Fitting to Contents
*Explains how to set a table to dynamically adjust the width of columns to fit in the available space.
*Resizing columns
*Explains how to resize a column using the API.
*Fixing columns in a table
*Describes how to fix a set of columns on the left side of a table.
*Moving columns
*Describes how to rearrange columns using the API.
*Searching for a string in a table
*Explains how to search for a string in a table using the API.
*Showing or hiding columns in a table
*Explains how to show or hide columns in a table using the API.
*Sorting columns
*Explains how to sort columns using the API.
*Adding new columns to the table
*Describes how to add new columns using the API.
*Filtering rows
*Describes how to filter the rows in a table using the API.
*Excluding table rows
*Describes how to exclude business objects from the table using the API.
*Editing table cells
*Explains how to make the cells of an IlpTable editable.
Introduction to table component services
Table component services are of two kinds:
*View services, related to the table view
*Selecting the accepted class of objects
*Filling the table with business objects
*Interacting with the table view
*Interacting with the table cells
*Handling the selection
*Fitting to Contents
*Resizing columns
*Fixing columns in a table
*Moving columns
*Searching for a string in a table
*Showing or hiding columns in a table
*Sorting columns
*Adding new columns to the table
*Adapter services, related to the table model
*Filtering rows
*Excluding table rows
Selecting the accepted class of objects
The accepted class allows you to define the class of objects to be displayed in the table component. The table can display predefined business objects of the class IltObject or of a subclass of IltObject, or user-defined business classes.
You need to specify the accepted class when you create your table component. Once the accepted class has been set, the attributes present in this class determine the columns that will be displayed in the table.
How to set the accepted class
 
// Create a table component and connect it to a data source
IlpTable tableComponent = new IlpTable();
IltDefaultDataSource dataSource = new IltDefaultDataSource();
// The second parameter specifies which kind of object contained
// in the data source the table will show
tableComponent.setDataSource(dataSource, IltNetworkElement.GetIlpClass());
or, after connecting the table with a data source, by using the method setAcceptedClass :
 
tableComponent.setAcceptedClass(IltObject.GetIlpClass());
Filling the table with business objects
The table can be filled with business objects through an IltDefaultDataSource, as illustrated by the following code.
How to fill a table with business objects
 
// Create a table component and connect it to a data source
IlpTable tableComponent = new IlpTable();
IltDefaultDataSource dataSource = new IltDefaultDataSource();
// The second parameter specifies which kind of object contained
// in the data source the table will show
tableComponent.setDataSource(dataSource, IltNetworkElement.GetIlpClass());
 
// Create a business object and insert it in the data source
IltObjectState os = new IltBellcoreObjectState();
os.set(IltBellcore.State.EnabledActive);
IltNetworkElement london =
  new IltNetworkElement("Fax", IltNetworkElement.Type.Fax, os);
dataSource.addObject(london);
Note that a data source can also load an XML file containing business objects, as shown in Creating a table component: a sample.
You can also use project files to easily create and load data source business objects into your table component, as illustrated below:
How to fill a table with business objects using a project file
You can create the following project file to indicate the type of data source to be used and the XML file that contains the data source information:
 
<?xml version="1.0"?>
<tgo xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation = "ilog/cpl/schema/project.xsd">
  <datasource javaClass="ilog.tgo.datasource.IltDefaultDataSource"
fileName="network.xml"/>
</tgo>
Once the project file is specified, you can load it in the component using method IlpTable.setProject(URL projectURL) or IlpTable.setProject(IlpProject project). See Loading a project file for details.
Interacting with the table view
The table component allows you to define behavior for the main view of the table, as well as specific behavior for the table header. In both cases, an interactor is used. The default interactors handle the basic interaction supported by the table (selection, moving columns, for example) and can be easily customized to:
*associate actions with mouse events and focus events,
*associate actions with keyboard events,
*build a pop-up menu to be displayed on the table.
Interacting with the main table view
A default view interactor (an instance of IlpDefaultTableViewInteractor) is associated with the main view of the table component. It is retrieved using the getViewInteractor method of IlpTable.
How to associate an action with a gesture in a table component
You can associate actions with mouse events by using either CSS or the API. The following CSS extract shows how to proceed:
 
Table {
  interactor: true;
}
 
Interactor {
  viewInteractor: @+viewInt;
}
 
Subobject#viewInt {
  class: 'ilog.cpl.table.interactor.IlpDefaultTableViewInteractor';
  action[0]: @+viewAction0;
}
 
Subobject#viewAction0 {
  class: 'ilog.cpl.interactor.IlpGestureAction';
  gesture: BUTTON1_DOUBLE_CLICKED;
  action: @+myAction;
}
Subobject#myAction {
  class: MyAction;
}
The same configuration can be achieved through the API, as follows:
 
// Create the table, and retrieve the view interactor
IlpTable tableComponent = new IlpTable()
IlpViewInteractor viewInteractor = tableComponent.getViewInteractor();
// Create a Swing action
// We assume the MyAction class is defined elsewhere
Action myAction = new MyAction();
// Double-clicking the left mouse button will trigger myAction
viewInteractor.setGestureAction(IlpGesture.BUTTON1_DOUBLE_CLICKED,
                         myAction);
.
NOTE A gesture is a series of one or more atomic user input events that are meant to invoke a single action.
How to associate an action with a keyboard event in a table component
You can associate actions with keyboard events by using either CSS or the API. The following CSS extract shows how to proceed:
 
Table {
  interactor: true;
}
 
Interactor {
  viewInteractor: @+viewInt;
}
 
Subobject#viewInt {
  class: 'ilog.cpl.table.interactor.IlpDefaultTableViewInteractor';
  action[0]: @+viewAction0;
}
 
Subobject#viewAction0 {
  class: 'ilog.cpl.interactor.IlpKeyStrokeAction';
  keyStroke: 'ctrl typed D';
  action: @+myAction;
}
 
Subobject#myAction {
  class: MyAction;
}
The same configuration can be achieved through the API, as follows:
 
// Create an action
Action myAction = new MyAction();
// Typing CTRL+D will trigger myAction
KeyStroke ctrlD = KeyStroke.getKeyStroke('D',java.awt.Event.CTRL_MASK);
viewInteractor.setKeyStrokeAction(ctrlD, myAction);
Both mouse and keyboard actions can be invoked anywhere in the table, except in the header.
Interacting with the table header
Usually, specific behavior is needed for the table header. For that reason, the table component also has a default interactor for the header. It is an instance of IlpDefaultTableHeaderInteractor and can be retrieved using the getHeaderInteractor method of IlpTable. This interactor can be customized in the same way as the interactor for the main view.
NOTE If no header interactor is set to the table controller (that it, if it is null), the events are handled directly by the view interactor.
Using pop-up menus
The JViews TGO interactors allow you to create custom pop-up menus easily for the table. To do this, you should implement the IlpPopupMenuFactory interface. One abstract and two default menu factories are provided, which you can extend by subclassing:
*IlpAbstractPopupMenuFactory gives you easy access to the currently selected business objects.
*IlpDefaultTableHeaderMenuFactory allows you to show or hide a column and change the sorting criterion of a column.
*IlpDefaultTableMenuFactory allows you to fix columns and show the hidden columns.
The following code shows how to define a custom pop-up menu factory for the table view.
How to define a custom pop-up menu for the table view
You can customize a pop-up menu factory for the table view or the table header, either through CSS or through the API. The following CSS extract shows how to configure a CSS file to add a pop-up menu factory:
 
Table {
  interactor: true;
}
 
Interactor {
  viewInteractor: @+viewInt;
}
 
Subobject#viewInt {
  class: 'ilog.cpl.table.interactor.IlpDefaultTableViewInteractor';
  popupMenuFactory: @+viewPopupMenuFactory;
}
Subobject#viewPopupMenuFactory {
  class: MyTableMenuFactory;
}
The same configuration can be achieved through the API, as follows:
1. Create a class extending IlpAbstractPopupMenuFactory as follows:
 
public MyTableMenuFactory extends IlpAbstractPopupMenuFactory
{
  public JPopupMenu createPopupMenu
    (IlpObjectSelectionModel ilpSelectionModel)
  {
  // The following menu could be context-dependent
  JPopupMenu popupMenu = new JPopupMenu();
  // Create here the items and add them in the menu
  // ....
  return popupMenu;
  }
}
2. Use a pop-up menu in the table view or header:
 
IlpTable tableComponent = new IlpTable();
// Use a custom pop-up menu in the table view
IlpPopupMenuFactory tableMenuFactory = new MyTableMenuFactory();
tableComponent.getViewInteractor().setPopupMenuFactory(tableMenuFactory);
// Use the default header pop-up menu in the table header
IlpPopupMenuFactory headerMenu =
  new IlpDefaultTableHeaderMenuFactory();
tableComponent.getHeaderInteractor().setPopupMenuFactory(headerMenu);
For a detailed description of interactors and gestures, refer to Interacting with the graphic components.
Interacting with the table cells
The topic Interacting with the table view describes how to set an interactor for the entire table view. You can also associate behavior with business objects (for a class or for individual objects), as well as with individual table cell instances. To do so, you use object interactors, which provide the same options as the view interactor, that is:
*Associating actions with mouse events
*Associating actions with keyboard events
*Defining a pop-up menu factory to build a pop-up menu that displays on representation objects
The object interactor handles any events occurring on the object with which the interactor is associated, provided the view interactor has enabled the use of object interactors. You can check this by means of the isUsingObjectInteractor method or modify it with the setUsingObjectInteractor method. Object interactors are enabled by default.
No default interactor is associated with any object. To associate actions with mouse or keyboard events or to define a pop-up menu factory, you first have to create an IlpObjectInteractor. You may use the IlpDefaultObjectInteractor, extend it, or create your own implementation.
How to associate an object interactor with a representation object in the table
You can associate an object interactor with a representation object by using either CSS or the API. The following CSS extract shows how to proceed:
 
Table {
  interactor: true;
}
 
object."ilog.tgo.model.IltNetworkElement" {
  interactor: @+objInteractor;
}
Subobject#objInteractor {
  class: 'ilog.cpl.interactor.IlpDefaultObjectInteractor';
}
The same configuration can be achieved through the API, as follows:
 
IlpTable table = // ...
IltNetworkElement ne = //...
IlpTableController tableController = table.getController();
// Create an object interactor
IlpObjectInteractor objectInteractor = new IlpDefaultObjectInteractor();
tableController.setObjectInteractor(ne, objectInteractor);
// Configuring the specific object interactor is similar to configuring
// a view interactor.
objectInteractor.setGestureAction(IlpGesture.BUTTON3_CLICKED, new MyAction());
How to associate an object interactor with a table cell
You can associate an object interactor with a table cell, which is identified by a representation object and an attribute, by using either CSS or the API. The following CSS extract shows how to customize a specific object interactor to the cell that represents the name attribute:
 
Table {
   interactor: true;
}
object."ilog.tgo.model.IltNetworkElement/name" {
   interactor: @+objInteractor;
}
Subobject#objInteractor {
   class: 'ilog.cpl.interactor.IlpDefaultObjectInteractor';
}
The same configuration can be achieved through the API, as follows:
 
IlpTable table = // ...
IltNetworkElement ne = //...
IlpAttribute attribute = IltNetworkElement.NameAttribute;
IlpTableController tableController = table.getController();
// Create an object interactor
IlpObjectInteractor objectInteractor = new IlpDefaultObjectInteractor();
tableController.setObjectInteractor( ne, attribute, objectInteractor);
Actions related to mouse and keyboard events can be customized in the same way as for the view interactor. A pop-up menu factory can also be defined in the same way as for the view interactor. Refer to Interacting with the table view.
For a detailed description of interactors and gestures, refer to Interacting with the graphic components.
Handling the selection
Selection in the table view is managed by an IlpTableSelectionModel. Different kinds of selection models can be set to the table by using the method setSelectionModel of the table view. However, only the IlpDefaultTableSelectionModel allows you to use the method setSelectionMode, as illustrated in the following code sample.
How to handle selection in the table
 
IlpTable tableComponent = new IlpTable();
// Set a selection mode to select multiple entire rows
tableComponent.setSelectionMode(IlpTableSelectionMode.
  MULTIPLE_OBJECTS_SELECTION);
The different selection modes, defined by the enumerated type IlpTableSelectionMode, are the following:
*EMPTY_SELECTION: nothing is selected when clicking the table.
*SINGLE_OBJECT_SELECTION: a single row can be selected in the table.
*MULTIPLE_OBJECTS_SELECTION: multiple rows can be selected (by using the traditional Shift and/or Control keys and dragging the mouse).
*SINGLE_ATTRIBUTE_SELECTION: a single column can be selected.
*MULTIPLE_ATTRIBUTES_SELECTION: multiple columns can be selected.
*SINGLE_CELL_SELECTION: a single cell can be selected.
*MULTIPLE_CELLS_SELECTION: multiple cells can be selected.
NOTE The selection mode can also be customized through the selectionMode property. The default mode is MULTIPLE_OBJECTS_SELECTION.
The following methods can be used to select business objects:
*addSelectionObject(IlpObject object) adds a business object to the selection (the entire row is selected).
*removeSelectionObject(IlpObject object) removes a business object from the selection.
*getSelectedObjects() returns the collection of selected business objects.
*getSelectedObject() returns the first selected business object (the first in the collection of business objects.)
*isObjectSelected(IlpObject object) returns true if the given selected object is selected.
*clearSelection() deselects all the selected objets.
*selectAll() selects all the visible cells (this means that filtered objects and hidden columns are not selected.)
Similar methods exist in IlpTableSelectionModel to select individual columns and cells.
Fitting to Contents
The table can dynamically adjust the width of one or more of its columns in order to fit in the available space. The table supports the following resizing modes defined in the enumerated type IlpTableResizeMode:
*No adjustment: AUTO_RESIZE_OFF
The width of the columns is never automatically adjusted. If there is more space than used by the columns, it remains empty. If there is less space than required, a horizontal scroll bar displays.
*Adjust last column: AUTO_RESIZE_LAST_COLUMN
The last column of the table will be adjusted to allow the width of the table to fit the available space.
*Proportionally adjust all columns: AUTO_RESIZE_ALL_COLUMNS
All columns will be proportionally shrunk or expanded to occupy the available space.
NOTE >> Unlike what happens in the Swing JTable when the resizing mode is AUTO_RESIZE_LAST_COLUMN and when the entire table is resized, not all the columns are proportionally adjusted. Only the last column is adjusted.
The default resize mode is AUTO_RESIZE_OFF.
The following example applies the AUTO_RESIZE_LAST_COLUMN mode to tableComponent.
How to resize a table
 
IlpTable tableComponent = new IlpTable();
// Apply the policy
tableComponent.setAutoResizeMode
  (IlpTableResizeMode.AUTO_RESIZE_LAST_COLUMN) ;
// Now, when a column or the entire table is resized, only the last column
//is shrunk or expanded
NOTE The resize mode can also be controlled through the autoResizeMode property.
Resizing columns
The user can dynamically resize the columns in a table by dragging the right border of their header.
To resize a column by programming, use the following code, setting a size of 10 to the name column.
How to resize columns in a table
 
IlpTable tableComponent = new IlpTable();
// This table will contain Network Elements
IlpClass acceptedClass = IltNetworkElement.GetIlpClass();
tableComponent.setAcceptedClass(acceptedClass);
...
// Retrieve the IlpAttribute corresponding to the name in
// IltNetworkElement class
IlpAttribute name = acceptedClass.getAttribute("name");
TableComponent.getTableColumn(name).setPreferredSize(10);
NOTE The preferred width of a column can also be controlled through the preferredWidth property. For more information, see Customizing column headers and rows.
Fixing columns in a table
You can fix a set of columns on the left side of the table. To do so, call the method setFixedColumnCount with the number of columns you want to fix as its parameter. The method has no effect if the value of its parameter is less than 0. A value of 0 indicates that none of the columns in the table will be fixed. If the parameter is greater than the number of columns in the table, all the columns are fixed. Here is an example.
How to fix the position of columns in a table
 
IlpTable tableComponent = new IlpTable();
...
// Fix 3 columns
tableComponent.setFixedColumnCount(3) ;
// Fix a 4th column
tableComponent.setFixedColumnCount(4) ;
// Unfix all columns
tableComponent.setFixedColumnCount(0) ;
You can retrieve the number of fixed columns in the table by using the method getFixedColumnCount, and know whether a given column is fixed by using the method isColumnFixed.
The number of fixed columns can be configured using style sheets, as described in Configuring the table component.
Moving columns
The user can dynamically rearrange the columns in a table by dragging their header to a new location. This functionality can be disabled and enabled with the method setReorderingAllowed of the class IlpTable.
To rearrange the columns by programming, use the following code.
How to rearrange columns in a table
 
IlpTable tableComponent = new IlpTable();
// This table will contain Network Elements
IlpClass acceptedClass = IltNetworkElement.GetIlpClass();
tableComponent.setAcceptedClass(acceptedClass);
...
// Retrieve the IlpAttribute corresponding to the name in
// IltNetworkElement class
IlpAttribute name = acceptedClass.getAttribute("name");
// Column "name" will take the second position
tableComponent.setColumnIndex(name,1);
The default order of columns for a business class can also be controlled through the tableColumnOrder property. For more information, see Customizing table column headers and rows.
Searching for a string in a table
You can search for a string in a table by using the searchValue method. Searching is performed on the values displayed in the cells (that is, with styles applied), not on the raw values stored by the representation objects. The searchValue method returns the coordinates of the first cell containing the string, starting from the specified cell.
If the startingcell parameter is null, the search starts from the first cell in the table.
The search is not case sensitive if the parameter caseMatching is false.
The search can be performed row by row ( scanRowByRow parameter is true ), or column by column ( scanRowByRow parameter is false ).
The method returns null if the search value cannot be found in the scope of the search.
How to search for a string in a table
 
IlpTable tableComponent = new IlpTable();
...
IlpCellCoordinates cellFound
   = tableComponent.searchValue("a string", // searched string
                                null, // starting cell
                                false, // scan row by row
                                false); // case matching
Showing or hiding columns in a table
You can alternatively hide and show columns in a table by using the method setColumnVisible. This method takes as its parameters the IlpAttribute object of the affected column and a Boolean value setting the visibility to true or false. The attribute can be retrieved from the table model or from the table view using the method getColumn.
How to show or hide columns in a table
The following example shows how to show and hide columns in a table.
 
IlpTable tableComponent = new IlpTable();
// This table will contain Network Elements
IlpClass acceptedClass = IltNetworkElement.GetIlpClass();
tableComponent.setAcceptedClass(acceptedClass);
...
// Retrieve the IlpAttribute corresponding to the name in
// IltNetworkElement class
IlpAttribute nameAttr = acceptedClass. getAttribute("name");
// Hide the column
tableComponent.setColumnVisible(nameAttr, false) ;
// Show the column again
tableComponent.setColumnVisible(nameAttr, true) ;
The method isColumnVisible indicates whether the column specified by attribute is visible.
NOTE The visibility of a column can also be controlled through the visible property. For more information, see Customizing column headers and rows.
Sorting columns
Columns can be sorted in ascending or descending order, interactively or by programming.
Interactively, the user clicks a column header once to sort it in ascending order, twice to sort it in descending order, and three times for no sorting at all. Using the Shift key while clicking the column header adds this column as a sorting criterion, whereas otherwise the column is set as the only sorting criterion.
By programming, you can use the following methods:
*addSortingCriteriaaddSortingCriteria adds the given attribute as a sorting criterion. This method takes as its arguments:
*the attribute corresponding to the column to be sorted
*an order parameter that defines the position of the column among the sorting criteria
*the ascendingOrder parameter, which, when set to true, sorts the column in ascending order
*the parameter useDisplayValue, which indicates whether the sorting is applied to the display values (that is, with style sheets applied) or to the raw values
Each sorted column serves as a sorting criterion. If order equals 1, the column is selected as the first sorting criterion, if it equals 2, it is selected as the second sorting criterion, and so on. If order is less than 1, the column is considered as the first criterion. If order is greater than the current number of criteria, the column is considered as the next criterion.
*getSortingOrder returns the position as a sorting criterion of the specified attribute.
*isUsingAscendingOrder returns true if the specified attribute is sorted in ascending order.
*isUsingDisplayValue returns true if the specified attribute is sorted by display values.
*removeAllSortingCriteria removes all sorting criteria.
*getSortedAttributesCount returns the number of sorted columns in the table.
NOTE The sorting order can also be controlled through the " sortingMode " and " sortingPriority " properties. For more information, see Customizing column headers and rows.
Adding new columns to the table
It is possible to add custom attributes as new columns in a table component, as illustrated by the following code sample.
How to add columns to a table
 
// Create a datasource
IltDefaultDataSource dataSource = new IltDefaultDataSource();
// Read an XML file into the datasource
dataSource.parse("alarms.xml");
// Create a table component
IlpTable tableComponent = new IlpTable();
// Get the Alarm class
IlpClass alarmClass =
  IltSystem.GetDefaultContext().getClassManager().getClass("Alarm");
// Set the datasource to the component, and show instances
// of the Alarm class
tableComponent.setDataSource(dataSource, alarmClass);
// Add custom attributes
// Get the existing severity attribute
IlpAttribute severity = alarmClass.getAttribute("perceivedSeverity");
// Create a 'Short severity' attribute that represents the severity
// in a concise way
IlpAttribute shortSeverityAttribute =
  new IlpReferenceAttribute("shortSeverity", severity);
tableComponent.addAttribute(shortSeverityAttribute);
Filtering rows
You can filter the rows in a table by implementing the interface IlpFilter and setting it to the table.
To perform the filtering, you can use the method setFilter at two different levels:
At the adapter level
You have the choice to apply the filter to the table component or to the adapter, the result will be the same.
The following code shows how to create a filter displaying only IltNetworkElement instances with alarms.
How to set a filter to the table component
 
// Create a table component and set it to a data source
IlpTable tableComponent = new IlpTable();
IltDefaultDataSource dataSource = new IltDefaultDataSource();
// The second parameter specifies which kind of object contained
// in the data source the table will show
tableComponent.setDataSource(dataSource,
  IltNetworkElement.GetIlpClass());
IlpFilter alarmFilter = new IlpFilter() {
  public boolean accept(Object object) {
    IlpObject ilpObject = (IlpObject)object;
    Integer alarmCount =
      (Integer)ilpObject.getAttributeValue(IltObject.AlarmCountAttribute);
    return (alarmCount.intValue() > 0);
   }
};
tableComponent.setFilter(alarmFilter);
The following example shows how to set a filter to an adapter.
How to set a filter to the adapter
 
adapter.setFilter(new IlpFilter() {
  public boolean accept(Object object) {
   IlpObject bo = (IlpObject)object;
   return bo.getAttributeValue(boolAtt).equals(Boolean.TRUE);
  }
});
The argument boolAtt passed to the method getAttributeValue is an instance of IlpAttribute that returns a Boolean value. Business objects will be transformed into representation objects only if this argument is true.
At the controller level.
Filtering takes places between the model and the view and is performed by the controller.
How to set a filter to the table controller
 
IlpTableController controller = table.getController();
controller.setFilter(new IlpFilter() {
  public boolean accept(Object object) {
    IlpObject bo = (IlpObject)object;
    return bo.getAttributeValue(boolAtt).equals(Boolean.TRUE);
  }
});
The setFilter method at the adapter level may seem redundant with the setFilter method at the controller level; however, the advantages and drawbacks are not the same. Modifying the filter associated with an adapter to which a number of representation objects have already been added causes a large number of objects to be created or destroyed. Whereas changing a filter set to the controller only alters intermediate data, without leading to object creation or destruction. Setting a filter to an adapter significantly improves the performance, since it avoids creating a great number of unused representation objects, and saves storage space in the memory of the model.
The most likely scenario for using the setFilter method at two different levels is the following: The setFilter method at the adapter level can be considered the first step in the filtering process in the sense that it reduces the number of objects of the accepted class that will be created and displayed. The next step consists in setting a filter at the controller level to further reduce the number of objects that will be actually displayed in the table component.
Excluding table rows
You can specify the business objects that will not be represented in the table component depending on their business classes. To do so, you need to specify the business classes to be excluded using method setExcludedClasses in the table component adapter. To retrieve the adapter, use the getAdapter method. The adapter must be an instance of a subclass of IlpListAdapter.
How to specify excluded classes in the table component
You can specify that business objects from specific business classes are not represented in the table component. You can do that using the API, setExcludedClasses method, or using CSS.
The following example shows you how to prevent objects from business classes IltAlarm and IltLed to be represented:
 
Adapter {
  excludedClasses[0]: "ilog.tgo.model.IltAlarm";
  excludedClasses[1]: "ilog.tgo.model.IltLed";
}
NOTE The filtering that is performed through the use of the excluded class list takes actually place at the adapter level.
To see how to configure excluded classes through CSS, refer to The Adapter rule.
Editing table cells
You can configure a JViews TGO table component to support cell editing. The configuration consists in defining specific cell editors (javax.swing.CellEditor) for the JViews TGO business attributes (IlpAttribute) to be edited. The Table model (IlpTableModel) must be extended to indicate which cells are editable, and the Table view (IlpTableView) must be extended to indicate the cell editors to be used for a given TGO attribute.
To configure the table component for cell editing:
1. Define and implement the cell editors for the attributes you want to edit.
public class NameAttributeEditor extends DefaultCellEditor {
  // Keep reference to Table view
  private IlpTableView _view;
  // Constructor initializing the editor as a text field
  public NameAttributeEditor(IlpTableView view) {
    super(new JTextField());
    _view = view;
  }
  // Set attribute when ending editing
  @Override
  public boolean stopCellEditing() {
    if (super.stopCellEditing()) {
      // Retrieve the object being edited
      IlpObject object = view.getSelectionModel().getSelectedObject();
      // Update the Name attribute accordingly
      object.setAttributeValue(IltObject.NameAttribute, getCellEditorValue());
      return true;
    }
    return false;
  }
}
2. Override the method isCellEditable(int,int) in IlpTableListModel to return true for the cells you want to edit.
public class EditableTableListModel extends IlpTableListModel {
  @Override
  public boolean isCellEditable(int rowIndex, int columnIndex) {
    // Indicates that the cell is editable
    return true;
  }
}
3. Override the method getCellEditor(IlpRepresentationObject,IlpAttribute) in IlpTableView to return the appropriate cell editor for the given attribute.
public class EditableTableView extends IlpTableView {
  // Keep reference to the name editor
  private NameAttributeEditor _nameEditor;
 
  // Constructor: Initialize editor
  public EditableTableView() {
    super();
    _nameEditor = new NameAttributeEditor(this);
  }
 
  // Return the name editor when applicable
  @Override
  public TableCellEditor getCellEditor(IlpRepresentationObject o, IlpAttribute a) {
    return (a == IltObject.NameAttribute ? _nameEditor : null);
  }
}
4. Configure IlpTable with the custom Table Model and Table View defined in steps 2 and 3.
After you have defined the table model (EditableTableListModel) and the table view (EditableTableView), you must set them to a table component in order to be able to edit the cells. To do so, you use the methods setModel() and setView(), as follows.
table = new IlpTable();
// Install custom types that allow for the use of table cell editors
table.setModel(new EditableTableListModel());
table.setView(new EditableTableView());
When the application is running, double-clicking the Name Attribute column will activate the NameAttributeEditor.

Copyright © 2018, Rogue Wave Software, Inc. All Rights Reserved.