Package io.guise.framework.coupler
Class AbstractCardCoupler
java.lang.Object
com.globalmentor.beans.BoundPropertyObject
io.guise.framework.event.GuiseBoundPropertyObject
io.guise.framework.coupler.AbstractCardCoupler
- All Implemented Interfaces:
com.globalmentor.beans.PropertyBindable
,com.globalmentor.beans.PropertyConstrainable
- Direct Known Subclasses:
ActionCardCoupler
,ListSelectCardCoupler
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
Modifier and TypeFieldDescriptionstatic final String
The bound property of the connected card.static final String
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
-
Method Summary
Modifier and TypeMethodDescriptiongetCard()
protected CardControl
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
Selects the first connected card that is displayed and enabled.protected void
selectCard
(CardControl cardControl, Component card) Selects the specified card.void
Sets the connected card.void
Sets the connected cards.protected void
uninstallCardConstraints
(Constraints constraints) Uninstalls appropriate listeners from a card's constraints.protected void
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
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
Performs any needed updates based upon the currently selected card.protected void
updateSelected
(boolean selected) Updates the current selected status.protected void
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 io.guise.framework.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
-
Field Details
-
CARD_PROPERTY
The bound property of the connected card. -
CARDS_PROPERTY
The bound property of the connected cards.
-
-
Constructor Details
-
AbstractCardCoupler
Card constructor.- Parameters:
cards
- The new cards to connect, if any.
-
-
Method Details
-
getCards
- Returns:
- The connected cards.
-
getCard
- Returns:
- The first connected card, or
null
if there are no connected cards.
-
setCard
Sets the connected card. This is a bound property.- Parameters:
newCard
- The new card to be connected.- See Also:
-
setCards
Sets the connected cards. This is a bound property.- Parameters:
newCards
- The new cards to be connected.- Throws:
NullPointerException
- if the given cards isnull
.- See Also:
-
getCardControl
- Returns:
- A convenience reference to the connected card's parent card control, if any.
-
installCardConstraints
Installs appropriate listeners in a card's constraints.- Parameters:
constraints
- The card constraints being installed.
-
uninstallCardConstraints
Uninstalls appropriate listeners from a card's constraints.- Parameters:
constraints
- The card constraints being uninstalled.
-
selectCard
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 callsisCardSelectable(Component)
andselectCard(CardControl, Component)
.- Throws:
PropertyVetoException
- if the appropriate card could not be selected.
-
isCardSelectable
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
Selects the specified card.- Parameters:
cardControl
- The card control to use in selected the card.card
- The card to select.- Throws:
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 consideredtrue
unless the constraints of all connected cards implementDisplayable
and returnfalse
forDisplayable.isDisplayed()
. This method callsupdateDisplayed(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 consideredtrue
unless the constraints of all connected cards implementEnableable
and returnfalse
forEnableable.isEnabled()
. This method callsupdateEnabled(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 callsupdateTaskState(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, ornull
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 callsupdateSelected(boolean)
. -
updateSelected
protected void updateSelected(boolean selected) Updates the current selected status. This implementation does nothing.- Parameters:
selected
- The new selected status.
-