net.sf.doolin.gui.display
Class ConditionalDisplayStateHandler

java.lang.Object
  extended by net.sf.doolin.gui.display.AbstractDisplayStateHandler
      extended by net.sf.doolin.gui.display.ConditionalDisplayStateHandler
All Implemented Interfaces:
DisplayStateHandler

public class ConditionalDisplayStateHandler
extends AbstractDisplayStateHandler

Handler that evaluates a condition on a property of the context.

Author:
Damien Coraboeuf

Constructor Summary
ConditionalDisplayStateHandler()
           
 
Method Summary
 DisplayState getDisplayState(ActionContext actionContext)
          Gets the current DisplayState for the given action context
 DisplayState getIfFalseState()
          Gets the if false state.
 DisplayState getIfTrueState()
          Gets the if true state.
 Object getOperand()
          Gets the operand.
 String getOperandPath()
          Gets the path to the property that contains the operand.
 String getOperandValue()
          Gets the operand value as a String.
 ConditionalOperator getOperator()
          Gets the operator.
protected  Object getOtherValue(Object data)
          Gets the value for the operand.
 String getPropertyPath()
          Gets the property path.
 boolean isReadOnly()
          Returns if the target property is read-only
 void setIfFalseState(DisplayState ifFalseState)
          Display state to return when condition is evaluated to false
 void setIfTrueState(DisplayState ifTrueState)
          Display state to return when condition is evaluated to true
 void setOperand(Object operand)
          Sets the operand for the operator.
 void setOperandPath(String operandPath)
          Sets the path to the property that contains the operand value
 void setOperandValue(String operandValue)
          Sets the operand value as a String.
 void setOperator(ConditionalOperator operator)
          Sets the operator to use.
 void setPropertyPath(String propertyPath)
          Sets the path to the property in the context.
 void setReadOnly(boolean readOnly)
          Sets if the target property is read-only
 void subscribe(ActionContext actionContext, Runnable task)
          Subscribes a task that is executed each time this display state handler changes its state.
 
Methods inherited from class net.sf.doolin.gui.display.AbstractDisplayStateHandler
connect, connect
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConditionalDisplayStateHandler

public ConditionalDisplayStateHandler()
Method Detail

getDisplayState

public DisplayState getDisplayState(ActionContext actionContext)
Description copied from interface: DisplayStateHandler
Gets the current DisplayState for the given action context

Parameters:
actionContext - Action context.
Returns:
Display state

getIfFalseState

public DisplayState getIfFalseState()
Gets the if false state.

Returns:
the if false state

getIfTrueState

public DisplayState getIfTrueState()
Gets the if true state.

Returns:
the if true state

getOperand

public Object getOperand()
Gets the operand.

Returns:
the operand

getOperandPath

public String getOperandPath()
Gets the path to the property that contains the operand.

Returns:
Property path

getOperandValue

public String getOperandValue()
Gets the operand value as a String.

Returns:
Operand value

getOperator

public ConditionalOperator getOperator()
Gets the operator.

Returns:
the operator

getPropertyPath

public String getPropertyPath()
Gets the property path.

Returns:
the property path

isReadOnly

public boolean isReadOnly()
Returns if the target property is read-only

Returns:
true if the target property is read-only

setIfFalseState

public void setIfFalseState(DisplayState ifFalseState)
Display state to return when condition is evaluated to false

Parameters:
ifFalseState - Display state to return when condition is evaluated to true

setIfTrueState

public void setIfTrueState(DisplayState ifTrueState)
Display state to return when condition is evaluated to true

Parameters:
ifTrueState - Display state to return when condition is evaluated to true

setOperand

public void setOperand(Object operand)
Sets the operand for the operator.

Parameters:
operand - the new operand

setOperandPath

public void setOperandPath(String operandPath)
Sets the path to the property that contains the operand value

Parameters:
operandPath - Property path

setOperandValue

public void setOperandValue(String operandValue)
Sets the operand value as a String.

Parameters:
operandValue - Operand value

setOperator

public void setOperator(ConditionalOperator operator)
Sets the operator to use.

Parameters:
operator - the new operator

setPropertyPath

public void setPropertyPath(String propertyPath)
Sets the path to the property in the context.

Parameters:
propertyPath - the new property path

setReadOnly

public void setReadOnly(boolean readOnly)
Sets if the target property is read-only

Parameters:
readOnly - true if the target property is read-only

subscribe

public void subscribe(ActionContext actionContext,
                      Runnable task)
Description copied from interface: DisplayStateHandler
Subscribes a task that is executed each time this display state handler changes its state.

Parameters:
actionContext - Action context for this display state handler
task - Task to run each time the state change

getOtherValue

protected Object getOtherValue(Object data)
Gets the value for the operand. The order of priority is the following:
  1. Gets the operand value specified as a String
  2. Gets the operand value defined by a property on the given data
  3. Gets the direct operand value

Parameters:
data - Bean to get the property from (if needed)
Returns:
Operand value to actually use


Copyright © 2011. All Rights Reserved.