ilog.cpl.list
Class IlpListAdapter

java.lang.Object
  extended by ilog.cpl.datasource.IlpAbstractAdapter
      extended by ilog.cpl.list.IlpListAdapter
All Implemented Interfaces:
IlpStylable, DataSourceListener, IlpStylableAdapter, IlpRepresentationObjectMapper, IlvStylable, EventListener
Direct Known Subclasses:
IlpTableListAdapter

public abstract class IlpListAdapter
extends IlpAbstractAdapter
implements DataSourceListener, IlpStylableAdapter

This class adapts a data source to a list model. It uses a factory (IlpRepresentationObjectFactory) to convert from the business objects (IlpObject) in the data source to the representation objects (IlpRepresentationObject).

It provides a mechanism to select a specific class of business objects to be adapted, the accepted class, that works with the adapter filter (IlpFilter) in determining which representation objects should be created.

This class is stylable using cascading style sheets. The CSS customization is done using files that are loaded in the method setStyleSheets(java.lang.String[]). Please refer to the properties defined by this adapter class for information about how each property can be customized using cascading style sheets.

Note: Subclasses of this class must set a representation object factory through the method setRepresentationObjectFactory before using the adapter.

Since:
JTGO 3.0

Field Summary
 
Fields inherited from interface ilog.cpl.css.IlpStylable
UPDATE_ALL_MASK, UPDATE_COMPONENT_MASK, UPDATE_NONE_MASK, UPDATE_OBJECTS_MASK
 
Fields inherited from interface ilog.views.util.styling.IlvStylable
APPLIED_RULE_MASK, BAD_CLASS_MASK, BAD_PROP_MASK, BAD_PROP_WITH_STACK_MASK, CREATED_MASK, DECL_MASK, DECL_VALUE_MASK, FAILED_CONVERSIONS_MASK, TIME_REPORT_MASK, WARNING_PROP_MASK
 
Constructor Summary
IlpListAdapter()
          Creates a new list adapter.
IlpListAdapter(IlpContext context)
          Creates a new list adapter.
 
Method Summary
 void addPropertyChangeListener(PropertyChangeListener listener)
          Adds a listener on property modification.
protected  void clearRepresentationObjects()
          Called when all representation objects should be cleared.
protected  IlpStylable createCSSDelegate()
          Creates the stylable object that will be used to customize the adapter.
protected  IlpRepresentationObject createRepresentationObject(IlpObject ilpObject)
          This method creates a representation object and stores it in the identifier-to-RO map.
protected  void doApplyConfiguration(Map properties)
          Applies the new configuration to this adapter.
protected  void fillModel()
          Fills the model with the representation objects.
 IlpClass getAcceptedClass()
          Returns the class of business objects accepted by this adapter.
 IlpExtendedAttributeGroup getAttributeGroup()
          Accesses the extended attribute group used by this adapter.
 IlpDefaultListModel getModel()
          Returns the model.
 IlpMutableStyleSheet getMutableStyleSheet()
          Returns a mutable style sheet that can be used to change the adapter configuration dynamically.
 IlpRepresentationObjectFactory getRepresentationObjectFactory()
          Returns the representation object factory used by this adapter.
 int getStyleSheetDebugMask()
          Returns the current debug level.
 String[] getStyleSheets()
          Returns the cascading style sheets.
 String getStyleSheets(int index)
          Returns one of the cascading style sheets.
protected  boolean hasConfigurationChanged(Map properties)
          Checks if the configuration has changed in comparison with the current configuration.
 boolean hasModel()
          Returns true if the adapter is connected to a model.
 boolean hasStyleSheets()
           
 void objectAttributeChanged(DataSourceObjectEvent e)
          Implementation of DataSourceListener
 void objectsAdded(DataSourceEvent e)
          Called when objects have been added to the data source.
 void objectsRemoved(DataSourceEvent e)
          Implementation of DataSourceListener
 void objectStructureChanged(DataSourceObjectEvent e)
          Implementation of DataSourceListener
protected  void refilterObjects()
          Applies the filter to the objects that exist in the attached data source.
 void removePropertyChangeListener(PropertyChangeListener listener)
          Removes a listener on property modification.
protected  IlpRepresentationObject removeRepresentation(Object id)
          Removes the representation object that corresponds to the given identifier.
 void setAcceptedClass(IlpClass aClass)
          Sets the class of business objects accepted by this adapter.
 void setAttributeGroup(IlpExtendedAttributeGroup group)
          Accesses the extended attribute group used by this adapter.
 void setModel(IlpDefaultListModel model)
          Sets the model.
 void setRepresentationObjectFactory(IlpRepresentationObjectFactory representationObjectFactory)
          Sets the representation object factory used by this adapter.
 void setStyleSheetDebugMask(int mask)
          Sets the debug level while parsing the style sheets.
 void setStyleSheets(int index, String css)
          Changes one of the cascading style sheets.
 void setStyleSheets(int index, String css, int updateMask)
          Changes one of the cascading style sheets.
 void setStyleSheets(String[] css)
          Sets the cascading style sheets.
 void setStyleSheets(String[] css, int updateMask)
          Sets the cascading style sheets.
protected  boolean testObject(IlpObject ilpObject)
          Returns true if an object of the data source should be represented.
 
Methods inherited from class ilog.cpl.datasource.IlpAbstractAdapter
addAdapterListener, addPropertyChangeListener, addRepresentation, applyConfiguration, batchEnded, batchStarted, beginRepresentation, clearIdToRepresentationObjectMap, endBatch, firePropertyChange, fireRepresentationObjectsAdded, fireRepresentationObjectsRemoved, getContext, getDataSource, getExcludedClasses, getFilter, getPossibleRoots, getRepresentationObject, getRepresentationObject, getRepresentationObjects, getSyncStrategy, hasRepresentationObject, hasRepresentationObjects, initializeExcludedClasses, initializeRepresentationObjects, isRepresenting, refilter, removeAdapterListener, removePropertyChangeListener, replaceExcludedClasses, setBatchable, setDataSource, setExcludedClasses, setFilter, startBatch, stopRepresentation, testRootObject
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface ilog.cpl.datasource.DataSourceListener
batchEnded, batchStarted
 

Constructor Detail

IlpListAdapter

public IlpListAdapter(IlpContext context)
Creates a new list adapter.

Parameters:
context - The context of this adapter.

IlpListAdapter

public IlpListAdapter()
Creates a new list adapter. This new adapter uses the default context.

See Also:
IlpSystem.GetDefaultContext()
Method Detail

setStyleSheets

public void setStyleSheets(String[] css)
                    throws IlvStylingException
Sets the cascading style sheets. Each element can be a URL, a filename, or the style sheet string directly. The order is by priority (the last CSS takes precedence).

This method uses the context URL Access Service to convert file names into URLs.

Specified by:
setStyleSheets in interface IlvStylable
Parameters:
css - An array of strings containing the URLs, the file names of CSS files (usually with a .css suffix) or CSS extracts directly.
Throws:
IlvStylingException - if the given cascading style sheets cannot be read.
Since:
JTGO 4.0
See Also:
getStyleSheets()

setStyleSheets

public void setStyleSheets(String[] css,
                           int updateMask)
                    throws IlvStylingException
Sets the cascading style sheets.

Each element can be a URL, a filename, or directly the style sheet string. The order is by priority (the last CSS takes precedence).

Specified by:
setStyleSheets in interface IlpStylable
Parameters:
css - An array of strings containing the URLs, the file names of CSS files (usually with a .css suffix) or CSS extracts directly.
updateMask - A flag that indicates whether the component and/or the business objects must be updated to use this new configuration. When IlpStylable.UPDATE_COMPONENT_MASK is set, the adapter is reconfigured with the new style sheets. When IlpStylable.UPDATE_OBJECTS_MASK is set, the representation objects that are handled by this adapter are reconfigured according to the new style sheets.
Throws:
IlvStylingException
Since:
JTGO 4.0
See Also:
IlpStylable.UPDATE_COMPONENT_MASK, IlpStylable.UPDATE_OBJECTS_MASK, getStyleSheets()

