ilog.views.sdm.swing
Class IlvSDMTableMediator

java.lang.Object
  extended by ilog.views.sdm.swing.IlvSDMTableMediator
All Implemented Interfaces:
ManagerSelectionListener, EventListener, ListSelectionListener

public class IlvSDMTableMediator
extends Object
implements ManagerSelectionListener, ListSelectionListener

This class lets you connect a Swing JTable to an SDM engine. The SDM data model is connected to the JTable using an IlvSDMTableModel adapter. The mediator also handles the synchronization of the selections between the ILOG JViews grapher and the JTable.

To connect a JTable to an SDM engine, create a table mediator as follows:

   IlvSDMEngine engine = ...;
   JTable table = new JTable();
   IlvSDMTableMediator mediator =
         new IlvSDMTableMediator(engine, table, null);
 

You can filter the objects and the properties that are displayed in the table. For this, you must write style rules in the style sheet using the pseudo-class "table", and set the properties "visible" and "properties".

For example, the following rule specifies that the objects of tag "join" are not displayed in the table:

 node.join:table {
     visible : false;
 }
 

The following rule specifies that only the properties "name" and "implementation" of activity objects are displayed in the table:

 node.activity:table {
     properties : "name,implementation";
 }
 

Optionally, you can also customize the colors of the table cells. This customization is not enabled by default, for performance reasons. To enable it, you must first call setUsingStyleSheetRenderer(true) on the table mediator. Then you can write style rules using the pseudo-class "table", and set the properties "foreground" and "background", as in the following example:

 node.join:table {
     foreground : "yellow";
     background : "red";
 }
 

Since:
JViews 4.0

Field Summary
static String tableClass
          The pseudo-class used to customize the colors of table cells.
 
Constructor Summary
IlvSDMTableMediator(IlvSDMEngine engine, JTable table, String tag)
          Creates a new SDM table mediator, which connects an SDM engine with a Swing JTable.
 
Method Summary
 IlvSDMEngine getSDMEngine()
          Returns the SDM engine connected to the JTable.
 JTable getTable()
          Returns the JTable connected to the SDM engine.
 IlvSDMTableModel getTableModel()
          Returns the JTable model.
 boolean isUsingStyleSheetRenderer()
          Returns true if the table cell renderer that reads the colors of the cells from the style sheet is installed, or false otherwise.
 void selectionChanged(ManagerSelectionChangedEvent event)
          Implementation of the ManagerSelectionListener interface.
 void setSDMEngine(IlvSDMEngine engine)
          Sets the SDM engine to connect to the JTable.
 void setTable(JTable table)
          Sets the JTable to connect to the SDM engine.
 void setTableModel(IlvSDMTableModel tableModel)
          Sets the JTable model.
 void setUsingStyleSheetRenderer(boolean yes)
          Installs or uninstalls a table cell renderer that reads the colors of the cells from the style sheet.
 void valueChanged(ListSelectionEvent event)
          Implementation of the javax.swing.event.ListSelectionListener interface.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

tableClass

public static final String tableClass
The pseudo-class used to customize the colors of table cells.

See Also:
Constant Field Values
Constructor Detail

IlvSDMTableMediator

public IlvSDMTableMediator(IlvSDMEngine engine,
                           JTable table,
                           String tag)
Creates a new SDM table mediator, which connects an SDM engine with a Swing JTable.

Parameters:
engine - The SDM engine.
table - The Swing JTable.
tag - The tag of the objects to display, or null to display all the objects.
Method Detail

setSDMEngine

public void setSDMEngine(IlvSDMEngine engine)
Sets the SDM engine to connect to the JTable.

Parameters:
engine - The new SDM engine.

getSDMEngine

public IlvSDMEngine getSDMEngine()
Returns the SDM engine connected to the JTable.


setTable

public void setTable(JTable table)
Sets the JTable to connect to the SDM engine.

Parameters:
table - The new Swing JTable.

getTable

public JTable getTable()
Returns the JTable connected to the SDM engine.


setTableModel

public void setTableModel(IlvSDMTableModel tableModel)
Sets the JTable model.

Parameters:
tableModel - The new model.

getTableModel

public IlvSDMTableModel getTableModel()
Returns the JTable model.


selectionChanged

public void selectionChanged(ManagerSelectionChangedEvent event)
Implementation of the ManagerSelectionListener interface. This method selects the JTable rows corresponding to the graphic objects that are selected in the grapher.

Specified by:
selectionChanged in interface ManagerSelectionListener
Parameters:
event - The event.
See Also:
IlvManager.addManagerSelectionListener(ilog.views.event.ManagerSelectionListener), IlvManager.removeManagerSelectionListener(ilog.views.event.ManagerSelectionListener), IlvManager.addManagerTreeSelectionListener(ilog.views.event.ManagerSelectionListener), IlvManager.removeManagerTreeSelectionListener(ilog.views.event.ManagerSelectionListener), IlvManager.selectionChanged(ilog.views.IlvGraphic)

valueChanged

public void valueChanged(ListSelectionEvent event)
Implementation of the javax.swing.event.ListSelectionListener interface. This method selects the graphic objects corresponding to the selected rows in the JTable.

Specified by:
valueChanged in interface ListSelectionListener
Parameters:
event - The event.

setUsingStyleSheetRenderer

public void setUsingStyleSheetRenderer(boolean yes)
Installs or uninstalls a table cell renderer that reads the colors of the cells from the style sheet.

Parameters:
yes - If true, the style sheet cell renderer is installed; otherwise it is uninstalled and the default table cell renderer is used.

isUsingStyleSheetRenderer

public boolean isUsingStyleSheetRenderer()
Returns true if the table cell renderer that reads the colors of the cells from the style sheet is installed, or false otherwise.



Copyright © 1996-2007 ILOG S.A. All rights reserved.   Documentation homepage.