Search this API

y.option
Class ConstraintManager

java.lang.Object
  extended by y.option.ConstraintManager

public class ConstraintManager
extends java.lang.Object

Provides convenience methods for creating editor constraints.

 

Nested Class Summary
static class ConstraintManager.Condition
          A Condition that can be used to trigger or control different behavior.
static interface ConstraintManager.ConditionCheck
          Implementations of this interface are queried by the ConstraintManager as soon as properties of an editor change.
static interface ConstraintManager.EditorAction
          An action-callback that is invoked in response to either performActionOnPropertyChange(y.option.ConstraintManager.EditorAction, OptionItem) or performActionOnCondition(y.option.ConstraintManager.EditorAction, y.option.ConstraintManager.Condition).
 
Constructor Summary
ConstraintManager(OptionHandler handler)
          Creates a new instance of ConstraintManager for the specified option handler.
 
Method Summary
 ConstraintManager.Condition createCondition(OptionItem item, ConstraintManager.ConditionCheck check)
          Creates a Condition whose value is calculated by the given checker when a property of the indicated item changes.
 ConstraintManager.Condition createConditionValueEquals(OptionItem source, java.lang.Object value)
          Creates a Condition object that yields true if the source item changes its value to the given value.
 ConstraintManager.Condition createConditionValueEquals(OptionItem source, java.lang.Object value, boolean reverse)
          Creates a Condition object that yields true if the source item changes its value to the given value.
 ConstraintManager.Condition createConditionValueEquals(java.lang.String source, java.lang.Object value)
          Creates a Condition object that yields true if the item which is identified by the source parameter changes its value to the given value.
 ConstraintManager.Condition createConditionValueIs(OptionItem source, java.util.Collection values)
          Creates a Condition object that yields true if the source item changes its value to one of the values from the provided collection.
 ConstraintManager.Condition createConditionValueIs(OptionItem source, java.util.Collection values, boolean reverse)
          Creates a Condition object that yields true if the source item changes its value to one of the values from the provided collection of values.
 ConstraintManager.Condition createConditionValueIs(OptionItem source, java.lang.Object[] values)
          Creates a Condition object that yields true if the source item changes its value to one of the values from the provided array of values.
 ConstraintManager.Condition createConditionValueIs(java.lang.String source, java.util.Collection values)
          Creates a Condition object that yields true if the source item changes its value to one of the values from the provided collection.
 ConstraintManager.Condition createConditionValueIs(java.lang.String source, java.lang.Object[] values)
          Creates a Condition object that yields true if the source item changes its value to one of the values from the provided array of values.
 OptionHandler getHandler()
          Returns the option handler for which this manager was created.
protected  void installConstraints(Editor editor)
          Tries to install all previously created constraints for the specified editor.
 void performActionOnCondition(ConstraintManager.EditorAction editorAction, ConstraintManager.Condition condition)
          Registers an action that will be triggered as soon as the condition changes to true
 void performActionOnPropertyChange(ConstraintManager.EditorAction editorAction, OptionItem onItem)
          Registers an action that will be triggered as soon as there is a property change on the editor of the given item.
 void setEnabledOnCondition(ConstraintManager.Condition c, OptionGroup target)
          Creates a constraint that is triggered when the value of the condition changes.
 void setEnabledOnCondition(ConstraintManager.Condition c, OptionItem target)
          Creates a constraint that is triggered when the value of the condition changes.
 void setEnabledOnValueEquals(OptionItem source, java.lang.Object value, OptionGroup target)
          Creates a constraint that is triggered when the value of the source item is changed.
 void setEnabledOnValueEquals(OptionItem source, java.lang.Object value, OptionGroup target, boolean invert)
          Creates a constraint that is triggered when the value of the source item is changed.
 void setEnabledOnValueEquals(OptionItem source, java.lang.Object value, OptionItem target)
          Creates a constraint that is triggered when the value of the source item is changed.
 void setEnabledOnValueEquals(OptionItem source, java.lang.Object value, OptionItem target, boolean invert)
          Creates a constraint that is triggered when the value of the source item is changed.
 void setEnabledOnValueEquals(java.lang.String source, java.lang.Object value, OptionGroup target)
          Creates a constraint that is triggered when the value of the source item is changed.
 void setEnabledOnValueEquals(java.lang.String source, java.lang.Object value, OptionGroup target, boolean invert)
          Creates a constraint that is triggered when the value of the source item is changed.
 void setEnabledOnValueEquals(java.lang.String source, java.lang.Object value, java.lang.String target)
          Creates a constraint that is triggered when the value of the source item is changed.
 void setEnabledOnValueEquals(java.lang.String source, java.lang.Object value, java.lang.String target, boolean invert)
          Creates a constraint that is triggered when the value of the source item is changed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConstraintManager

public ConstraintManager(OptionHandler handler)
Creates a new instance of ConstraintManager for the specified option handler.

Parameters:
handler - the handler this ConstraintManager instance is associated with
Method Detail

getHandler

public OptionHandler getHandler()
Returns the option handler for which this manager was created.

Returns:
the option handler for which this manager was created

setEnabledOnValueEquals

public void setEnabledOnValueEquals(java.lang.String source,
                                    java.lang.Object value,
                                    java.lang.String target)
Creates a constraint that is triggered when the value of the source item is changed. The triggered constraint will set the enabled property of the target item.

Parameters:
source - the name of the OptionItem used as constraint condition
value - the value that triggers the constraint action
target - the name of the OptionItem to set the enabled state

setEnabledOnValueEquals

public void setEnabledOnValueEquals(java.lang.String source,
                                    java.lang.Object value,
                                    java.lang.String target,
                                    boolean invert)
Creates a constraint that is triggered when the value of the source item is changed. The triggered constraint will set the enabled property of the target item.

Parameters:
source - the name of the OptionItem used as constraint condition
value - the value that triggers the constraint action
target - the name of the OptionItem to receive the constraint action
invert - if true, setEnabled( false ) will be invoked on target; else setEnabled( true ) will be invoked on

setEnabledOnCondition

public void setEnabledOnCondition(ConstraintManager.Condition c,
                                  OptionItem target)
Creates a constraint that is triggered when the value of the condition changes. The value of the condition will set the enabled property of the target item.

Parameters:
c - the condition to query
target - the target item to enable depending on the state of the condition

setEnabledOnCondition

public void setEnabledOnCondition(ConstraintManager.Condition c,
                                  OptionGroup target)
Creates a constraint that is triggered when the value of the condition changes. The value of the condition will set the enabled property of all items contained in the target group

Parameters:
c - the condition to query
target - the target group to enable depending on the state of the condition

createConditionValueEquals

public ConstraintManager.Condition createConditionValueEquals(java.lang.String source,
                                                              java.lang.Object value)
Creates a Condition object that yields true if the item which is identified by the source parameter changes its value to the given value.

Parameters:
source - the name of the item
value - the value used for comparison
Returns:
a Condition object that can be used to create more sophisticated conditions

createConditionValueEquals

public ConstraintManager.Condition createConditionValueEquals(OptionItem source,
                                                              java.lang.Object value)
Creates a Condition object that yields true if the source item changes its value to the given value.

Parameters:
source - the item to inspect
value - the value used for comparison
Returns:
a Condition object that can be used to create more sophisticated conditions

createConditionValueEquals

public ConstraintManager.Condition createConditionValueEquals(OptionItem source,
                                                              java.lang.Object value,
                                                              boolean reverse)
Creates a Condition object that yields true if the source item changes its value to the given value. If the reverse parameter is true the behavior is reversed.

Parameters:
source - the item to inspect
value - the value used for comparison
Returns:
a Condition object that can be used to create more sophisticated conditions

createConditionValueIs

public ConstraintManager.Condition createConditionValueIs(java.lang.String source,
                                                          java.util.Collection values)
Creates a Condition object that yields true if the source item changes its value to one of the values from the provided collection.

Parameters:
source - the item to inspect
values - the value used for comparison
Returns:
a Condition object that can be used to create more sophisticated conditions

createConditionValueIs

public ConstraintManager.Condition createConditionValueIs(OptionItem source,
                                                          java.util.Collection values)
Creates a Condition object that yields true if the source item changes its value to one of the values from the provided collection.

Parameters:
source - the item to inspect
values - the value used for comparison
Returns:
a Condition object that can be used to create more sophisticated conditions

createConditionValueIs

public ConstraintManager.Condition createConditionValueIs(java.lang.String source,
                                                          java.lang.Object[] values)
Creates a Condition object that yields true if the source item changes its value to one of the values from the provided array of values.

Parameters:
source - the item to inspect
values - the value used for comparison
Returns:
a Condition object that can be used to create more sophisticated conditions

createConditionValueIs

public ConstraintManager.Condition createConditionValueIs(OptionItem source,
                                                          java.lang.Object[] values)
Creates a Condition object that yields true if the source item changes its value to one of the values from the provided array of values.

