com.guiseframework.component
Class AbstractComponent

java.lang.Object
  extended by com.globalmentor.beans.BoundPropertyObject
      extended by com.guiseframework.event.GuiseBoundPropertyObject
          extended by com.guiseframework.model.ui.AbstractPresentationModel
              extended by com.guiseframework.component.AbstractComponent
All Implemented Interfaces:
com.globalmentor.beans.PropertyBindable, com.globalmentor.beans.PropertyConstrainable, Component, Displayable, InfoModel, LabelModel, Model, PresentationModel, DepictedObject
Direct Known Subclasses:
AbstractCompositeComponent, AbstractControl, AbstractImageComponent, AbstractLabel, Flash, Message

public abstract class AbstractComponent
extends AbstractPresentationModel
implements Component

An abstract implementation of a component.

A component should never fire a property event directly. It should rather create a postponed event and queue that event with the session. This implementation automatically handles postponed property change events when BoundPropertyObject.firePropertyChange(String, Object, Object) or a related method is called.

Property changes to a component's constraints are repeated with the component as the source and the constraints as the target.

Author:
Garret Wilson

Nested Class Summary
static class AbstractComponent.AbstractFlyoverFrameStrategy<S extends Component>
          An abstract flyover strategy that uses flyover frames.
static class AbstractComponent.AbstractFlyoverStrategy<S extends Component>
          An abstract implementation of a strategy for showing and hiding flyovers in response to mouse events.
static class AbstractComponent.DefaultFlyoverStrategy<S extends Component>
          The default strategy for showing and hiding flyovers in response to mouse events.
 
Nested classes/interfaces inherited from interface com.guiseframework.component.Component
Component.FlyoverStrategy<S extends Component>
 
Field Summary
 
Fields inherited from class com.globalmentor.beans.BoundPropertyObject
NO_PROPERTY_CHANGE_LISTENERS, NO_VETOABLE_CHANGE_LISTENERS
 
Fields inherited from interface com.guiseframework.component.Component
BOOKMARK_ENABLED_PROPERTY, CONSTRAINTS_PROPERTY, DRAG_ENABLED_PROPERTY, DROP_ENABLED_PROPERTY, FLYOVER_ENABLED_PROPERTY, FLYOVER_STRATEGY_PROPERTY, INPUT_STRATEGY_PROPERTY, NAME_PROPERTY, NOTIFICATION_PROPERTY, ORIENTATION_PROPERTY, THEME_APPLIED_PROPERTY, VALID_PROPERTY
 
Fields inherited from interface com.guiseframework.model.ui.PresentationModel
BACKGROUND_COLOR_PROPERTY, BORDER_LINE_FAR_COLOR_PROPERTY, BORDER_LINE_FAR_EXTENT_PROPERTY, BORDER_LINE_FAR_STYLE_PROPERTY, BORDER_LINE_NEAR_COLOR_PROPERTY, BORDER_LINE_NEAR_EXTENT_PROPERTY, BORDER_LINE_NEAR_STYLE_PROPERTY, BORDER_PAGE_FAR_COLOR_PROPERTY, BORDER_PAGE_FAR_EXTENT_PROPERTY, BORDER_PAGE_FAR_STYLE_PROPERTY, BORDER_PAGE_NEAR_COLOR_PROPERTY, BORDER_PAGE_NEAR_EXTENT_PROPERTY, BORDER_PAGE_NEAR_STYLE_PROPERTY, CORNER_LINE_FAR_PAGE_FAR_ARC_SIZE_PROPERTY, CORNER_LINE_FAR_PAGE_NEAR_ARC_SIZE_PROPERTY, CORNER_LINE_NEAR_PAGE_FAR_ARC_SIZE_PROPERTY, CORNER_LINE_NEAR_PAGE_NEAR_ARC_SIZE_PROPERTY, CURSOR_PROPERTY, FONT_FAMILIES_PROPERTY, FONT_SIZE_PROPERTY, FONT_STYLE_PROPERTY, FONT_WEIGHT_BOLD, FONT_WEIGHT_NORMAL, FONT_WEIGHT_PROPERTY, LABEL_FONT_FAMILIES_PROPERTY, LABEL_FONT_SIZE_PROPERTY, LABEL_FONT_STYLE_PROPERTY, LABEL_FONT_WEIGHT_PROPERTY, LABEL_TEXT_COLOR_PROPERTY, LINE_EXTENT_PROPERTY, MARGIN_LINE_FAR_EXTENT_PROPERTY, MARGIN_LINE_NEAR_EXTENT_PROPERTY, MARGIN_PAGE_FAR_EXTENT_PROPERTY, MARGIN_PAGE_NEAR_EXTENT_PROPERTY, OPACITY_PROPERTY, PADDING_LINE_FAR_EXTENT_PROPERTY, PADDING_LINE_NEAR_EXTENT_PROPERTY, PADDING_PAGE_FAR_EXTENT_PROPERTY, PADDING_PAGE_NEAR_EXTENT_PROPERTY, PAGE_EXTENT_PROPERTY, ROUNDED_CORNER_ARC_SIZE, STYLE_ID_PROPERTY, TEXT_COLOR_PROPERTY, TOOLTIP_ENABLED_PROPERTY, VISIBLE_PROPERTY
 
Fields inherited from interface com.guiseframework.model.Displayable
DISPLAYED_PROPERTY
 
Fields inherited from interface com.guiseframework.model.InfoModel
DESCRIPTION_CONTENT_TYPE_PROPERTY, DESCRIPTION_PROPERTY, INFO_CONTENT_TYPE_PROPERTY, INFO_PROPERTY
 
Fields inherited from interface com.guiseframework.model.LabelModel
GLYPH_URI_PROPERTY, LABEL_CONTENT_TYPE_PROPERTY, LABEL_PROPERTY
 
Fields inherited from interface com.guiseframework.model.Model
PLAIN_TEXT_CONTENT_TYPE, XHTML_CONTENT_TYPE, XHTML_FRAGMENT_CONTENT_TYPE
 
Constructor Summary
AbstractComponent()
          Default constructor.
AbstractComponent(InfoModel infoModel)
          Info model constructor.
 
Method Summary
 void addCommandListener(CommandListener commandListener)
          Adds a command listener.
 void addExportStrategy(ExportStrategy<?> exportStrategy)
          Adds an export strategy to the component.
 void addImportStrategy(ImportStrategy<?> importStrategy)
          Adds an import strategy to the component.
 void addKeyListener(KeyboardListener keyListener)
          Adds a key listener.
 void addMouseListener(MouseListener mouseListener)
          Adds a mouse listener.
 void addNotificationListener(NotificationListener notificationListener)
          Adds a notification listener.
 void addPreferenceProperty(java.lang.String propertyName)
          Adds a property to be saved and loaded as a preference.
 void applyTheme()
          Applies the theme to this object.
 void applyTheme(Theme theme)
          Applies a theme and its parents to this object.
 void depict()
          Updates the depiction of the object.
protected  boolean determineValid()
          Checks the state of the component for validity.
 void dispatchInputEvent(InputEvent inputEvent)
          Dispatches an input event to this component and all child components, if any.
 boolean equals(java.lang.Object object)
          Indicates whether some other object is "equal to" this one.
 Transferable<?> exportTransfer()
          Exports data from the component.
 void fireInputEvent(InputEvent inputEvent)
          Fire the given even to all registered listeners, if any.
protected  void fireNotified(Notification notification)
          Fires an event to all registered notification listeners with the new notification information.
protected  void fireNotified(NotificationEvent notificationEvent)
          Fires an event to all registered notification listeners with the new notification information.
<A extends CompositeComponent>
A
getAncestor(java.lang.Class<A> ancestorClass)
          Retrieves the first ancestor of the given type.
protected  java.lang.Iterable<CommandListener> getCommandListeners()
           
static Component getComponentByID(Component component, long id)
          Retrieves a component with the given ID.
static Component getComponentByName(Component component, java.lang.String name)
          Retrieves a component with the given name.
 Orientation getComponentOrientation()
          Determines the internationalization orientation of the component's contents.
 Constraints getConstraints()
           
 long getDepictID()
           
 Depictor<? extends Component> getDepictor()
           
 java.lang.String getDescription()
           
 com.globalmentor.net.ContentType getDescriptionContentType()
           
static java.util.List<Component> getDirtyComponents(Component component)
          Retrieves all components that have views needing updated.
static java.util.List<Component> getDirtyComponents(Component component, java.util.List<Component> dirtyComponents)
          Retrieves all components that have views needing updated.
protected  com.globalmentor.event.EventListenerManager getEventListenerManager()
           
 Component.FlyoverStrategy<?> getFlyoverStrategy()
           
 java.net.URI getGlyphURI()
           
 java.lang.String getInfo()
           
 com.globalmentor.net.ContentType getInfoContentType()
           
protected  InfoModel getInfoModel()
           
 InputStrategy getInputStrategy()
           
protected  java.lang.Iterable<KeyboardListener> getKeyListeners()
           
 java.lang.String getLabel()
           
 com.globalmentor.net.ContentType getLabelContentType()
           
protected  java.lang.Iterable<MouseListener> getMouseListeners()
           
 java.lang.String getName()
           
 Notification getNotification()
           
static java.util.List<Notification> getNotifications(Component component)
          Retrieves the the notifications of all components in a hierarchy.
protected static java.util.List<Notification> getNotifications(Component component, java.util.List<Notification> notifications)
          Retrieves the the notifications of all components in a hierarchy.
 Orientation getOrientation()
          Returns this component's requested orientation.
 CompositeComponent getParent()
           
 java.lang.Iterable<java.lang.String> getPreferenceProperties()
          Returns all properties stored as preferences.
static Component getRootComponent(Component component)
          Determines the root parent of the given component.
 Theme getTheme()
          Returns the theme to apply to this component.
static boolean hasAncestor(Component component, CompositeComponent ancestor)
          Determines whether a component has a given component as its ancestor, not including the component itself.
 boolean hasCommandListeners()
           
 int hashCode()
           
 boolean hasKeyListeners()
           
 boolean hasMouseListeners()
           
 boolean importTransfer(Transferable<?> transferable)
          Imports data to the component.
 void initialize()
          Initializes the component after construction.
 boolean isDragEnabled()
           
 boolean isDropEnabled()
           
 boolean isFlyoverEnabled()
           
 boolean isPreferenceProperty(java.lang.String propertyName)
          Determines whether the given property is saved and loaded as a preference.
 boolean isThemeApplied()
           
 boolean isValid()
          Determines whether the state of the component and all child components represents valid user input.
 void loadPreferences(boolean includeDescendants)
          Loads the preferences for this component and optionally any descendant components.
 void notify(Notification notification)
          Notifies the user of the given notification information.
 void processEvent(PlatformEvent event)
          Processes an event from the platform.
 void removeCommandListener(CommandListener commandListener)
          Removes a command listener.
 void removeExportStrategy(ExportStrategy<?> exportStrategy)
          Removes an export strategy from the component.
 void removeImportStrategy(ImportStrategy<?> importStrategy)
          Removes an import strategy from the component.
 void removeKeyListener(KeyboardListener keyListener)
          Removes a key listener.
 void removeMouseListener(MouseListener mouseListener)
          Removes a mouse listener.
 void removeNotificationListener(NotificationListener notificationListener)
          Removes a notification listener.
 void removePreferenceProperty(java.lang.String propertyName)
          Removes a property from being saved and loaded as preferences.
 void resetTheme()
          Resets this object's theme.
 void savePreferences(boolean includeDescendants)
          Saves the preferences for this component and optionally any descendant components.
 void setConstraints(Constraints newConstraints)
          Sets the layout constraints of this component.
static void setDepicted(Component component, boolean newUpdated)
          Changes the updated status of the views of an entire component descendant hierarchy.
 void setDescription(java.lang.String newDescription)
          Sets the description text, such as might appear in a flyover.
 void setDescriptionContentType(com.globalmentor.net.ContentType newDescriptionContentType)
          Sets the content type of the description text.
 void setDragEnabled(boolean newDragEnabled)
          Sets whether the component has dragging enabled.
 void setDropEnabled(boolean newDropEnabled)
          Sets whether the component has dropping enabled.
 void setFlyoverEnabled(boolean newFlyoverEnabled)
          Sets whether flyovers are enabled for this component.
 void setFlyoverStrategy(Component.FlyoverStrategy<?> newFlyoverStrategy)
          Sets the strategy for controlling flyovers.
 void setGlyphURI(java.net.URI newLabelIcon)
          Sets the URI of the icon.
 void setInfo(java.lang.String newInfo)
          Sets the advisory information text, such as might appear in a tooltip.
 void setInfoContentType(com.globalmentor.net.ContentType newInfoContentType)
          Sets the content type of the advisory information text.
 void setInputStrategy(InputStrategy newInputStrategy)
          Sets the strategy for processing input.
 void setLabel(java.lang.String newLabelText)
          Sets the text of the label.
 void setLabelContentType(com.globalmentor.net.ContentType newLabelTextContentType)
          Sets the content type of the label text.
 void setName(java.lang.String newName)
          Sets the name of the component.
 void setNotification(Notification newNotification)
          Sets the component notification.
 void setOrientation(Orientation newOrientation)
          Sets the orientation.
 void setParent(CompositeComponent newParent)
          Sets the parent of this component.
 void setThemeApplied(boolean newThemeApplied)
          Sets whether a theme has been applied to this component.
protected  void setValid(boolean newValid)
          Sets whether the state of the component and all child components represents valid user input This is a bound property of type Boolean.
 java.lang.String toString()
           
protected  void update()
          Updates the condition of the component based upon the state.
 void updateTheme()
          Updates this object's theme.
protected  void updateValid()
          Rechecks user input validity of this component and all child components, and updates the valid state.
 boolean validate()
          Validates the user input of this component and all child components.
 
Methods inherited from class com.guiseframework.model.ui.AbstractPresentationModel
BorderLineFarColor, BorderLineFarExtent, BorderLineFarStyle, BorderLineNearColor, BorderLineNearExtent, BorderLineNearStyle, BorderPageFarColor, BorderPageFarExtent, BorderPageFarStyle, BorderPageNearColor, BorderPageNearExtent, BorderPageNearStyle, getBackgroundColor, getBorderColor, getBorderExtent, getBorderStyle, getCornerArcSize, getCornerLineFarPageFarArcSize, getCornerLineFarPageNearArcSize, getCornerLineNearPageFarArcSize, getCornerLineNearPageNearArcSize, getCursor, getExtent, getFontFamilies, getFontSize, getFontStyle, getFontWeight, getLabelFontFamilies, getLabelFontSize, getLabelFontStyle, getLabelFontWeight, getLabelTextColor, getLineExtent, getMarginExtent, getMarginLineFarExtent, getMarginLineNearExtent, getMarginPageFarExtent, getMarginPageNearExtent, getOpacity, getPaddingExtent, getPaddingLineFarExtent, getPaddingLineNearExtent, getPaddingPageFarExtent, getPaddingPageNearExtent, getPageExtent, getStyleID, getTextColor, isDisplayed, isTooltipEnabled, isVisible, setBackgroundColor, setBorderColor, setBorderColor, setBorderExtent, setBorderExtent, setBorderLineFarColor, setBorderLineFarExtent, setBorderLineFarStyle, setBorderLineNearColor, setBorderLineNearExtent, setBorderLineNearStyle, setBorderPageFarColor, setBorderPageFarExtent, setBorderPageFarStyle, setBorderPageNearColor, setBorderPageNearExtent, setBorderPageNearStyle, setBorderStyle, setBorderStyle, setCornerArcSize, setCornerArcSize, setCornerLineFarPageFarArcSize, setCornerLineFarPageNearArcSize, setCornerLineNearPageFarArcSize, setCornerLineNearPageNearArcSize, setCursor, setDisplayed, setExtent, setFontFamilies, setFontSize, setFontStyle, setFontWeight, setLabelFontFamilies, setLabelFontSize, setLabelFontStyle, setLabelFontWeight, setLabelTextColor, setLineExtent, setMarginExtent, setMarginExtent, setMarginLineFarExtent, setMarginLineNearExtent, setMarginPageFarExtent, setMarginPageNearExtent, setOpacity, setPaddingExtent, setPaddingExtent, setPaddingLineFarExtent, setPaddingLineNearExtent, setPaddingPageFarExtent, setPaddingPageNearExtent, setPageExtent, setStyleID, setTextColor, setTooltipEnabled, setVisible
 
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, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.guiseframework.platform.DepictedObject
getSession
 
Methods inherited from interface com.guiseframework.model.ui.PresentationModel
BorderLineFarColor, BorderLineFarExtent, BorderLineFarStyle, BorderLineNearColor, BorderLineNearExtent, BorderLineNearStyle, BorderPageFarColor, BorderPageFarExtent, BorderPageFarStyle, BorderPageNearColor, BorderPageNearExtent, BorderPageNearStyle, getBackgroundColor, getBorderColor, getBorderExtent, getBorderStyle, getCornerArcSize, getCornerLineFarPageFarArcSize, getCornerLineFarPageNearArcSize, getCornerLineNearPageFarArcSize, getCornerLineNearPageNearArcSize, getCursor, getExtent, getFontFamilies, getFontSize, getFontStyle, getFontWeight, getLabelFontFamilies, getLabelFontSize, getLabelFontStyle, getLabelFontWeight, getLabelTextColor, getLineExtent, getMarginExtent, getMarginLineFarExtent, getMarginLineNearExtent, getMarginPageFarExtent, getMarginPageNearExtent, getOpacity, getPaddingExtent, getPaddingLineFarExtent, getPaddingLineNearExtent, getPaddingPageFarExtent, getPaddingPageNearExtent, getPageExtent, getSession, getStyleID, getTextColor, isDisplayed, isTooltipEnabled, isVisible, setBackgroundColor, setBorderColor, setBorderColor, setBorderExtent, setBorderExtent, setBorderLineFarColor, setBorderLineFarExtent, setBorderLineFarStyle, setBorderLineNearColor, setBorderLineNearExtent, setBorderLineNearStyle, setBorderPageFarColor, setBorderPageFarExtent, setBorderPageFarStyle, setBorderPageNearColor, setBorderPageNearExtent, setBorderPageNearStyle, setBorderStyle, setBorderStyle, setCornerArcSize, setCornerArcSize, setCornerLineFarPageFarArcSize, setCornerLineFarPageNearArcSize, setCornerLineNearPageFarArcSize, setCornerLineNearPageNearArcSize, setCursor, setDisplayed, setExtent, setFontFamilies, setFontSize, setFontStyle, setFontWeight, setLabelFontFamilies, setLabelFontSize, setLabelFontStyle, setLabelFontWeight, setLabelTextColor, setLineExtent, setMarginExtent, setMarginExtent, setMarginLineFarExtent, setMarginLineNearExtent, setMarginPageFarExtent, setMarginPageNearExtent, setOpacity, setPaddingExtent, setPaddingExtent, setPaddingLineFarExtent, setPaddingLineNearExtent, setPaddingPageFarExtent, setPaddingPageNearExtent, setPageExtent, setStyleID, setTextColor, setTooltipEnabled, setVisible
 
