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
public class AbstractCardCoupler extends GuiseBoundPropertyObject
Abstract coupler to one or more cards in aCardControl
. This coupler is only functional when the given card is contained within aCardControl
. This coupler can behave as if a single card or multiple cards are connected, firing both theCARD_PROPERTY
andCARDS_PROPERTY
property change events when cards are changed. If the card change results in the same card in the first position in the list, theCARD_PROPERTY
is not fired.- Author:
- Garret Wilson
-
-
Field Summary
Fields Modifier and Type Field Description 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.
-
Constructor Summary
Constructors Constructor Description AbstractCardCoupler(Component... cards)
Card constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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 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
-
-
-
-
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 isnull
.- 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 callsisCardSelectable(Component)
andselectCard(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:
cardControl
- 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 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.
-
-