edu.washington.cs.supple.rep
Class UiObjectImpl

java.lang.Object
  extended byedu.washington.cs.supple.rep.SuppleBeanImpl
      extended byedu.washington.cs.supple.rep.SuppleUiObjectHierarchyElementImpl
          extended byedu.washington.cs.supple.rep.UiObjectImpl
All Implemented Interfaces:
java.lang.Cloneable, ConstraintManipulation, java.util.EventListener, java.beans.PropertyChangeListener, java.io.Serializable, SuppleBean, SuppleUiObjectHierarchyElement, UiObject, ValueListener
Direct Known Subclasses:
StateVarImpl, UiActionImpl, UiAlternativeImpl

public class UiObjectImpl
extends SuppleUiObjectHierarchyElementImpl
implements java.io.Serializable, UiObject, java.beans.PropertyChangeListener, ValueListener, java.lang.Cloneable

Author:
kgajos
See Also:
Serialized Form

Field Summary
protected  boolean active
           
protected  ValueBinding activeValue
           
protected  java.util.Vector constraints
           
protected  RenderedView currentView
           
protected  java.util.Vector hints
           
protected  java.io.Serializable interfaceIdentifier
           
protected  boolean modifiable
           
protected  boolean runtime
           
protected  java.lang.String textLabel
           
protected  SuppleType type
           
protected  int uniqueId
           
protected static int uniqueIdCounter
           
 
Fields inherited from class edu.washington.cs.supple.rep.SuppleUiObjectHierarchyElementImpl
name, parent
 
Fields inherited from class edu.washington.cs.supple.rep.SuppleBeanImpl
pcs
 
Constructor Summary
UiObjectImpl(SuppleType type, java.lang.String label)
          Constructor for elements that do not take a value
 
Method Summary
 void accept(UiVisitor visitor)
          Accept a UiVisitor.
protected  void acceptBindingVisitor(UiVisitor visitor)
          Helper for accept() - allows subclasses to extend the bindings to be visited without overriding accept().
 void addRenderingConstraint(RenderingConstraint constr)
           
 void addRenderingHint(RenderingHint hint)
           
 void bindActive(ValueBinding value)
          Bind the active property to a "live" value.
 void childChanged()
          Called by a child object if something in it or below it changes
 java.lang.Object clone()
           
 boolean equals(java.lang.Object o)
          Based on the uid
static java.util.Vector getBottomUpObjects(UiObject root)
           
static UiObject getCommonAncestor(UiObject o1, UiObject o2)
          Returns the deepest common ancestor of the two inputs
 java.io.Serializable getInterfaceIdentifier()
          Produces an object that uniquely identifies this interface; this identifier remains the same across sessions and is based on the structure of the interface.
static java.util.Vector getPath(UiObject source, UiObject dest)
          Returns a path from source to destination along the hierarchy treee.
 java.util.Vector getRenderingConstraints()
           
 java.util.Vector getRenderingHints()
           
 java.lang.String getTextLabel()
          Sets the visibility of this object (for renderings).
 SuppleType getType()
          Returns the Supple type of this object
 int getUniqueId()
          Returns a unique id of this instantiation.
 RenderedView getView()
          Returns the view that shows this UI object; usuall only the root knows directly abou the view so this object may need to ask up the hierarchy to get the information
 int hashCode()
          Based on the uid
 boolean hasTextLabel()
          Lets you check if the object has a meaningful text label
 boolean isActive()
          UiObjects (well, really StateVars and UiActions) can become inactive if some preconditions are not satisfied (e.g., you cannot execute an action, if it's parameters are not set).
 boolean isLeaf()
          A convenience method -- returns true if the corresponding type has no children (state vars or actions)
 boolean isModifiable()
           
 boolean isRuntime()
          Runtime objects are created on the fly to represent dynamic data objects -- they are unlikely to appear in other instances of the UI; their names are instance-specific
 void propertyChange(java.beans.PropertyChangeEvent event)
           
 void setActive(boolean a)
          Let's you change the active state of the UiObject
 void setRuntime(boolean r)
           
protected  void setType(SuppleType t)
           
 void setView(RenderedView view)
          Tells this object what view shows it -- should only be called by RenderedView objects themselves
 java.lang.String toPrettyString(java.lang.String pref)
           
 java.lang.String toString()
           
protected  void updateParent()
           
 void valueChanged(ValueBinding binding, java.lang.Object newValue)
          Signals variable change.
 
Methods inherited from class edu.washington.cs.supple.rep.SuppleUiObjectHierarchyElementImpl
getAncestors, getFullName, getName, getParent, getParentObject, getRootObject, isChildOf, isDescendantOf, isRoot, setName, setParent
 
Methods inherited from class edu.washington.cs.supple.rep.SuppleBeanImpl
addPropertyChangeListener, removePropertyChangeListener
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface edu.washington.cs.supple.rep.SuppleUiObjectHierarchyElement
getAncestors, getFullName, getName, getParent, getParentObject, getRootObject, isChildOf, isDescendantOf, isRoot, setName, setParent
 
Methods inherited from interface edu.washington.cs.supple.rep.SuppleBean
addPropertyChangeListener, removePropertyChangeListener
 

Field Detail

uniqueIdCounter

protected static int uniqueIdCounter

uniqueId

protected int uniqueId

type

protected SuppleType type

textLabel

protected java.lang.String textLabel

modifiable

protected boolean modifiable

hints

protected java.util.Vector hints

constraints

protected java.util.Vector constraints

runtime

protected boolean runtime

currentView

protected transient RenderedView currentView

active

protected boolean active

activeValue

protected transient ValueBinding activeValue

interfaceIdentifier

protected java.io.Serializable interfaceIdentifier
Constructor Detail

UiObjectImpl

public UiObjectImpl(SuppleType type,
                    java.lang.String label)
Constructor for elements that do not take a value

Parameters:
type - the type of this element
label - a text label
Method Detail

clone

public java.lang.Object clone()

isActive

public boolean isActive()
Description copied from interface: UiObject
UiObjects (well, really StateVars and UiActions) can become inactive if some preconditions are not satisfied (e.g., you cannot execute an action, if it's parameters are not set). This method lets you check if a UiObject is active.

Specified by:
isActive in interface UiObject
Returns:
true if active, false otherwise

setActive

public void setActive(boolean a)
Let's you change the active state of the UiObject

Specified by:
setActive in interface UiObject
Parameters:
a - new value

bindActive

public void bindActive(ValueBinding value)
Bind the active property to a "live" value.

Parameters:
value -

valueChanged

public void valueChanged(ValueBinding binding,
                         java.lang.Object newValue)
Description copied from interface: ValueListener
Signals variable change.

Specified by:
valueChanged in interface ValueListener
Parameters:
binding -
newValue -

getType

public SuppleType getType()
Returns the Supple type of this object

Specified by:
getType in interface UiObject
Returns:
the type of this object

getView

public RenderedView getView()
Returns the view that shows this UI object; usuall only the root knows directly abou the view so this object may need to ask up the hierarchy to get the information

Specified by:
getView in interface UiObject
Returns:
the view that shows this object

setView

public void setView(RenderedView view)
Tells this object what view shows it -- should only be called by RenderedView objects themselves

Specified by:
setView in interface UiObject
Parameters:
view - the view that shows this object

isLeaf

public boolean isLeaf()
A convenience method -- returns true if the corresponding type has no children (state vars or actions)

Specified by:
isLeaf in interface UiObject
Returns:
true if leaf, false otherwise

getTextLabel

public java.lang.String getTextLabel()
Sets the visibility of this object (for renderings).

Specified by:
getTextLabel in interface UiObject

hasTextLabel

public boolean hasTextLabel()
Lets you check if the object has a meaningful text label

Specified by:
hasTextLabel in interface UiObject
Returns:
true if text label is not null and at least one char long; false otherwise

setType

protected void setType(SuppleType t)

getInterfaceIdentifier

public java.io.Serializable getInterfaceIdentifier()
Produces an object that uniquely identifies this interface; this identifier remains the same across sessions and is based on the structure of the interface. At the moment it just returns the string signature.

Specified by:
getInterfaceIdentifier in interface UiObject
Returns:
the identifying object

isRuntime

public boolean isRuntime()
Runtime objects are created on the fly to represent dynamic data objects -- they are unlikely to appear in other instances of the UI; their names are instance-specific

Specified by:
isRuntime in interface UiObject
Returns:
true if this is a runtime object, false otherwise

setRuntime

public void setRuntime(boolean r)
Specified by:
setRuntime in interface UiObject

isModifiable

public boolean isModifiable()
Specified by:
isModifiable in interface UiObject

addRenderingHint

public void addRenderingHint(RenderingHint hint)
Specified by:
addRenderingHint in interface ConstraintManipulation

getRenderingHints

public java.util.Vector getRenderingHints()
Specified by:
getRenderingHints in interface ConstraintManipulation

addRenderingConstraint

public void addRenderingConstraint(RenderingConstraint constr)
Specified by:
addRenderingConstraint in interface ConstraintManipulation

getRenderingConstraints

public java.util.Vector getRenderingConstraints()
Specified by:
getRenderingConstraints in interface ConstraintManipulation

hashCode

public int hashCode()
Based on the uid

Specified by:
hashCode in interface UiObject
See Also:
Object.hashCode()

equals

public boolean equals(java.lang.Object o)
Based on the uid

Specified by:
equals in interface UiObject
See Also:
Object.equals(java.lang.Object)

toString

public java.lang.String toString()
Specified by:
toString in interface UiObject

toPrettyString

public java.lang.String toPrettyString(java.lang.String pref)
Specified by:
toPrettyString in interface UiObject

getCommonAncestor

public static UiObject getCommonAncestor(UiObject o1,
                                         UiObject o2)
Returns the deepest common ancestor of the two inputs

Parameters:
o1 - non-null interface object
o2 - non-null interface object
Returns:
the deepest (furthest from root) common ancestor or null if there is no common ancestor

getPath

public static java.util.Vector getPath(UiObject source,
                                       UiObject dest)
Returns a path from source to destination along the hierarchy treee. both source and destination are included in the path. If source and destination belong to different hierarchies and no path between them exists, an empty vector is returned.

Parameters:
source - source object
dest - destination object
Returns:
vector with source, destination and all intermediate nodes; an empty vector if no path exists

getBottomUpObjects

public static java.util.Vector getBottomUpObjects(UiObject root)

propertyChange

public void propertyChange(java.beans.PropertyChangeEvent event)
Specified by:
propertyChange in interface java.beans.PropertyChangeListener
Overrides:
propertyChange in class SuppleUiObjectHierarchyElementImpl

childChanged

public void childChanged()
Called by a child object if something in it or below it changes

Specified by:
childChanged in interface UiObject

updateParent

protected void updateParent()

getUniqueId

public int getUniqueId()
Returns a unique id of this instantiation.

Specified by:
getUniqueId in interface UiObject
Returns:
unique id

accept

public void accept(UiVisitor visitor)
Description copied from interface: UiObject
Accept a UiVisitor.

Specified by:
accept in interface UiObject

acceptBindingVisitor

protected void acceptBindingVisitor(UiVisitor visitor)
Helper for accept() - allows subclasses to extend the bindings to be visited without overriding accept().