Parameters:
source - the item to inspect
values - the value used for comparison
Returns:
a Condition object that can be used to create more sophisticated conditions

createConditionValueIs

public ConstraintManager.Condition createConditionValueIs(OptionItem source,
                                                          java.util.Collection values,
                                                          boolean reverse)
Creates a Condition object that yields true if the source item changes its value to one of the values from the provided collection of values. If the reverse parameter is true the behavior is reversed.

Parameters:
source - the item to inspect
values - the value used for comparison
reverse - true iff the condition's state should be reversed
Returns:
a Condition object that can be used to create more sophisticated conditions

createCondition

public ConstraintManager.Condition createCondition(OptionItem item,
                                                   ConstraintManager.ConditionCheck check)
Creates a Condition whose value is calculated by the given checker when a property of the indicated item changes.

Parameters:
item - the item whose property changes will be observed
check - an object that yields the current state of the condition
Returns:
a Condition object

setEnabledOnValueEquals

public void setEnabledOnValueEquals(OptionItem source,
                                    java.lang.Object value,
                                    OptionItem target)
Creates a constraint that is triggered when the value of the source item is changed. The triggered constraint will set the enabled property of the target item.

Parameters:
source - the OptionItem used as constraint condition
value - the value that triggers the constraint action
target - the OptionItem to set the enabled state

setEnabledOnValueEquals

public void setEnabledOnValueEquals(OptionItem source,
                                    java.lang.Object value,
                                    OptionItem target,
                                    boolean invert)
Creates a constraint that is triggered when the value of the source item is changed. The triggered constraint will set the enabled property of the target item.

Parameters:
source - the OptionItem used as constraint condition
value - the value that triggers the constraint action
target - the OptionItem to receive the constraint action
invert - if true, setEnabled( false ) will be invoked on target; else setEnabled( true ) will be invoked on

setEnabledOnValueEquals

public void setEnabledOnValueEquals(java.lang.String source,
                                    java.lang.Object value,
                                    OptionGroup target)
Creates a constraint that is triggered when the value of the source item is changed. The triggered constraint will set the enabled property of the target item.

Parameters:
source - the name of the OptionItem used as constraint condition
value - the value that triggers the constraint action
target - the OptionGroup to set the enabled state

setEnabledOnValueEquals

public void setEnabledOnValueEquals(java.lang.String source,
                                    java.lang.Object value,
                                    OptionGroup target,
                                    boolean invert)
Creates a constraint that is triggered when the value of the source item is changed. The triggered constraint will set the enabled property of the target item.

Parameters:
source - the name of the OptionItem used as constraint condition
value - the value that triggers the constraint action
target - the OptionGroup to receive the constraint action
invert - if true, setEnabled( false ) will be invoked on target; else setEnabled( true ) will be invoked on

setEnabledOnValueEquals

public void setEnabledOnValueEquals(OptionItem source,
                                    java.lang.Object value,
                                    OptionGroup target)
Creates a constraint that is triggered when the value of the source item is changed. The triggered constraint will set the enabled property of the target item.

Parameters:
source - the OptionItem used as constraint condition
value - the value that triggers the constraint action
target - the OptionGroup to set the enabled state

setEnabledOnValueEquals

public void setEnabledOnValueEquals(OptionItem source,
                                    java.lang.Object value,
                                    OptionGroup target,
                                    boolean invert)
Creates a constraint that is triggered when the value of the source item is changed. The triggered constraint will set the enabled property of the target item.

Parameters:
source - the OptionItem used as constraint condition
value - the value that triggers the constraint action
target - the OptionGroup to receive the constraint action
invert - if true, setEnabled( false ) will be invoked on target; else setEnabled( true ) will be invoked on

performActionOnPropertyChange

public void performActionOnPropertyChange(ConstraintManager.EditorAction editorAction,
                                          OptionItem onItem)
Registers an action that will be triggered as soon as there is a property change on the editor of the given item.

Parameters:
editorAction - the action to perform if the corresponding item fires a property change event
onItem - the item whose editor instances will be observed

performActionOnCondition

public void performActionOnCondition(ConstraintManager.EditorAction editorAction,
                                     ConstraintManager.Condition condition)
Registers an action that will be triggered as soon as the condition changes to true

Parameters:
editorAction - the action to perform if the corresponding item fires a property change event
condition - the condition that will be observed

installConstraints

protected void installConstraints(Editor editor)
Tries to install all previously created constraints for the specified editor.
This method is called on editorAdded notifications.


© Copyright 2000-2022,
yWorks GmbH.
All rights reserved.