public abstract class IlpListAdapter extends IlpAbstractAdapter implements DataSourceListener, IlpStylableAdapter
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.
UPDATE_ALL_MASK, UPDATE_COMPONENT_MASK, UPDATE_NONE_MASK, UPDATE_OBJECTS_MASK
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 and Description |
---|
IlpListAdapter()
Creates a new list adapter.
|
IlpListAdapter(IlpContext context)
Creates a new list adapter.
|
Modifier and Type | Method and Description |
---|---|
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<String,Object> 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()
Returns whether style sheets have been set in this context or not.
|
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. |
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
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
batchEnded, batchStarted
public IlpListAdapter(IlpContext context)
context
- The context of this adapter.public IlpListAdapter()
IlpSystem.GetDefaultContext()
public void setStyleSheets(String[] css) throws IlvStylingException
This method uses the context URL Access Service to convert file names into URLs.
setStyleSheets
in interface IlvStylable
css
- An array of strings containing the URLs, the file names of
CSS files (usually with a .css
suffix) or
CSS extracts directly.IlvStylingException
- if the given cascading style sheets cannot
be read.getStyleSheets()
public void setStyleSheets(String[] css, int updateMask) throws IlvStylingException
Each element can be a URL, a filename, or directly the style sheet string. The order is by priority (the last CSS takes precedence).
setStyleSheets
in interface IlpStylable
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.IlvStylingException
IlpStylable.UPDATE_COMPONENT_MASK
,
IlpStylable.UPDATE_OBJECTS_MASK
,
getStyleSheets()
public void setStyleSheets(int index, String css) throws IlvStylingException
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.
setStyleSheets
in interface IlvStylable
index
- The index of the style sheet to replace.css
- The URL, file name of the new style sheet file or CSS
extract directly.IlvStylingException
- when the given cascading style sheet cannot
be read.setStyleSheets(java.lang.String[])
,
getStyleSheets(int)
public void setStyleSheets(int index, String css, int updateMask) throws IlvStylingException
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.
setStyleSheets
in interface IlpStylable
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.IlvStylingException
IlpStylable.UPDATE_COMPONENT_MASK
,
IlpStylable.UPDATE_OBJECTS_MASK
,
getStyleSheets(int)
public String getStyleSheets(int index)
getStyleSheets
in interface IlvStylable
index
- The position of the cascading style sheet to return.index
-th position.setStyleSheets(int, String)
,
setStyleSheets(String[])
public String[] getStyleSheets()
getStyleSheets
in interface IlvStylable
setStyleSheets(String[])
public boolean hasStyleSheets()
true
if style sheets have been set in this contextpublic void setStyleSheetDebugMask(int mask)
setStyleSheets(java.lang.String[])
to debug
problems during configuration.setStyleSheetDebugMask
in interface IlvStylable
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"; }
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
public int getStyleSheetDebugMask()
getStyleSheetDebugMask
in interface IlvStylable
setStyleSheetDebugMask(int)
public void addPropertyChangeListener(PropertyChangeListener listener)
addPropertyChangeListener
in interface IlvStylable
addPropertyChangeListener
in class IlpAbstractAdapter
listener
- The listener to add.public void removePropertyChangeListener(PropertyChangeListener listener)
removePropertyChangeListener
in interface IlvStylable
removePropertyChangeListener
in class IlpAbstractAdapter
listener
- The listener to remove.public IlpMutableStyleSheet getMutableStyleSheet()
IlpStylableAdapter
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.
getMutableStyleSheet
in interface IlpStylableAdapter
protected IlpStylable createCSSDelegate()
protected boolean hasConfigurationChanged(Map properties)
hasConfigurationChanged
in class IlpAbstractAdapter
properties
- true
if a property of the given configuration
differs from the current value in this adapter.protected void doApplyConfiguration(Map<String,Object> properties)
doApplyConfiguration
in class IlpAbstractAdapter
properties
- public boolean hasModel()
true
if the adapter is connected to a model.hasModel
in class IlpAbstractAdapter
protected void clearRepresentationObjects()
clearRepresentationObjects
in class IlpAbstractAdapter
protected IlpRepresentationObject removeRepresentation(Object id)
IlpAbstractAdapter
removeRepresentation
in class IlpAbstractAdapter
id
- Object identifierprotected void fillModel()
IlpAbstractAdapter
fillModel
in class IlpAbstractAdapter
public void setModel(IlpDefaultListModel model)
This is a bound property.
model
- The model in which the adapter places representation objects.public IlpDefaultListModel getModel()
This is a bound property.
public void setAcceptedClass(IlpClass aClass)
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"; }
aClass
- The new accepted class.IlpAbstractAdapter.setFilter(IlpFilter)
public IlpClass getAcceptedClass()
setAcceptedClass(IlpClass)
public IlpExtendedAttributeGroup getAttributeGroup()
public void setAttributeGroup(IlpExtendedAttributeGroup group)
group
- The new extended attribute group to be set, it
should not be null
.public IlpRepresentationObjectFactory getRepresentationObjectFactory()
public void setRepresentationObjectFactory(IlpRepresentationObjectFactory representationObjectFactory)
Note: This property can be customized using a CSS, as illustrated below:
Adapter { representationObjectFactory: @+factoryDef; } Subobject#factoryDef { class: ...; }
representationObjectFactory
- The factory of representation objects.public void objectsAdded(DataSourceEvent e)
DataSourceListener
objectsAdded
in interface DataSourceListener
protected boolean testObject(IlpObject ilpObject)
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.
testObject
in class IlpAbstractAdapter
IlpAbstractAdapter.setFilter(ilog.cpl.util.IlpFilter)
,
IlpAbstractAdapter.setExcludedClasses(java.util.List<ilog.cpl.model.IlpClass>)
,
setAcceptedClass(ilog.cpl.model.IlpClass)
protected IlpRepresentationObject createRepresentationObject(IlpObject ilpObject)
IlpAbstractAdapter
null
in which case it does
not store anything in the map.createRepresentationObject
in class IlpAbstractAdapter
getRepresentationObjectFactory()
protected void refilterObjects()
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.
refilterObjects
in class IlpAbstractAdapter
public void objectsRemoved(DataSourceEvent e)
DataSourceListener
objectsRemoved
in interface DataSourceListener
public void objectStructureChanged(DataSourceObjectEvent e)
DataSourceListener
objectStructureChanged
in interface DataSourceListener
public void objectAttributeChanged(DataSourceObjectEvent e)
DataSourceListener
objectAttributeChanged
in interface DataSourceListener
© Copyright 2024 Rogue Wave Software, Inc., a Perforce company.. All Rights Reserved.