org.eclipse.actf.model
Class AbstractRenderableModel

java.lang.Object
  extended by org.eclipse.actf.model.AbstractModel
      extended by org.eclipse.actf.model.AbstractRenderableModel
All Implemented Interfaces:
IModel, IRenderableModel
Direct Known Subclasses:
DomBrowserGuiModel, MsaaGuiModel

public abstract class AbstractRenderableModel
extends AbstractModel
implements IRenderableModel

base implementation for IRenderableModel. Clients should extend this class rather than attempting to implement IRenderableModel.

Author:
Mike Squillace

Field Summary
protected  Map eventIdMap
          keyed by event ids with values that are instances of ModelEventType
 
Fields inherited from class org.eclipse.actf.model.AbstractModel
baseType, configuration, locator, nodeToTypeNameMap, runtimeContext, treeNodeWalker
 
Constructor Summary
AbstractRenderableModel(String modelType)
          create an IRenderableModel implementation
 
Method Summary
 Rectangle getBoundingRectangle(Object element)
          gets the rectangle bounding the given element default implementation returns null
 ModelEventType getModelEventType(Object eventId)
          get the ModelEventType instances associated with the given event id.
 ModelEventType[] getModelEventTypes(Class c)
          get the model event types for the given source type. default implementation returns null
 void highlight(Object element)
          highlight or visually indicate the element that is being examined.
protected  void initEventIdMap()
          used to initialize the eventId map, which is keyed by eventId that corresponds to a ModelEventType instance.
protected  void initEventIdMap(Class sourceType, Class eventFieldProviderType, String fieldPrefix)
           
 boolean isValid(Object comp)
          returns whether or not the specified component is valid for access. default implementation merely checks that the component is not null.
 boolean isVisible(Object comp)
          returns whether or not the specified component is currently visible
 void registerModelEventListener(IModelEventListener listener, ModelEventType[] eventTypes)
          register a listener to receive notification when events with the given eventTypes are fired within this model. equivalent to calling registerModelEventListener(listener, eventTypes, null)
 void registerModelEventListener(IModelEventListener listener, ModelEventType[] eventTypes, Object[] params)
          register a listener to receive notification when events with the given eventTypes are fired within this model.
 boolean requestFocusFor(Object comp)
          request the focus for the specified component.
 void unregisterModelEventListener(IModelEventListener listener, ModelEventType[] eventTypes)
          unregister a previously registered listener.
 
Methods inherited from class org.eclipse.actf.model.AbstractModel
addModelChangeListener, fireModelChangeEvent, getBaseType, getDefaultAliasPrefix, getName, getNodeId, getNodeLocator, getNodeName, getNodeWalker, getOrder, getTypeName, removeModelChangeListener, setFilters, setModelType, setNodeID
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.eclipse.actf.model.IRenderableModel
asyncInvokeOnUIThread, invokeOnUIThread, isUIThread
 
Methods inherited from interface org.eclipse.actf.model.IModel
addModelChangeListener, getBaseType, getDefaultAliasPrefix, getName, getNodeId, getNodeLocator, getNodeName, getNodeWalker, getOrder, getPackageNames, getTypeName, removeModelChangeListener, setNodeID
 

Field Detail

eventIdMap

protected Map eventIdMap
keyed by event ids with values that are instances of ModelEventType

Constructor Detail

AbstractRenderableModel

public AbstractRenderableModel(String modelType)
create an IRenderableModel implementation

Parameters:
modelType - - name of model
Method Detail

getModelEventType

public ModelEventType getModelEventType(Object eventId)
get the ModelEventType instances associated with the given event id. The event id is model-specific and will usually be presented in the model's API. What constitutes an event id and how they are determined should be specified in clients that implement this model.

Specified by:
getModelEventType in interface IRenderableModel
Parameters:
eventId - model-specific event id
Returns:
ModelEventType instances associated with this event id or null if no event types are associated with this id

isVisible

public boolean isVisible(Object comp)
returns whether or not the specified component is currently visible

Specified by:
isVisible in interface IRenderableModel
Parameters:
comp - - component to be tested
Returns:
whether or not the component is currently visible or showing on the screen

isValid

public boolean isValid(Object comp)
returns whether or not the specified component is valid for access. Components may be invalid because their underlying resources have been disposed, because the device that displays or renders them is destroyed, or for many other reasons. default implementation merely checks that the component is not null.

Specified by:
isValid in interface IRenderableModel
Parameters:
comp - - component to be tested
Returns:
true if this component is valid, false otherwise
See Also:
InvalidComponentException

requestFocusFor

public boolean requestFocusFor(Object comp)
request the focus for the specified component. This method should be invoked, for example, just prior to validation for a report that reflects the state of the component while visible.

Specified by:
requestFocusFor in interface IRenderableModel
Parameters:
comp - - component for which focus is desired
Returns:
true if focus is successful, false otherwise

highlight

public void highlight(Object element)
highlight or visually indicate the element that is being examined. Highlighting may take place by placing a border around the element, flashing the element, or changing its background color.

Specified by:
highlight in interface IRenderableModel
Parameters:
element - - the element to be highlited

getBoundingRectangle

public Rectangle getBoundingRectangle(Object element)
gets the rectangle bounding the given element default implementation returns null

Specified by:
getBoundingRectangle in interface IRenderableModel
Parameters:
element - - element for which bounds are desired
Returns:
bounding rectangle of component

getModelEventTypes

public ModelEventType[] getModelEventTypes(Class c)
get the model event types for the given source type. A ModelEventType object describes the types of events that can be fired within the context of this runtime model. If the sourceType is null, then all of the event types of which this model is aware will be returned else only events that can be fired by the given sourceType will be returned. default implementation returns null

Specified by:
getModelEventTypes in interface IRenderableModel
Parameters:
c - type to be queried for events
Returns:
all events that can be fired by instances of the given type or all events of which this model is aware
See Also:
ModelEventType

registerModelEventListener

public void registerModelEventListener(IModelEventListener listener,
                                       ModelEventType[] eventTypes)
register a listener to receive notification when events with the given eventTypes are fired within this model. The eventTypes should be obtained from one of the getModelEventTypes methods. equivalent to calling registerModelEventListener(listener, eventTypes, null)

Specified by:
registerModelEventListener in interface IRenderableModel
Parameters:
listener - listener to be notified when specified events occur
eventTypes - event types for which listener is being registered
See Also:
IRenderableModel.getModelEventType(Object), IRenderableModel.getModelEventTypes(Class)

registerModelEventListener

public void registerModelEventListener(IModelEventListener listener,
                                       ModelEventType[] eventTypes,
                                       Object[] params)
register a listener to receive notification when events with the given eventTypes are fired within this model. The eventTypes should be obtained from one of the getModelEventTypes methods. Optional parameters can also be passed to facilitate additional side effects or for additional information about the context in which events are being fired.

Specified by:
registerModelEventListener in interface IRenderableModel
Parameters:
listener - listener to be notified when specified events occur
eventTypes - event types for which listener is being registered
params - - additional parameters (may be null)
See Also:
IRenderableModel.getModelEventType(Object), IRenderableModel.getModelEventTypes(Class)

unregisterModelEventListener

public void unregisterModelEventListener(IModelEventListener listener,
                                         ModelEventType[] eventTypes)
Description copied from interface: IRenderableModel
unregister a previously registered listener. The eventTypes should be obtained from either of the getModelEventTypes methods.

Specified by:
unregisterModelEventListener in interface IRenderableModel
Parameters:
listener - listener to be unregistered
eventTypes - event types for which listener is to be unregistered
See Also:
IRenderableModel.registerModelEventListener(IModelEventListener, ModelEventType[]), ModelEventType

initEventIdMap

protected void initEventIdMap()
used to initialize the eventId map, which is keyed by eventId that corresponds to a ModelEventType instance. Event ids are model-specific and typically defined as part of that model's definition.

See Also:
ModelEventType, registerModelEventListener(IModelEventListener, ModelEventType[])

initEventIdMap

protected void initEventIdMap(Class sourceType,
                              Class eventFieldProviderType,
                              String fieldPrefix)