com.guiseframework.platform
Class AbstractDepictor<O extends DepictedObject>

java.lang.Object
  extended by com.guiseframework.platform.AbstractDepictor<O>
Type Parameters:
O - The type of object being depicted.
All Implemented Interfaces:
Depictor<O>
Direct Known Subclasses:
AbstractComponentDepictor, AbstractWebDepictor

public abstract class AbstractDepictor<O extends DepictedObject>
extends java.lang.Object
implements Depictor<O>

An abstract strategy for depicting objects on some platform. The Depictor.GENERAL_PROPERTY is used to indicate that some general property has changed.

Author:
Garret Wilson

Nested Class Summary
protected  class AbstractDepictor.DepictedPropertyChangeListener
          A listener that marks this depiction as dirty if changes occur.
 
Field Summary
 
Fields inherited from interface com.guiseframework.platform.Depictor
GENERAL_PROPERTY
 
Constructor Summary
AbstractDepictor()
          Default constructor.
 
Method Summary
 void depict()
          Updates the depiction of the object.
protected  void depictedObjectPropertyChange(java.beans.PropertyChangeEvent propertyChangeEvent)
          Called when a depicted object bound property is changed.
 DepictContext getDepictContext()
          Retrieves information and functionality related to the current depiction on the platform.
 O getDepictedObject()
           
protected  AbstractDepictor.DepictedPropertyChangeListener getDepictedPropertyChangeListener()
           
protected  java.util.Set<java.lang.String> getIgnoredProperties()
           
protected  java.util.Set<java.lang.String> getModifiedProperties()
           
 Platform getPlatform()
           
 GuiseSession getSession()
           
 void installed(O depictedObject)
          Called when the depictor is installed in a depicted object.
 boolean isDepicted()
           
 void processEvent(PlatformEvent event)
          Processes an event from the platform.
 void setDepicted(boolean newDepicted)
          Changes the depictor's updated status.
protected  void setPropertyModified(java.lang.String property, boolean modified)
          Calls when a property has been modified to sets whether a property has been modified.
 void uninstalled(O depictedObject)
          Called when the depictor is uninstalled from a depicted object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractDepictor

public AbstractDepictor()
Default constructor.

Method Detail

getSession

public GuiseSession getSession()
Specified by:
getSession in interface Depictor<O extends DepictedObject>
Returns:
The Guise session that owns this object.

getPlatform

public Platform getPlatform()
Specified by:
getPlatform in interface Depictor<O extends DepictedObject>
Returns:
The platform on which this depictor is depicting ojects.

getDepictContext

public DepictContext getDepictContext()
Retrieves information and functionality related to the current depiction on the platform. This method delegates to Platform.getDepictContext().

Specified by:
getDepictContext in interface Depictor<O extends DepictedObject>
Returns:
A context for the current depiction.
Throws:
java.lang.IllegalStateException - if no depict context can be returned in the current depiction state.

getIgnoredProperties

protected java.util.Set<java.lang.String> getIgnoredProperties()
Returns:
The depicted object properties that are to be ignored.

getModifiedProperties

protected java.util.Set<java.lang.String> getModifiedProperties()
Returns:
The depicted object properties that have been modified.

setPropertyModified

protected void setPropertyModified(java.lang.String property,
                                   boolean modified)
Calls when a property has been modified to sets whether a property has been modified. If the property's modified status is set to true, the depictor's isDepicted() status is changed to false. If the property's modified status is set to false and there are no other modified properties, the depictor's isDepicted() status is set to true.

Parameters:
property - The property that has been modified.
See Also:
setDepicted(boolean)

getDepictedPropertyChangeListener

protected AbstractDepictor.DepictedPropertyChangeListener getDepictedPropertyChangeListener()
Returns:
The listener that marks this depiction as dirty if a change occurs.

getDepictedObject

public O getDepictedObject()
Specified by:
getDepictedObject in interface Depictor<O extends DepictedObject>
Returns:
The object being depicted, or null if this depictor is not installed in a depicted object.

isDepicted

public boolean isDepicted()
Specified by:
isDepicted in interface Depictor<O extends DepictedObject>
Returns:
Whether this depictor's representation of the depicted object is up to date.

setDepicted

public void setDepicted(boolean newDepicted)
Changes the depictor's updated status. If the new depicted status is true, all modified properties are removed. If the new depicted status is false, the Depictor.GENERAL_PROPERTY property is set as modified.

Specified by:
setDepicted in interface Depictor<O extends DepictedObject>
Parameters:
newDepicted - Whether this depictor's representation of the depicted object is up to date.

installed

public void installed(O depictedObject)
Called when the depictor is installed in a depicted object. This version listens for property changes of a PropertyBindable object. This version listens for list changes of a ListListenable object.

Specified by:
installed in interface Depictor<O extends DepictedObject>
Parameters:
depictedObject - The depictedObject into which this depictor is being installed.
Throws:
java.lang.NullPointerException - if the given depicted object is null.
java.lang.IllegalStateException - if this depictor is already installed in a depicted object.
See Also:
depictedPropertyChangeListener

uninstalled

public void uninstalled(O depictedObject)
Called when the depictor is uninstalled from a depicted object. This version stop listening for property changes of a PropertyBindable object. This version stops listening for list changes of a ListListenable object.

Specified by:
uninstalled in interface Depictor<O extends DepictedObject>
Parameters:
depictedObject - The depicted object from which this depictor is being uninstalled.
Throws:
java.lang.NullPointerException - if the given depicted object is null.
java.lang.IllegalStateException - if this depictor is not installed in a depicted object.
See Also:
depictedPropertyChangeListener

processEvent

public void processEvent(PlatformEvent event)
Processes an event from the platform.

Specified by:
processEvent in interface Depictor<O extends DepictedObject>
Parameters:
event - The event to be processed.
Throws:
java.lang.IllegalArgumentException - if the given event is a relevant DepictEvent with a source of a different depicted object.

depict

public void depict()
            throws java.io.IOException
Updates the depiction of the object. This implementation marks the depiction as depicted.

Specified by:
depict in interface Depictor<O extends DepictedObject>
Throws:
java.io.IOException - if there is an error updating the depiction.

depictedObjectPropertyChange

protected void depictedObjectPropertyChange(java.beans.PropertyChangeEvent propertyChangeEvent)
Called when a depicted object bound property is changed. This method may also be called for objects related to the depicted object, so if specific properties are checked the event source should be verified to be the depicted object. This implementation marks the property as being modified if the property is not an ignored property.

Parameters:
propertyChangeEvent - An event object describing the event source and the property that has changed.
See Also:
getIgnoredProperties(), setPropertyModified(String, boolean)


Copyright © 2005-2010 GlobalMentor, Inc. All Rights Reserved.