|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface Settable
This is an interface for attributes that can have their values externally set. An attribute class that implements this interface has to be able to have a value set by a string, via the setExpression() method. A string representation is returned by the getExpression() method. An expression may be an ordinary string with no further interpretation, or it may be a string that needs to be evaluated. In the latter case, an implementation of this attribute may not evaluate the string when the setExpression() method is called. It may instead only evaluate the string when the validate() method is called. Often this will not be called until the value of the expression is actually needed (this is known as "lazy evaluation"). Such an implementation will defer notification of listeners and the container until the string is evaluated. In a typical use of this interface, therefore, it is necessary to be sure that validate() is called sometime after setExpression() is called.
In addition, an attribute class that implements this interface needs to maintain a list of listeners that are informed whenever the value of the attribute changes. It should inform those listeners whenever setExpression() is called.
Among other uses, this interface marks attributes whose value can be set via the value attribute of a MoML property element. For example, if class XXX implements Settable, then the following is valid MoML:
<property name="xxx" class="XXX" value="yyy"/>
This interface also supports annotations that hint to a user interface the level of visibility that an instance should have. The visibility is specified as one of the static instances of the inner class Visibility, currently NONE, EXPERT, FULL, and NOT_EDITABLE NONE indicates that the user should never see the instance, and should not be able to set its value through the user interface. EXPERT means that only expert users should see the instance. FULL means that the instance is always visible, and a user interface should always allow it to be set. NOT_EDITABLE is similar to FULL, except that the value of the expression is visible, but not editable by the user. This is commonly used for feedback from the model.
Green (cxh) |
Green (eal) |
Nested Class Summary | |
---|---|
static class |
Settable.Visibility
Inner class used for the static enumeration of indicators of visibility. |
Field Summary | |
---|---|
static Settable.Visibility |
EXPERT
Indicator that a user interface should make an instance visible only to experts. |
static Settable.Visibility |
FULL
Indicator that a user interface should make an instance visible. |
static Settable.Visibility |
NONE
Indicator that a user interface should not make an instance visible. |
static Settable.Visibility |
NOT_EDITABLE
Indicator that a user interface should make an instance visible, but not allow editing of the variable. |
Method Summary | |
---|---|
void |
addValueListener(ValueListener listener)
Add a listener to be notified when the value of this settable object changes. |
java.lang.String |
getDefaultExpression()
Return the default value of this attribute, if there is one, or null if there is none. |
java.lang.String |
getDisplayName()
Return a name to present to the user. |
java.lang.String |
getExpression()
Get the expression of the attribute that has been set by setExpression(), or null if there is none. |
java.lang.String |
getValueAsString()
Get the value of the attribute, which is the evaluated expression. |
Settable.Visibility |
getVisibility()
Get the visibility of this Settable, as set by setVisibility(). |
void |
removeValueListener(ValueListener listener)
Remove a listener from the list of listeners that are notified when the value of this variable changes. |
void |
setExpression(java.lang.String expression)
Set the value of the attribute by giving some expression. |
void |
setVisibility(Settable.Visibility visibility)
Set the visibility of this Settable. |
java.util.Collection |
validate()
Check the validity of the expression set in setExpression(). |
Methods inherited from interface ptolemy.kernel.util.Nameable |
---|
description, getContainer, getFullName, getName, getName, setName |
Field Detail |
---|
static final Settable.Visibility NONE
static final Settable.Visibility EXPERT
static final Settable.Visibility FULL
static final Settable.Visibility NOT_EDITABLE
Method Detail |
---|
void addValueListener(ValueListener listener)
listener
- The listener to add.removeValueListener(ValueListener)
java.lang.String getDefaultExpression()
java.lang.String getDisplayName()
getDisplayName
in interface Nameable
java.lang.String getExpression()
setExpression(String)
java.lang.String getValueAsString()
getExpression()
Settable.Visibility getVisibility()
setVisibility(Settable.Visibility)
void removeValueListener(ValueListener listener)
listener
- The listener to remove.addValueListener(ValueListener)
void setExpression(java.lang.String expression) throws IllegalActionException
expression
- The value of the attribute.
IllegalActionException
- If the expression is invalid.getExpression()
void setVisibility(Settable.Visibility visibility)
visibility
- The visibility of this Settable.getVisibility()
java.util.Collection validate() throws IllegalActionException
IllegalActionException
- If the expression is not valid, or
its value is not acceptable to the container or the listeners.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |