|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectplugins.adufour.ezplug.EzComponent
plugins.adufour.ezplug.EzVar<T>
public abstract class EzVar<T>
Class defining a variable for use within an EzPlug.
EzVar objects are powerful components that bind each parameter type to a specific graphical
component that can be used to receive input from the user interface. It is designed to be used by
plug-in developers in a simple and fast manner with zero knowledge in graphical interface
programming.
A wide-range of EzVar subclasses are available, depending on the type of data to handle
(numerical value, boolean flags, image sequences, file arrays, etc.). Advanced developers may
also contribute to the EzVar class hierarchy by implementing additional variable types to fit
their needs and that of others.
EzVar objects are always instantiated using the subclass corresponding to the parameter type to
use. Once created, the variable can be added to the graphical interface of the EzPlug via the
EzPlug.addEzComponent(EzComponent)
method (see sample code in the
EzPlug
class documentation).
Field Summary |
---|
Fields inherited from class plugins.adufour.ezplug.EzComponent |
---|
name, visible |
Constructor Summary | |
---|---|
protected |
EzVar(Var<T> variable,
T[] defaultValues,
int defaultValueIndex,
boolean freeInput)
Creates a new variable with a JComboBox as default graphical component |
protected |
EzVar(Var<T> variable,
VarEditorModel<T> constraint)
Constructs a new variable |
Method Summary | |
---|---|
protected void |
addTo(java.awt.Container container)
|
void |
addVarChangeListener(EzVarListener<T> listener)
Adds a new listener that will be notified is this variable changes |
void |
addVisibilityTriggerTo(EzComponent targetComponent,
T... values)
Sets a visibility trigger on the target EzComponent. |
protected void |
dispose()
|
protected void |
fireVariableChanged(T value)
|
T[] |
getDefaultValues(T[] dest)
Retrieves the default values into the destination array, or returns a new one if dest is not big enough. |
T |
getValue()
Returns the variable value. |
T |
getValue(boolean forbidNull)
Returns the variable value (or fails if the variable is null). |
protected VarEditor<T> |
getVarEditor()
|
Var<T> |
getVariable()
|
boolean |
isEnabled()
Indicates whether this variable is enabled, and therefore may be used by plug-ins. |
void |
referenceChanged(Var<T> source,
Var<? extends T> oldReference,
Var<? extends T> newReference)
Called when the variable reference changes |
void |
removeAllVarChangeListeners()
Removes all change listeners for this variable |
void |
removeVarChangeListener(EzVarListener<T> listener)
Removes the given listener from the list |
void |
setDefaultValues(T[] values,
int defaultValueIndex,
boolean allowUserInput)
Replaces the list of values available in the combo box of this variable NOTE: this method has no effect if the user component is not already a combo box |
void |
setEnabled(boolean enabled)
Sets whether the variable is enabled, i.e. |
void |
setOptional(boolean optional)
Sets a flag indicating whether this variable should be considered "optional". |
void |
setToolTipText(java.lang.String text)
Assigns a tool-tip text to the variable, which pops up when the user hovers the mouse on it. |
void |
setValue(T value)
Sets the new value of this variable |
void |
setVisible(boolean newVisibleState)
Sets the visibility state of this variable, and updates the chain of visibility states (components hiding other components) |
java.lang.String |
toString()
|
protected void |
updateVisibilityChain()
|
void |
valueChanged(Var<T> source,
T oldValue,
T newValue)
Called when the value of the source variable changes |
Methods inherited from class plugins.adufour.ezplug.EzComponent |
---|
getGroup, getVisible, isVisible, setGroup |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
protected EzVar(Var<T> variable, VarEditorModel<T> constraint)
variable
- The variable to attach to this objectconstraint
- the constraint to apply on the variable when receiving input, or null if a default
constraint should be appliedprotected EzVar(Var<T> variable, T[] defaultValues, int defaultValueIndex, boolean freeInput)
variable
- the variable to attach to this EzVardefaultValues
- the list of values to store in the combo boxdefaultValueIndex
- the index of the default selected itemfreeInput
- true to allow user manual input, false to restrict the selection to the given listMethod Detail |
---|
public void addVarChangeListener(EzVarListener<T> listener)
listener
- the listener to addpublic void addVisibilityTriggerTo(EzComponent targetComponent, T... values)
targetComponent
- the component to hide or showvalues
- the list of values which will set the visibility of the target component to true.
If no value is indicated, the target component will be visible as long as the
source component is both visible and enabledprotected void addTo(java.awt.Container container)
addTo
in class EzComponent
protected void dispose()
dispose
in class EzComponent
protected final void fireVariableChanged(T value)
public T[] getDefaultValues(T[] dest)
dest
- the array to fill with the values. the array is left untouched if it is not big
enough
java.lang.UnsupportedOperationException
- if the user input component is not a combo boxprotected VarEditor<T> getVarEditor()
public T getValue()
getValue(boolean)
method instead
public T getValue(boolean forbidNull) throws EzException
forbidNull
- set to true to display an error message (or to throw an exception in head-less
mode)
EzException
- if the variable value is null and forbidNull is truepublic Var<T> getVariable()
public boolean isEnabled()
true
if this variable is enabled, false
otherwisepublic void removeVarChangeListener(EzVarListener<T> listener)
listener
- the listener to removepublic void removeAllVarChangeListeners()
public void setDefaultValues(T[] values, int defaultValueIndex, boolean allowUserInput)
values
- defaultValueIndex
- allowUserInput
- public void setEnabled(boolean enabled)
enabled
- the enabled statepublic void setOptional(boolean optional)
optional
- true
if this parameter is optional, false
otherwisepublic void setValue(T value) throws java.lang.UnsupportedOperationException
value
- the new value
java.lang.UnsupportedOperationException
- thrown if changing the variable value from code is not supported (or not yet
implemented)public void setToolTipText(java.lang.String text)
EzComponent
setToolTipText
in class EzComponent
text
- the text to display (usually no more than 20 words)public void setVisible(boolean newVisibleState)
setVisible
in class EzComponent
newVisibleState
- the new visibility statepublic java.lang.String toString()
toString
in class java.lang.Object
protected void updateVisibilityChain()
public void valueChanged(Var<T> source, T oldValue, T newValue)
VarListener
valueChanged
in interface VarListener<T>
source
- the variable firing the listeneroldValue
- the old variable valuenewValue
- the new variable valuepublic void referenceChanged(Var<T> source, Var<? extends T> oldReference, Var<? extends T> newReference)
VarListener
referenceChanged
in interface VarListener<T>
source
- the variable firing the listeneroldReference
- the old variable referencenewReference
- the new variable reference
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |