com.tensegrity.gui.swing.customattribute
Class ItemListAttribute

java.lang.Object
  extended bycom.tensegrity.gui.swing.customattribute.ItemListAttribute
All Implemented Interfaces:
Attribute, java.lang.Cloneable, CustomAttribute, Restrictable

public class ItemListAttribute
extends java.lang.Object
implements CustomAttribute

ItemListAttribute

: An attribute with a list of possible values. The editor is a combobox. A generator key can be set in the constructor. The string representation is determined by calling toString() on the object stringRepresentation that is passed to the constructor.

Author:
BurkhardWick

Constructor Summary
ItemListAttribute(java.lang.Object[] items, java.lang.String name, java.lang.Object value, java.lang.String generatorKey, java.lang.Object stringRepresentation)
          Constructor
 
Method Summary
 java.lang.Object clone()
          Clones this attribute.
 java.lang.Object cloneValue()
          Clones this attribute's value.
 Constraint getConstraint()
          Returns the root of the constraint tree.
 CustomAttributeEditor getEditor()
          Method getEditor returns an instance of a CustomAttributeEditor which the AttributeTree will use to allow users to edit this attribute.
 java.lang.String getGeneratorKey()
          Returns a String which will be used as key to retrieve the generator for this CustomAttribute.
 java.lang.String getName()
          Returns the Attribute name.
 CustomAttributeRenderer getRenderer()
          Returns an instance of a CustomAttributeRenderer which the AttributeTree uses to render values of this attribute.
 java.lang.String getStringRepresentation()
          Returns a String representation for the value of this attribute, which will be used to create an instance of this attribute via the CustomAttributeGenerator.
 AttributeType getType()
          Returns the current value's type.
 java.lang.Object getValue()
          Returns the Attribute value.
 boolean isMutable()
          Returns the mutable flag that indicates whether the attribute is mutable or immutable.
 java.lang.Object newValueInstance()
          Creates a new instance of the value part of the CustomAttribute.
 void setConstraint(Constraint constraint)
          Sets the root of the constraint tree.
 void setMutable(boolean mutable)
          Sets the mutable flag that indicates whether the attribute is mutable or immutable.
 void setName(java.lang.String name)
          Sets the name of this attribute.
 void setValue(java.lang.Object value)
          Sets the Attribute value.
 boolean useDefaultEditor()
          If the CustomAttribute does not implement its own editor, it can use the default editors if the value is one of the recognized types (e.g.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ItemListAttribute

public ItemListAttribute(java.lang.Object[] items,
                         java.lang.String name,
                         java.lang.Object value,
                         java.lang.String generatorKey,
                         java.lang.Object stringRepresentation)
Constructor

Parameters:
items - The possible values
name - The name
value - The current value
generatorKey - The generator key
stringRepresentation - The method toString() of this object is used to determine the string representation that is stored to file
Method Detail

getEditor

public CustomAttributeEditor getEditor()
Description copied from interface: CustomAttribute
Method getEditor returns an instance of a CustomAttributeEditor which the AttributeTree will use to allow users to edit this attribute. The method returns null if no such editor exists and the attribute is not editable or the default editor should be used.

Specified by:
getEditor in interface CustomAttribute
Returns:
a CustomAttributeEditor for this attribute.

useDefaultEditor

public boolean useDefaultEditor()
Description copied from interface: CustomAttribute
If the CustomAttribute does not implement its own editor, it can use the default editors if the value is one of the recognized types (e.g. String, Integer, etc.)

Specified by:
useDefaultEditor in interface CustomAttribute
Returns:
true to use the default editors if the method CustomAttribute.getEditor() returns null

getRenderer

public CustomAttributeRenderer getRenderer()
Description copied from interface: CustomAttribute
Returns an instance of a CustomAttributeRenderer which the AttributeTree uses to render values of this attribute. The method returns null if no such renderer exists and the default renderer should be used. A renderer is required if the Attribute cannot be rendered by the standard renderer of the Table.

Specified by:
getRenderer in interface CustomAttribute
Returns:
a CustomAttributeRenderer for this attribute.

getStringRepresentation

public java.lang.String getStringRepresentation()
Description copied from interface: CustomAttribute
Returns a String representation for the value of this attribute, which will be used to create an instance of this attribute via the CustomAttributeGenerator.

Specified by:
getStringRepresentation in interface CustomAttribute
Returns:
a String representation of this attribute.

getGeneratorKey

public java.lang.String getGeneratorKey()
Description copied from interface: CustomAttribute
Returns a String which will be used as key to retrieve the generator for this CustomAttribute. Applications should use this key to provide a registry-alike mechanism to obtain generators.

Specified by:
getGeneratorKey in interface CustomAttribute
Returns:
a String usable as a key for this attribute.

newValueInstance

public java.lang.Object newValueInstance()
Description copied from interface: CustomAttribute
Creates a new instance of the value part of the CustomAttribute. This is needed when instances of this Attribute need to be added and an instance of the value part is required.

Specified by:
newValueInstance in interface CustomAttribute
Returns:
an Object for the value part of this attribute.

setName

public void setName(java.lang.String name)
Description copied from interface: CustomAttribute
Sets the name of this attribute.

Specified by:
setName in interface CustomAttribute
Parameters:
name - String for the new name.

getType

public AttributeType getType()
Description copied from interface: Attribute
Returns the current value's type.

Specified by:
getType in interface Attribute
Returns:
the type of the current value.

getName

public java.lang.String getName()
Description copied from interface: Attribute
Returns the Attribute name.

Specified by:
getName in interface Attribute
Returns:
the name of the attribute.

getValue

public java.lang.Object getValue()
Description copied from interface: Attribute
Returns the Attribute value.

Specified by:
getValue in interface Attribute
Returns:
the value of this attribute.

setValue

public void setValue(java.lang.Object value)
              throws IllegalValueException,
                     ConstraintViolationException
Description copied from interface: Attribute
Sets the Attribute value.

Specified by:
setValue in interface Attribute
Parameters:
value - the new value of the attribute.
Throws:
IllegalValueException - if the attribute value is invalid.
ConstraintViolationException - thrown if the constraint of this attribute does not permit setting the new value.

cloneValue

public java.lang.Object cloneValue()
                            throws java.lang.CloneNotSupportedException
Description copied from interface: Attribute
Clones this attribute's value. Usually a deep copy is returned. The value object itself can decide what is to be considered a deep-copy. Sometimes in case of (nested) references to immutable objects a deep-copy may be the same as a shallow-copy.

Specified by:
cloneValue in interface Attribute
Returns:
a deep copy of this attribute's value.
Throws:
java.lang.CloneNotSupportedException - may be thrown if invoking this method on the value is not allowed or supported.

isMutable

public boolean isMutable()
Description copied from interface: Attribute
Returns the mutable flag that indicates whether the attribute is mutable or immutable.

Specified by:
isMutable in interface Attribute
Returns:
true, if it is mutable; false, if it is immutable.

setMutable

public void setMutable(boolean mutable)
Description copied from interface: Attribute
Sets the mutable flag that indicates whether the attribute is mutable or immutable.

Specified by:
setMutable in interface Attribute
Parameters:
mutable - the new value of the mutable flag.

setConstraint

public void setConstraint(Constraint constraint)
Description copied from interface: Restrictable
Sets the root of the constraint tree.

Specified by:
setConstraint in interface Restrictable
Parameters:
constraint - the root of the constraint tree

getConstraint

public Constraint getConstraint()
Description copied from interface: Restrictable
Returns the root of the constraint tree.

Specified by:
getConstraint in interface Restrictable
Returns:
the root of the constraint tree

clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
Description copied from interface: Attribute
Clones this attribute. The name of the attribute is not deep-copied, as String instances are immutable. The value of the attribute is copied by means of the clone method of Object.

Specified by:
clone in interface Attribute
Throws:
java.lang.CloneNotSupportedException


Copyright © 2005 Tensegrity Software GmbH. All Rights Reserved. Date of creation: 09.06.2006.