Methods inherited from interface com.globalmentor.beans.PropertyBindable
addPropertyChangeListener, addPropertyChangeListener, getPropertyChangeListeners, getPropertyChangeListeners, hasPropertyChangeListeners, removePropertyChangeListener, removePropertyChangeListener
 
Methods inherited from interface com.globalmentor.beans.PropertyConstrainable
addVetoableChangeListener, addVetoableChangeListener, getVetoableChangeListeners, getVetoableChangeListeners, hasVetoableChangeListeners, removeVetoableChangeListener, removeVetoableChangeListener
 

Constructor Detail

AbstractComponent

public AbstractComponent()
Default constructor.

Throws:
java.lang.IllegalStateException - if no controller is registered for this component type.
java.lang.IllegalStateException - if no view is registered for this component type.

AbstractComponent

public AbstractComponent(InfoModel infoModel)
Info model constructor.

Parameters:
infoModel - The component info model.
Throws:
java.lang.NullPointerException - if the given info model is null.
java.lang.IllegalStateException - if no depictor is registered for this component type.
Method Detail

getEventListenerManager

protected com.globalmentor.event.EventListenerManager getEventListenerManager()
Returns:
The object managing event listeners.

addPreferenceProperty

public void addPreferenceProperty(java.lang.String propertyName)
Adds a property to be saved and loaded as a preference.

Specified by:
addPreferenceProperty in interface Component
Parameters:
propertyName - The property to store as a preference.
See Also:
loadPreferences(boolean), savePreferences(boolean)

isPreferenceProperty

public boolean isPreferenceProperty(java.lang.String propertyName)
Determines whether the given property is saved and loaded as a preference.

Specified by:
isPreferenceProperty in interface Component
Parameters:
propertyName - The property to determine if it is stored as a preference.
Returns:
true if the given property is saved and loaded as a preference.
See Also:
loadPreferences(boolean), savePreferences(boolean)

getPreferenceProperties

public java.lang.Iterable<java.lang.String> getPreferenceProperties()
Returns all properties stored as preferences.

Specified by:
getPreferenceProperties in interface Component
Returns:
An iterable of all properties saved and loaded as preferences.
See Also:
loadPreferences(boolean), savePreferences(boolean)

removePreferenceProperty

public void removePreferenceProperty(java.lang.String propertyName)
Removes a property from being saved and loaded as preferences.

Specified by:
removePreferenceProperty in interface Component
Parameters:
propertyName - The property that should no longer be stored as a preference.
See Also:
loadPreferences(boolean), savePreferences(boolean)

getInfoModel

protected InfoModel getInfoModel()
Returns:
The info model decorated by this component.

getName

public java.lang.String getName()
Specified by:
getName in interface Component
Returns:
The name of the component, not guaranteed to be unique (but guaranteed not to be the empty string) and useful only for searching for components within a component sub-hierarchy, or null if the component has no name.

setName

public void setName(java.lang.String newName)
Sets the name of the component. This is a bound property.

Specified by:
setName in interface Component
Parameters:
newName - The new name of the component, or null if the component should have no name.
Throws:
java.lang.IllegalArgumentException - if the given name is the empty string.
See Also:
Component.NAME_PROPERTY

getGlyphURI

public java.net.URI getGlyphURI()
Specified by:
getGlyphURI in interface LabelModel
Returns:
The icon URI, which may be a resource URI, or null if there is no icon URI.

setGlyphURI

public void setGlyphURI(java.net.URI newLabelIcon)
Sets the URI of the icon. This is a bound property of type URI.

Specified by:
setGlyphURI in interface LabelModel
Parameters:
newLabelIcon - The new URI of the icon, which may be a resource URI.
See Also:
LabelModel.GLYPH_URI_PROPERTY

getLabel

public java.lang.String getLabel()
Specified by:
getLabel in interface LabelModel
Returns:
The label text, which may include a resource reference, or null if there is no label text.

setLabel

public void setLabel(java.lang.String newLabelText)
Sets the text of the label. This is a bound property.

Specified by:
setLabel in interface LabelModel
Parameters:
newLabelText - The new text of the label, which may include a resource reference.
See Also:
LabelModel.LABEL_PROPERTY

getLabelContentType

public com.globalmentor.net.ContentType getLabelContentType()
Specified by:
getLabelContentType in interface LabelModel
Returns:
The content type of the label text.

setLabelContentType

public void setLabelContentType(com.globalmentor.net.ContentType newLabelTextContentType)
Sets the content type of the label text. This is a bound property.

Specified by:
setLabelContentType in interface LabelModel
Parameters:
newLabelTextContentType - The new label text content type.
Throws:
java.lang.NullPointerException - if the given content type is null.
java.lang.IllegalArgumentException - if the given content type is not a text content type.
See Also:
LabelModel.LABEL_CONTENT_TYPE_PROPERTY

getDescription

public java.lang.String getDescription()
Specified by:
getDescription in interface InfoModel
Returns:
The description text, such as might appear in a flyover, or null if there is no description.

setDescription

public void setDescription(java.lang.String newDescription)
Sets the description text, such as might appear in a flyover. This is a bound property.

Specified by:
setDescription in interface InfoModel
Parameters:
newDescription - The new text of the description, such as might appear in a flyover.
See Also:
InfoModel.DESCRIPTION_PROPERTY

getDescriptionContentType

public com.globalmentor.net.ContentType getDescriptionContentType()
Specified by:
getDescriptionContentType in interface InfoModel
Returns:
The content type of the description text.

setDescriptionContentType

public void setDescriptionContentType(com.globalmentor.net.ContentType newDescriptionContentType)
Sets the content type of the description text. This is a bound property.

Specified by:
setDescriptionContentType in interface InfoModel
Parameters:
newDescriptionContentType - The new description text content type.
Throws:
java.lang.NullPointerException - if the given content type is null.
java.lang.IllegalArgumentException - if the given content type is not a text content type.
See Also:
InfoModel.DESCRIPTION_CONTENT_TYPE_PROPERTY

getInfo

public java.lang.String getInfo()
Specified by:
getInfo in interface InfoModel
Returns:
The advisory information text, such as might appear in a tooltip, or null if there is no advisory information.

setInfo

public void setInfo(java.lang.String newInfo)
Sets the advisory information text, such as might appear in a tooltip. This is a bound property.

Specified by:
setInfo in interface InfoModel
Parameters:
newInfo - The new text of the advisory information, such as might appear in a tooltip.
See Also:
InfoModel.INFO_PROPERTY

getInfoContentType

public com.globalmentor.net.ContentType getInfoContentType()
Specified by:
getInfoContentType in interface InfoModel
Returns:
The content type of the advisory information text.

setInfoContentType

public void setInfoContentType(com.globalmentor.net.ContentType newInfoContentType)
Sets the content type of the advisory information text. This is a bound property.

Specified by:
setInfoContentType in interface InfoModel
Parameters:
newInfoContentType - The new advisory information text content type.
Throws:
java.lang.NullPointerException - if the given content type is null.
java.lang.IllegalArgumentException - if the given content type is not a text content type.
See Also:
InfoModel.INFO_CONTENT_TYPE_PROPERTY

getConstraints

public Constraints getConstraints()
Specified by:
getConstraints in interface Component
Returns:
The layout constraints describing individual component layout information, or null if no constraints have been specified for this component.

setConstraints

public void setConstraints(Constraints newConstraints)
Sets the layout constraints of this component. This is a bound property.

Specified by:
setConstraints in interface Component
Parameters:
newConstraints - The layout constraints describing individual component layout information, or null if no constraints have been specified for this component.
See Also:
Component.CONSTRAINTS_PROPERTY

getInputStrategy

public InputStrategy getInputStrategy()
Specified by:
getInputStrategy in interface Component
Returns:
The strategy for processing input, or null if this component has no input strategy.

setInputStrategy

public void setInputStrategy(InputStrategy newInputStrategy)
Sets the strategy for processing input. This is a bound property.

Specified by:
setInputStrategy in interface Component
Parameters:
newInputStrategy - The new strategy for processing input, or null if this component is to have no input strategy.
See Also:
Component.INPUT_STRATEGY_PROPERTY

getNotification

public Notification getNotification()
Specified by:
getNotification in interface Component
Returns:
The notification associated with the component, or null if no notification is associated with this component.

setNotification

public void setNotification(Notification newNotification)
Sets the component notification. This is a bound property. The notification is also fired as a NotificationEvent on this component if a new notification is given. Parents are expected to refire the notification event up the hierarchy.

Specified by:
setNotification in interface Component
Parameters:
newNotification - The notification for the component, or null if no notification is associated with this component.
See Also:
Component.NOTIFICATION_PROPERTY

isValid

public boolean isValid()
Determines whether the state of the component and all child components represents valid user input. This implementation initializes the valid property if needed.

Specified by:
isValid in interface Component
Returns:
Whether the state of the component and all child components represents valid user input.

setValid

protected void setValid(boolean newValid)
Sets whether the state of the component and all child components represents valid user input This is a bound property of type Boolean. This implementation initializes the valid property if needed.

Parameters:
newValid - true if user input of this component and all child components should be considered valid
See Also:
Component.VALID_PROPERTY

updateValid

protected void updateValid()
Rechecks user input validity of this component and all child components, and updates the valid state. This implementation only updates the valid property if the property is already initialized or there is at least one listener to the Component.VALID_PROPERTY.

See Also:
setValid(boolean)

determineValid

protected boolean determineValid()
Checks the state of the component for validity. This version returns true.

Returns:
true if the component and all children passes all validity tests, else false.

getDepictor

public Depictor<? extends Component> getDepictor()
Specified by:
getDepictor in interface Component
Specified by:
getDepictor in interface DepictedObject
Returns:
The depictor for this object.

processEvent

public void processEvent(PlatformEvent event)
Processes an event from the platform. This method delegates to the currently installed depictor.

Specified by:
processEvent in interface DepictedObject
Parameters:
event - The event to be processed.
Throws:
java.lang.IllegalArgumentException - if the given event is a relevant DepictEvent with a source of a different depicted object.
See Also:
getDepictor(), Depictor.processEvent(PlatformEvent)

depict

public void depict()
            throws java.io.IOException
Updates the depiction of the object. The depiction will be marked as updated. This method delegates to the currently installed depictor.

Specified by:
depict in interface DepictedObject
Throws:
java.io.IOException - if there is an error updating the depiction.
See Also:
getDepictor(), Depictor.depict()

getDepictID

public long getDepictID()
Specified by:
getDepictID in interface DepictedObject
Returns:
The object depiction identifier.

getOrientation

public Orientation getOrientation()
Returns this component's requested orientation. To resolve the orientation up the hierarchy, getComponentOrientation() should be used.

Specified by:
getOrientation in interface Component
Returns:
The internationalization orientation of the component's contents, or null if the default orientation should be used.
See Also:
getComponentOrientation()

getComponentOrientation

public Orientation getComponentOrientation()
Determines the internationalization orientation of the component's contents. This method returns the local orientation value, if there is one. If there is no orientation specified for this component, the request is deferred to this component's parent. If there is no parent component, a default orientation is retrieved from the current session.

Specified by:
getComponentOrientation in interface Component
Returns:
The internationalization orientation of the component's contents.
See Also:
getOrientation(), GuiseSession.getOrientation()

setOrientation

public void setOrientation(Orientation newOrientation)
Sets the orientation. This is a bound property

Specified by:
setOrientation in interface Component
Parameters:
newOrientation - The new internationalization orientation of the component's contents, or null if default orientation should be determined based upon the session's locale.
See Also:
Component.ORIENTATION_PROPERTY

getParent

public CompositeComponent getParent()
Specified by:
getParent in interface Component
Returns:
The parent of this component, or null if this component does not have a parent.

getAncestor

public <A extends CompositeComponent> A getAncestor(java.lang.Class<A> ancestorClass)
Retrieves the first ancestor of the given type.

Specified by:
getAncestor in interface Component
Type Parameters:
A - The type of ancestor component requested.
Parameters:
ancestorClass - The class of ancestor component requested.
Returns:
The first ancestor component of the given type, or null if this component has no such ancestor.

setParent

public void setParent(CompositeComponent newParent)
Sets the parent of this component. This method is managed by containers, and normally should not be called by applications. A component cannot be given a parent if it already has a parent. A component's parent cannot be removed if that parent is a container and this component is still a child of that container. A container's parent cannot be set to a container unless that container already recognizes this component as one of its children. If a component is given the same parent it already has, no action occurs.

Specified by:
setParent in interface Component
Parameters:
newParent - The new parent for this component, or null if this component is being removed from a parent.
Throws:
java.lang.IllegalStateException - if a parent is provided and this component already has a parent.
java.lang.IllegalStateException - if no parent is provided and this component's old parent is a container that still recognizes this component as its child.
java.lang.IllegalArgumentException - if a parent container is provided and the given parent container does not already recognize this component as its child.
See Also:
Container.add(Component), Container#remove(Component)

isDragEnabled

public boolean isDragEnabled()
Specified by:
isDragEnabled in interface Component
Returns:
Whether the component has dragging enabled.

setDragEnabled

public void setDragEnabled(boolean newDragEnabled)
Sets whether the component has dragging enabled. This is a bound property of type Boolean.

Specified by:
setDragEnabled in interface Component
Parameters:
newDragEnabled - true if the component should allow dragging, else false.
See Also:
Component.DRAG_ENABLED_PROPERTY

isDropEnabled

public boolean isDropEnabled()
Specified by:
isDropEnabled in interface Component
Returns:
Whether the component has dropping enabled.

setDropEnabled

public void setDropEnabled(boolean newDropEnabled)
Sets whether the component has dropping enabled. This is a bound property of type Boolean.

Specified by:
setDropEnabled in interface Component
Parameters:
newDropEnabled - true if the component should allow dropping, else false.
See Also:
Component.DROP_ENABLED_PROPERTY

isFlyoverEnabled

public boolean isFlyoverEnabled()
Specified by:
isFlyoverEnabled in interface Component
Returns:
Whether flyovers are enabled for this component.

setFlyoverEnabled

public void setFlyoverEnabled(boolean newFlyoverEnabled)
Sets whether flyovers are enabled for this component. Flyovers contain information from the component model's "description" property. This implementation adds or removes a default flyover strategy if one is not already installed. This is a bound property of type Boolean.

Specified by:
setFlyoverEnabled in interface Component
Parameters:
newFlyoverEnabled - true if the component should display flyovers, else false.
See Also:
getDescription(), Component.FLYOVER_ENABLED_PROPERTY

getFlyoverStrategy

public Component.FlyoverStrategy<?> getFlyoverStrategy()
Specified by:
getFlyoverStrategy in interface Component
Returns:
The installed flyover strategy, or null if there is no flyover strategy installed.

setFlyoverStrategy

public void setFlyoverStrategy(Component.FlyoverStrategy<?> newFlyoverStrategy)
Sets the strategy for controlling flyovers. The flyover strategy will be registered as a mouse listener for this component. This is a bound property.

Specified by:
setFlyoverStrategy in interface Component
Parameters:
newFlyoverStrategy - The new flyover strategy, or null if there is no flyover strategy installed.
See Also:
Component.FLYOVER_STRATEGY_PROPERTY

isThemeApplied

public boolean isThemeApplied()
Specified by:
isThemeApplied in interface Component
Returns:
Whether a theme has been applied to this component.

setThemeApplied

public void setThemeApplied(boolean newThemeApplied)
Sets whether a theme has been applied to this component. This is a bound property of type Boolean.

Specified by:
setThemeApplied in interface Component
Parameters:
newThemeApplied - true if a theme has been applied to this component, else false.
See Also:
Component.THEME_APPLIED_PROPERTY

addExportStrategy

public void addExportStrategy(ExportStrategy<?> exportStrategy)
Adds an export strategy to the component. The export strategy will take precedence over any compatible export strategy previously added.

Specified by:
addExportStrategy in interface Component
Parameters:
exportStrategy - The export strategy to add.

removeExportStrategy

public void removeExportStrategy(ExportStrategy<?> exportStrategy)
Removes an export strategy from the component.

Specified by:
removeExportStrategy in interface Component
Parameters:
exportStrategy - The export strategy to remove.

exportTransfer

public Transferable<?> exportTransfer()
Exports data from the component. Each export strategy, from last to first added, will be asked to export data, until one is successful.

Specified by:
exportTransfer in interface Component
Specified by:
exportTransfer in interface DepictedObject
Returns:
The object to be transferred, or null if no data can be transferred.

addImportStrategy

public void addImportStrategy(ImportStrategy<?> importStrategy)
Adds an import strategy to the component. The import strategy will take prececence over any compatible import strategy previously added.

Specified by:
addImportStrategy in interface Component
Parameters:
importStrategy - The importstrategy to add.

removeImportStrategy

public void removeImportStrategy(ImportStrategy<?> importStrategy)
Removes an import strategy from the component.