setStyleSheets

public void setStyleSheets(int index,
                           String css)
                    throws IlvStylingException
Changes one of the cascading style sheets. This method is an alternative to setStyleSheets(java.lang.String[]). It lets you change one particular style sheet file, instead of setting the whole style sheet array.

This method uses the context URL Access Service to convert file names into URLs.

Specified by:
setStyleSheets in interface IlvStylable
Parameters:
index - The index of the style sheet to replace.
css - The URL, file name of the new style sheet file or CSS extract directly.
Throws:
IlvStylingException - when the given cascading style sheet cannot be read.
Since:
JTGO 4.0
See Also:
setStyleSheets(java.lang.String[]), getStyleSheets(int)

setStyleSheets

public void setStyleSheets(int index,
                           String css,
                           int updateMask)
                    throws IlvStylingException
Changes one of the cascading style sheets.

This method is an alternative to setStyleSheets(java.lang.String[]). It lets you change one particular style sheet file, instead of setting the whole style sheet array. When this method is used, you can indicate whether you want to reapply this configuration immediately to the adapter and to all the representation objects that are already managed by this adapter.

Specified by:
setStyleSheets in interface IlpStylable
Parameters:
index - The index of the style sheet to replace.
css - The URL, file name or CSS extract of the new style sheet.
updateMask - A flag that indicates whether the component and/or the business objects must be updated to use this new configuration. When IlpStylable.UPDATE_COMPONENT_MASK is set, the adapter is reconfigured with the new style sheets. When IlpStylable.UPDATE_OBJECTS_MASK is set, the representation objects that are handled by this adapter are reconfigured according to the new style sheets.
Throws:
IlvStylingException
Since:
JTGO 4.0
See Also:
IlpStylable.UPDATE_COMPONENT_MASK, IlpStylable.UPDATE_OBJECTS_MASK, getStyleSheets(int)

getStyleSheets

public String getStyleSheets(int index)
Returns one of the cascading style sheets.

Specified by:
getStyleSheets in interface IlvStylable
Parameters:
index - The position of the cascading style sheet to return.
Returns:
The URL, file name or CSS extract that has been set on this component in the index-th position.
Since:
JTGO 4.0
See Also:
setStyleSheets(int, String), setStyleSheets(String[])

getStyleSheets

public String[] getStyleSheets()
Returns the cascading style sheets.

Specified by:
getStyleSheets in interface IlvStylable
Returns:
An array containing the URLs, file names of the style sheets or CSS extracts directly.
Since:
JTGO 4.0
See Also:
setStyleSheets(String[])

hasStyleSheets

public boolean hasStyleSheets()
Returns:
true if style sheets have been set in this context.
Since:
JTGO 4.0

setStyleSheetDebugMask

public void setStyleSheetDebugMask(int mask)
Sets the debug level while parsing the style sheets. Set this property before calling setStyleSheets(java.lang.String[]) to debug problems during configuration.

Specified by:
setStyleSheetDebugMask in interface IlvStylable
Parameters:
mask - The debug mask, expressed as an OR combination of the predefined flags.

Note: You can also set the style sheet debug mask directly in the style sheet files. The following example illustrates a style sheet extract with this configuration:

 StyleSheet {
   styleSheetDebugMask: "BAD_CLASS_MASK|BAP_PROP_MASK";
 }
 
Since:
JTGO 4.0
See Also:
setStyleSheets(java.lang.String[]), getStyleSheetDebugMask(), IlvStylable.APPLIED_RULE_MASK, IlvStylable.BAD_CLASS_MASK, IlvStylable.BAD_PROP_MASK, IlvStylable.CREATED_MASK, IlvStylable.DECL_MASK, IlvStylable.DECL_VALUE_MASK, IlvStylable.FAILED_CONVERSIONS_MASK, IlvStylable.TIME_REPORT_MASK, IlvStylable.WARNING_PROP_MASK

getStyleSheetDebugMask

public int getStyleSheetDebugMask()
Returns the current debug level.

Specified by:
getStyleSheetDebugMask in interface IlvStylable
Since:
JTGO 4.0
See Also:
setStyleSheetDebugMask(int)

addPropertyChangeListener

public void addPropertyChangeListener(PropertyChangeListener listener)
Adds a listener on property modification.

Specified by:
addPropertyChangeListener in interface IlvStylable
Overrides:
addPropertyChangeListener in class IlpAbstractAdapter
Parameters:
listener - The listener to add.
Since:
JTGO 4.0

removePropertyChangeListener

public void removePropertyChangeListener(PropertyChangeListener listener)
Removes a listener on property modification.

Specified by:
removePropertyChangeListener in interface IlvStylable
Overrides:
removePropertyChangeListener in class IlpAbstractAdapter
Parameters:
listener - The listener to remove.
Since:
JTGO 4.0

getMutableStyleSheet

public IlpMutableStyleSheet getMutableStyleSheet()
Description copied from interface: IlpStylableAdapter
Returns a mutable style sheet that can be used to change the adapter configuration dynamically.

The mutable style sheet is created and registered in this adapter when this method is called for the first time.

Note: if you replace the existing style sheets, the mutable style sheet will no longer be connected to this adapter. Once this happens, a future call to this method will then create a new mutable style sheet and register it.

Specified by:
getMutableStyleSheet in interface IlpStylableAdapter
Since:
JViews 8.1

createCSSDelegate

protected IlpStylable createCSSDelegate()
Creates the stylable object that will be used to customize the adapter.

Since:
JViews 7.5
Internal method or field: do not use!

hasConfigurationChanged

protected boolean hasConfigurationChanged(Map properties)
Checks if the configuration has changed in comparison with the current configuration.

Overrides:
hasConfigurationChanged in class IlpAbstractAdapter
Parameters:
properties -
Returns:
true if a property of the given configuration differs from the current value in this adapter.
Since:
JTGO 4.0
Internal method or field: do not use!

doApplyConfiguration

protected void doApplyConfiguration(Map properties)
Applies the new configuration to this adapter.

Overrides:
doApplyConfiguration in class IlpAbstractAdapter
Parameters:
properties -
Since:
JTGO 4.0
Internal method or field: do not use!

hasModel

public boolean hasModel()
Returns true if the adapter is connected to a model.

Specified by:
hasModel in class IlpAbstractAdapter

clearRepresentationObjects

protected void clearRepresentationObjects()
Called when all representation objects should be cleared.

Specified by:
clearRepresentationObjects in class IlpAbstractAdapter

removeRepresentation

protected IlpRepresentationObject removeRepresentation(Object id)
Description copied from class: IlpAbstractAdapter
Removes the representation object that corresponds to the given identifier.

Overrides:
removeRepresentation in class IlpAbstractAdapter
Parameters:
id - Object identifier

fillModel

protected void fillModel()
Description copied from class: IlpAbstractAdapter
Fills the model with the representation objects. This method is called only when there is a model.

Specified by:
fillModel in class IlpAbstractAdapter
Internal method or field: do not use!

setModel

public void setModel(IlpDefaultListModel model)
Sets the model.

This is a bound property.

Parameters:
model - The model in which the adapter places representation objects.

getModel

public IlpDefaultListModel getModel()
Returns the model.

This is a bound property.

Returns:
The model in which the adapter places the representation objects.

setAcceptedClass

public void setAcceptedClass(IlpClass aClass)
Sets the class of business objects accepted by this adapter.

Representation objects are created only if the corresponding business object is of the same class (or subclass) as the accepted class, and if it is accepted by the adapter filter (if there is one).

Note: When this adapter is connected to a table component, the accepted class will be related to the table model (the attributes of the accepted class are mapped to columns in the table). Changing the accepted class will not update the columns in the table model immediately; the change will be made in a different thread (the AWT Event Dispatch Thread).

