ilog.ds.adapter
Class IlAbstractAdapter

java.lang.Object
  |
  +--ilog.ds.adapter.IlAbstractAdapter
All Implemented Interfaces:
BatchListener, DataSourceListener, EventListener, IlFreezableAdapter
Direct Known Subclasses:
IlAbstractGanttModelAdapter, IlAbstractJTableAdapter, IlAbstractJTreeAdapter, IlAbstractListModelAdapter, IlAbstractSDMModelAdapter, IlsDefaultIlvGrapherAdapter

public abstract class IlAbstractAdapter
extends Object
implements BatchListener, DataSourceListener, IlFreezableAdapter

Base class for adapters to model or model-related classes. It implements the batch mechanism: at the end of each batch, the previously received events stored using the addDSEvent method are processed using its synchronization strategy.


Field Summary
protected  ilog.util.IlEventListenerList _dispatchListeners
           
protected  ArrayList _events
           
protected  ArrayList _frozenEvents
           
protected  boolean _inBatchedEvents
           
protected  boolean _inTransaction
           
protected  boolean _isFrozen
           
protected  IlSynchronizationStrategy _syncStrategy
           
 
Constructor Summary
IlAbstractAdapter()
          public constructor Initializes the synchronization strategy by using IlSynchronizationStrategy.GetDefault()
 
Method Summary
 void addDispatchListener(DispatchListener l)
           
protected  void addDSEvent(Object event)
           
protected  void clearDSEvents()
           
protected  void dispatchBatchedEvent(EventObject event)
           
protected  void dispatchBatchedEvents(ArrayList batchedEvents)
           
 void endBatch(BatchEvent e)
           
protected  void firePostDispatchBatchedEventsEvent(DispatchEvent e)
           
protected  void firePreDispatchBatchedEventsEvent(DispatchEvent e)
           
static Color GetColor(String color)
           
protected  Object getSynchronizationObject()
          Gets the object to synchronize in the synchronization strategy used by this adapter.
 IlSynchronizationStrategy getSynchronizationStrategy()
          Gets the synchronization strategy used by this adapter
protected  void internalDataSourceChange(DataSourceEvent evt)
          Internal code called in the Swing event thread.
 boolean isFrozen()
          Returns true if the adapter is frozen.
 boolean isInBatchedEvents()
           
 boolean isInTransaction()
           
protected  void postDispatchBatchedEvents(ArrayList events)
           
protected  void preDispatchBatchedEvents(ArrayList events)
          dispatching events methods
 void removeDispatchListener(DispatchListener l)
           
 void setFrozen(boolean isFrozen)
          Freezes or unfreeze the adapter.
 void setSynchronizationStrategy(IlSynchronizationStrategy syncStrategy)
          Sets the synchronization strategy to use
 void startBatch(BatchEvent e)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface ilog.ds.DataSourceListener
dataSourceChange
 

Field Detail

_dispatchListeners

protected ilog.util.IlEventListenerList _dispatchListeners

_syncStrategy

protected IlSynchronizationStrategy _syncStrategy

_events

protected ArrayList _events

_frozenEvents

protected ArrayList _frozenEvents

_inBatchedEvents

protected boolean _inBatchedEvents

_isFrozen

protected boolean _isFrozen

_inTransaction

protected boolean _inTransaction
Constructor Detail

IlAbstractAdapter

public IlAbstractAdapter()
public constructor Initializes the synchronization strategy by using IlSynchronizationStrategy.GetDefault()
Method Detail

GetColor

public static Color GetColor(String color)

setSynchronizationStrategy

public void setSynchronizationStrategy(IlSynchronizationStrategy syncStrategy)
Sets the synchronization strategy to use
Parameters:
syncStrategy - the new synchronization strategy to use

getSynchronizationStrategy

public IlSynchronizationStrategy getSynchronizationStrategy()
Gets the synchronization strategy used by this adapter
Returns:
the synchronization strategy.

getSynchronizationObject

protected Object getSynchronizationObject()
Gets the object to synchronize in the synchronization strategy used by this adapter.
Returns:
this by default, the data model generally (in subsclasses)

setFrozen

public void setFrozen(boolean isFrozen)
Freezes or unfreeze the adapter. When the adapter is frozen, all the incoming events are buffered instead of being dispatched at each end of batch. When the adapter is unfrozen, all the buffered events, if there are any, are dispatched.
Specified by:
setFrozen in interface IlFreezableAdapter

isFrozen

public boolean isFrozen()
Returns true if the adapter is frozen.
Specified by:
isFrozen in interface IlFreezableAdapter

startBatch

public void startBatch(BatchEvent e)
Description copied from interface: BatchListener
Start of batch
Specified by:
startBatch in interface BatchListener

endBatch

public void endBatch(BatchEvent e)
Description copied from interface: BatchListener
End of batch
Specified by:
endBatch in interface BatchListener

isInTransaction

public boolean isInTransaction()
Returns:
true if the adapter is in transaction (component thread side).
See Also:
startBatch(ilog.ds.BatchEvent), endBatch(ilog.ds.BatchEvent)

internalDataSourceChange

protected void internalDataSourceChange(DataSourceEvent evt)
Internal code called in the Swing event thread.

isInBatchedEvents

public boolean isInBatchedEvents()
Returns:
true if the adapter is processing the batched events. (swing (or other synchronization strategy) thread side).
See Also:
preDispatchBatchedEvents(java.util.ArrayList), postDispatchBatchedEvents(java.util.ArrayList), dispatchBatchedEvent(java.util.EventObject), dispatchBatchedEvents(java.util.ArrayList)

preDispatchBatchedEvents

protected void preDispatchBatchedEvents(ArrayList events)
dispatching events methods

postDispatchBatchedEvents

protected void postDispatchBatchedEvents(ArrayList events)

dispatchBatchedEvent

protected void dispatchBatchedEvent(EventObject event)

dispatchBatchedEvents

protected void dispatchBatchedEvents(ArrayList batchedEvents)

addDSEvent

protected void addDSEvent(Object event)

clearDSEvents

protected void clearDSEvents()

addDispatchListener

public void addDispatchListener(DispatchListener l)

removeDispatchListener

public void removeDispatchListener(DispatchListener l)

firePreDispatchBatchedEventsEvent

protected void firePreDispatchBatchedEventsEvent(DispatchEvent e)

firePostDispatchBatchedEventsEvent

protected void firePostDispatchBatchedEventsEvent(DispatchEvent e)