com.guiseframework.coupler
Class AbstractCardCoupler

java.lang.Object
  extended by com.globalmentor.beans.BoundPropertyObject
      extended by com.guiseframework.event.GuiseBoundPropertyObject
          extended by com.guiseframework.coupler.AbstractCardCoupler
All Implemented Interfaces:
com.globalmentor.beans.PropertyBindable, com.globalmentor.beans.PropertyConstrainable
Direct Known Subclasses:
ActionCardCoupler, ListSelectCardCoupler

public class AbstractCardCoupler
extends GuiseBoundPropertyObject

Abstract coupler to one or more cards in a CardControl. This coupler is only functional when the given card is contained within a CardControl. This coupler can behave as if a single card or multiple cards are connected, firing both the CARD_PROPERTY and CARDS_PROPERTY property change events when cards are changed. If the card change results in the same card in the first position in the list, the CARD_PROPERTY is not fired.

Author:
Garret Wilson

Field Summary
static java.lang.String CARD_PROPERTY
          The bound property of the connected card.
static java.lang.String CARDS_PROPERTY
          The bound property of the connected cards.
 
Fields inherited from class com.globalmentor.beans.BoundPropertyObject
NO_PROPERTY_CHANGE_LISTENERS, NO_VETOABLE_CHANGE_LISTENERS
 
Constructor Summary
AbstractCardCoupler(Component... cards)
          Card constructor.
 
Method Summary
 Component getCard()
           
protected  CardControl getCardControl()
           
 java.util.List<Component> getCards()
           
protected  void installCardConstraints(Constraints constraints)
          Installs appropriate listeners in a card's constraints.
protected  boolean isCardSelectable(Component card)
          Determines whether the given card is selectable.
protected  void selectCard()
          Selects the first connected card that is displayed and enabled.
protected  void selectCard(CardControl cardControl, Component card)
          Selects the specified card.
 void setCard(Component newCard)
          Sets the connected card.
 void setCards(java.util.List<Component> newCards)
          Sets the connected cards.
protected  void uninstallCardConstraints(Constraints constraints)
          Uninstalls appropriate listeners from a card's constraints.
protected  void updateDisplayed()
          Performs any needed updates based upon the displayed status of the constraints of the connected cards.
protected  void updateDisplayed(boolean displayed)
          Updates the current displayed status.
protected  void updateEnabled()
          Performs any needed updates based upon the enabled status of the constraints of the connected cards.
protected  void updateEnabled(boolean enabled)
          Updates the current enabled status.
protected  void updateSelected()
          Performs any needed updates based upon the currently selected card.
protected  void updateSelected(boolean selected)
          Updates the current selected status.
protected  void updateTaskState()
          Performs any needed updates based upon the current task status of the constraints of the connected cards.
protected  void updateTaskState(com.globalmentor.model.TaskState taskState)
          Updates the current task state.
 
Methods inherited from class com.guiseframework.event.GuiseBoundPropertyObject
getSession
 
Methods inherited from class com.globalmentor.beans.BoundPropertyObject
addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, addVetoableChangeListener, createPostponedPropertyChangeEvent, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, fireVetoableChange, fireVetoableChange, fireVetoableChange, getForwardPropertyChangeListener, getPropertyChangeListeners, getPropertyChangeListeners, getPropertyChangeSupport, getRepeatPropertyChangeListener, getRepeatVetoableChangeListener, getVetoableChangeListeners, getVetoableChangeListeners, getVetoableChangeSupport, hasPropertyChangeListeners, hasVetoableChangeListeners, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, removeVetoableChangeListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CARD_PROPERTY

public static final java.lang.String CARD_PROPERTY
The bound property of the connected card.


CARDS_PROPERTY

public static final java.lang.String CARDS_PROPERTY
The bound property of the connected cards.

Constructor Detail

AbstractCardCoupler

public AbstractCardCoupler(Component... cards)
Card constructor.

Parameters:
cards - The new cards to connect, if any.
Method Detail

getCards

public java.util.List<Component> getCards()
Returns:
The connected cards.

getCard

public Component getCard()
Returns:
The first connected card, or null if there are no connected cards.

setCard

public void setCard(Component newCard)
Sets the connected card. This is a bound property.

Parameters:
newCard - The new card to be connected.
See Also:
CARD_PROPERTY

setCards

public void setCards(java.util.List<Component> newCards)
Sets the connected cards. This is a bound property.

Parameters:
newCards - The new cards to be connected.
Throws:
java.lang.NullPointerException - if the given cards is null.
See Also:
CARDS_PROPERTY

getCardControl

protected CardControl getCardControl()
Returns:
A convenience reference to the connected card's parent card control, if any.

installCardConstraints

protected void installCardConstraints(Constraints constraints)
Installs appropriate listeners in a card's constraints.

Parameters:
constraints - The card constraints being installed.

uninstallCardConstraints

protected void uninstallCardConstraints(Constraints constraints)
Uninstalls appropriate listeners from a card's constraints.

Parameters:
constraints - The card constraints being uninstalled.

selectCard

protected void selectCard()
                   throws java.beans.PropertyVetoException
Selects the first connected card that is displayed and enabled. If no card is connected or the card has no parent card control, no action occurs. If a selectable card is already selected, no action occurs. This method calls isCardSelectable(Component) and selectCard(CardControl, Component).

Throws:
java.beans.PropertyVetoException - if the appropriate card could not be selected.

isCardSelectable

protected boolean isCardSelectable(Component card)
Determines whether the given card is selectable. This method ensures the card is enabled (if enableable) and displayed (if displayable).

Parameters:
card - The card to check.
Returns:
true if the card can be selected.

selectCard

protected void selectCard(CardControl cardControl,
                          Component card)
                   throws java.beans.PropertyVetoException
Selects the specified card.

Parameters:
The - card control to use in selected the card.
card - The card to select.
Throws:
java.beans.PropertyVetoException - if the provided card could not be selected.

updateDisplayed

protected void updateDisplayed()
Performs any needed updates based upon the displayed status of the constraints of the connected cards. The new displayed status will be considered true unless the constraints of all connected cards implement Displayable and return false for Displayable.isDisplayed(). This method calls updateDisplayed(boolean) with the result.


updateDisplayed

protected void updateDisplayed(boolean displayed)
Updates the current displayed status. This implementation does nothing.

Parameters:
displayed - The new displayed status.

updateEnabled

protected void updateEnabled()
Performs any needed updates based upon the enabled status of the constraints of the connected cards. The new enabled status will be considered true unless the constraints of all connected cards implement Enableable and return false for Enableable.isEnabled(). This method calls updateEnabled(boolean) with the result.


updateEnabled

protected void updateEnabled(boolean enabled)
Updates the current enabled status. This implementation does nothing.

Parameters:
enabled - The new enabled status.

updateTaskState

protected void updateTaskState()
Performs any needed updates based upon the current task status of the constraints of the connected cards. This implementation uses the first available task status from the connected cards. This method calls updateTaskState(TaskState).


updateTaskState

protected void updateTaskState(com.globalmentor.model.TaskState taskState)
Updates the current task state. This implementation does nothing.

Parameters:
taskState - The new task state, or null if there is no task state.

updateSelected

protected void updateSelected()
Performs any needed updates based upon the currently selected card. This implementation determines the selected status based upon whether the currently selected card in the connected card control is one of the connected cards. This method calls updateSelected(boolean).


updateSelected

protected void updateSelected(boolean selected)
Updates the current selected status. This implementation does nothing.

Parameters:
selected - The new selected status.


Copyright © 2005-2010 GlobalMentor, Inc. All Rights Reserved.