Note: This property can be customized using a CSS, as illustrated below:

 Adapter {
   acceptedClass: "business class name";
 }
 

Parameters:
aClass - The new accepted class.
See Also:
IlpAbstractAdapter.setFilter(IlpFilter)

getAcceptedClass

public IlpClass getAcceptedClass()
Returns the class of business objects accepted by this adapter.

Returns:
The accepted class.
See Also:
setAcceptedClass(IlpClass)

getAttributeGroup

public IlpExtendedAttributeGroup getAttributeGroup()
Accesses the extended attribute group used by this adapter. The attribute group is shared with the representation object factory.

Returns:
The extended attribute group used by this adapter. It creates a new instance if none has been set.
Since:
JTGO 4.0
Internal method or field: do not use!

setAttributeGroup

public void setAttributeGroup(IlpExtendedAttributeGroup group)
Accesses the extended attribute group used by this adapter. The attribute group is shared with the representation object factory and is directly related to the accepted class.

Parameters:
group - The new extended attribute group to be set, it should not be null.
Since:
JTGO 4.0
Internal method or field: do not use!

getRepresentationObjectFactory

public IlpRepresentationObjectFactory getRepresentationObjectFactory()
Returns the representation object factory used by this adapter.

Returns:
The factory of representation objects.

setRepresentationObjectFactory

public void setRepresentationObjectFactory(IlpRepresentationObjectFactory representationObjectFactory)
Sets the representation object factory used by this adapter.

Note: This property can be customized using a CSS, as illustrated below:

 Adapter {
   representationObjectFactory: @+factoryDef;
 }
 Subobject#factoryDef {
   class: ...;
 }
 

Parameters:
representationObjectFactory - The factory of representation objects.

objectsAdded

public void objectsAdded(DataSourceEvent e)
Description copied from interface: DataSourceListener
Called when objects have been added to the data source.

Specified by:
objectsAdded in interface DataSourceListener
Internal method or field: do not use!

testObject

protected boolean testObject(IlpObject ilpObject)
Returns true if an object of the data source should be represented.

By default, it returns true if there is no filtering, if the IlpObject passes through the filter and the excluded class list and if the IlpObject corresponds to the current accepted class.

Overrides:
testObject in class IlpAbstractAdapter
Since:
JTGO 3.0
See Also:
IlpAbstractAdapter.setFilter(ilog.cpl.util.IlpFilter), IlpAbstractAdapter.setExcludedClasses(java.util.List), setAcceptedClass(ilog.cpl.model.IlpClass)

createRepresentationObject

protected IlpRepresentationObject createRepresentationObject(IlpObject ilpObject)
Description copied from class: IlpAbstractAdapter
This method creates a representation object and stores it in the identifier-to-RO map. Note that this method may return null in which case it does not store anything in the map.

Specified by:
createRepresentationObject in class IlpAbstractAdapter
See Also:
getRepresentationObjectFactory()
Internal method or field: do not use!

refilterObjects

protected void refilterObjects()
Applies the filter to the objects that exist in the attached data source.

The default implementation iterates on all business objects in the attached data source and checks if the object is accepted or not by the current filter. If an object is accepted, its representation object is created, if it does not exist already. If an object is no longer accepted, its representation object is removed from the adapter.

Overrides:
refilterObjects in class IlpAbstractAdapter
Since:
JTGO 4.0

objectsRemoved

public void objectsRemoved(DataSourceEvent e)
Implementation of DataSourceListener

Specified by:
objectsRemoved in interface DataSourceListener
Internal method or field: do not use!

objectStructureChanged

public void objectStructureChanged(DataSourceObjectEvent e)
Implementation of DataSourceListener

Specified by:
objectStructureChanged in interface DataSourceListener
Internal method or field: do not use!

objectAttributeChanged

public void objectAttributeChanged(DataSourceObjectEvent e)
Implementation of DataSourceListener

Specified by:
objectAttributeChanged in interface DataSourceListener
Internal method or field: do not use!


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