Specified by:
removeImportStrategy in interface Component
Parameters:
importStrategy - The import strategy to remove.

importTransfer

public boolean importTransfer(Transferable<?> transferable)
Imports data to the component. Each import strategy, from last to first added, will be asked to import data, until one is successful.

Specified by:
importTransfer in interface Component
Parameters:
transferable - The object to be transferred.
Returns:
true if the given object was be imported.

initialize

public void initialize()
Initializes the component after construction. This method can only be called once during the life of a component. Subclasses should call this version. This implementation performs no actions.

Specified by:
initialize in interface Component
Throws:
java.lang.IllegalStateException - if this method has already been called.

update

protected void update()
Updates the condition of the component based upon the state. This method is a convenience method for complex components that would like to perform wholesale updates any prototypes, enabled/disabled status, proxied actions, etc. This version does nothing.


validate

public boolean validate()
Validates the user input of this component and all child components. The component will be updated with error information. This version clears all notifications. This version calls updateValid().

Specified by:
validate in interface Component
Returns:
The current state of isValid() as a convenience.

dispatchInputEvent

public void dispatchInputEvent(InputEvent inputEvent)
Dispatches an input event to this component and all child components, if any. If this is a FocusedInputEvent, the event will be directed towards the branch in which lies the focused component of any InputFocusGroupComponent ancestor of this component (or this component, if it is a focus group). If this is instead a TargetedEvent, the event will be directed towards the branch in which lies the target component of the event. Otherwise, the event will be dispatched to all child components. Only after the event has been dispatched to any children will the event be fired to any event listeners and then passed to the installed input strategy, if any. Once the event is consumed, no further processing takes place. This version fires all events that are not consumed.

Specified by:
dispatchInputEvent in interface Component
Parameters:
inputEvent - The input event to dispatch.
Throws:
java.lang.NullPointerException - if the given event is null.
See Also:
TargetedEvent, FocusedInputEvent, InputEvent.isConsumed(), fireInputEvent(InputEvent), getInputStrategy(), InputStrategy.input(Input)

fireInputEvent

public void fireInputEvent(InputEvent inputEvent)
Fire the given even to all registered listeners, if any. If the event is consumed further processing should cease.

Specified by:
fireInputEvent in interface Component
Parameters:
inputEvent - The input event to fire.
Throws:
java.lang.NullPointerException - if the given event is null.
See Also:
InputEvent.isConsumed(), CommandEvent, KeyboardEvent, MouseEvent

getTheme

public Theme getTheme()
               throws java.io.IOException
Returns the theme to apply to this component. If there is no theme to this component, the parent theme will be returned. This version delegates to the parent version, if there is a parent component; otherwise, the session theme is returned.

Specified by:
getTheme in interface Component
Returns:
The theme to apply to this component.
Throws:
java.io.IOException - if there is an error loading the theme.
See Also:
getParent(), GuiseSession.getTheme()

resetTheme

public void resetTheme()
Resets this object's theme. This method sets to false the state of whether a theme has been applied to this object. This method is called for any child components resetting its own theme. No new theme is actually loaded. There is normally no need to override this method or to call this method directly by applications.

Specified by:
resetTheme in interface Component
See Also:
setThemeApplied(boolean)

updateTheme

public void updateTheme()
                 throws java.io.IOException
Updates this object's theme. This method checks whether a theme has been applied to this object. If a theme has not been applied to this object this method calls applyTheme(). This method is called for any child components before applying the theme to the component itself, to assure that child theme updates have already occured before theme updates occur for this component. There is normally no need to override this method or to call this method directly by applications.

Specified by:
updateTheme in interface Component
Throws:
java.io.IOException - if there was an error loading or applying a theme.
See Also:
isThemeApplied(), applyTheme()

applyTheme

public void applyTheme()
                throws java.io.IOException
Applies the theme to this object. Themes are only applied of the application is themed. This method may be overridden to effectively override theme settings by ensuring the state of important properties after the theme has been set. If the theme is successfully applied, this method updates the theme applied status.

Specified by:
applyTheme in interface Component
Throws:
java.io.IOException - if there was an error loading or applying a theme.
See Also:
GuiseApplication.isThemed(), getTheme(), applyTheme(Theme), setThemeApplied(boolean)

applyTheme

public void applyTheme(Theme theme)
Applies a theme and its parents to this object. The theme's rules will be applied to this object and any related objects. Theme application occurs unconditionally, regardless of whether themes have been applied to this component before. There is normally no need to call this method directly by applications.

Specified by:
applyTheme in interface Component
Parameters:
theme - The theme to apply to the object.

loadPreferences

public void loadPreferences(boolean includeDescendants)
                     throws java.io.IOException
Loads the preferences for this component and optionally any descendant components. Any preferences returned from getPreferenceProperties() will be loaded automatically.

Specified by:
loadPreferences in interface Component
Parameters:
includeDescendants - true if preferences of any descendant components should also be loaded, else false.
Throws:
java.io.IOException - if there is an error loading preferences.

savePreferences

public void savePreferences(boolean includeDescendants)
                     throws java.io.IOException
Saves the preferences for this component and optionally any descendant components. Any preferences returned from getPreferenceProperties() will be saved automatically.

Specified by:
savePreferences in interface Component
Parameters:
includeDescendants - true if preferences of any descendant components should also be saved, else false.
Throws:
java.io.IOException - if there is an error saving preferences.

addCommandListener

public void addCommandListener(CommandListener commandListener)
Adds a command listener.

Specified by:
addCommandListener in interface Component
Parameters:
commandListener - The command listener to add.

removeCommandListener

public void removeCommandListener(CommandListener commandListener)
Removes a command listener.

Specified by:
removeCommandListener in interface Component
Parameters:
commandListener - The command listener to remove.

hasCommandListeners

public boolean hasCommandListeners()
Specified by:
hasCommandListeners in interface Component
Returns:
true if there is one or more command listeners registered.

getCommandListeners

protected java.lang.Iterable<CommandListener> getCommandListeners()
Returns:
all registered command listeners.

addKeyListener

public void addKeyListener(KeyboardListener keyListener)
Adds a key listener.

Specified by:
addKeyListener in interface Component
Parameters:
keyListener - The key listener to add.

removeKeyListener

public void removeKeyListener(KeyboardListener keyListener)
Removes a key listener.

Specified by:
removeKeyListener in interface Component
Parameters:
keyListener - The key listener to remove.

hasKeyListeners

public boolean hasKeyListeners()
Specified by:
hasKeyListeners in interface Component
Returns:
true if there is one or more key listeners registered.

getKeyListeners

protected java.lang.Iterable<KeyboardListener> getKeyListeners()
Returns:
all registered key listeners.

addMouseListener

public void addMouseListener(MouseListener mouseListener)
Adds a mouse listener.

Specified by:
addMouseListener in interface Component
Parameters:
mouseListener - The mouse listener to add.

removeMouseListener

public void removeMouseListener(MouseListener mouseListener)
Removes a mouse listener.

Specified by:
removeMouseListener in interface Component
Parameters:
mouseListener - The mouse listener to remove.

hasMouseListeners

public boolean hasMouseListeners()
Specified by:
hasMouseListeners in interface Component
Returns:
true if there is one or more mouse listeners registered.

getMouseListeners

protected java.lang.Iterable<MouseListener> getMouseListeners()
Returns:
all registered mouse listeners.

getRootComponent

public static Component getRootComponent(Component component)
Determines the root parent of the given component.

Parameters:
component - The component for which the root should be found.
Returns:
The root component (the component or ancestor which has no parent).

hasAncestor

public static boolean hasAncestor(Component component,
                                  CompositeComponent ancestor)
Determines whether a component has a given component as its ancestor, not including the component itself.

Parameters:
component - The component for which the potential ancestor should be checked.
ancestor - The component to check as an ancestor.
Returns:
true if the given ancestor component is its parent or one of its parent's parents.
Throws:
java.lang.NullPointerException - if the given component and/or ancestor is null.

getComponentByID

public static Component getComponentByID(Component component,
                                         long id)
Retrieves a component with the given ID. This method checks the given component and all descendant components.

Parameters:
component - The component that should be checked, along with its descendants, for the given ID.
Returns:
The component with the given ID, or null if this component and all descendant components do not have the given ID.

getComponentByName

public static Component getComponentByName(Component component,
                                           java.lang.String name)
Retrieves a component with the given name. This method checks the given component and all descendant components.

Parameters:
component - The component that should be checked, along with its descendants, for the given name.
Returns:
The first component with the given name, or null if this component and all descendant components do not have the given name.

getDirtyComponents

public static java.util.List<Component> getDirtyComponents(Component component)
Retrieves all components that have views needing updated. This method checks the given component and all descendant components. If a given component is dirty, its child views will not be checked.

Parameters:
component - The component that should be checked, along with its descendants, for out-of-date views.
Returns:
The components with views needing to be updated.

getDirtyComponents

public static java.util.List<Component> getDirtyComponents(Component component,
                                                           java.util.List<Component> dirtyComponents)
Retrieves all components that have views needing updated. This method checks the given component and all descendant components. If a given component is dirty, its child views will not be checked.

Parameters:
component - The component that should be checked, along with its descendants, for out-of-date views.
dirtyComponents - The list that will be updated with more dirty components if any are found.
Returns:
The components with views needing to be updated.

setDepicted

public static void setDepicted(Component component,
                               boolean newUpdated)
Changes the updated status of the views of an entire component descendant hierarchy.

Parameters:
newUpdated - Whether the views of this component and all child components are up to date.

getNotifications

public static java.util.List<Notification> getNotifications(Component component)
Retrieves the the notifications of all components in a hierarchy. This method checks the given component and all descendant components. Children that are not visible and/or not displayed are not taken into account.

Parameters:
component - The component from which, along with its descendants, notifications should be retrieved.
Returns:
The notifications of all components in the hierarchy.

getNotifications

protected static java.util.List<Notification> getNotifications(Component component,
                                                               java.util.List<Notification> notifications)
Retrieves the the notifications of all components in a hierarchy. This method checks the given component and all descendant components. Children that are not visible and/or not displayed are not taken into account.

Parameters:
component - The component from which, along with its descendants, notifications should be retrieved.
notifications - The list that will be updated with more dirty components if any are found.
Returns:
The notifications of all components in the hierarchy.

addNotificationListener

public void addNotificationListener(NotificationListener notificationListener)
Adds a notification listener.

Specified by:
addNotificationListener in interface Component
Parameters:
notificationListener - The notification listener to add.

removeNotificationListener

public void removeNotificationListener(NotificationListener notificationListener)
Removes a notification listener.

Specified by:
removeNotificationListener in interface Component
Parameters:
notificationListener - The notification listener to remove.

fireNotified

protected void fireNotified(Notification notification)
Fires an event to all registered notification listeners with the new notification information. Parents are expected to refire the notification event up the hierarchy.

Parameters:
notification - The notification to send to the notification listeners.
Throws:
java.lang.NullPointerException - if the given notification is null.
See Also:
NotificationListener, NotificationEvent

fireNotified

protected void fireNotified(NotificationEvent notificationEvent)
Fires an event to all registered notification listeners with the new notification information. Parents are expected to refire copies of the notification event up the hierarchy, keeping the original target.

Parameters:
notificationEvent - The notification event to send to the notification listeners.
Throws:
java.lang.NullPointerException - if the given notification event is null.
See Also:
NotificationListener

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object
Returns:
A hash code value for the object.

equals

public boolean equals(java.lang.Object object)
Indicates whether some other object is "equal to" this one. This implementation returns whether the object is a component with the same ID.

Overrides:
equals in class java.lang.Object
Parameters:
object - The reference object with which to compare.
Returns:
true if this object is equivalent to the given object.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object
Returns:
A string representation of this depicted object.

notify

public void notify(Notification notification)
Notifies the user of the given notification information. The notification is stored in this component using setNotification(Notification), which fires appropriate notification events. This method calls GuiseSession#notify(Notification).

Specified by:
notify in interface Component
Parameters:
notification - The notification information to relay.


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