Class AbstractControl

All Implemented Interfaces:
com.globalmentor.beans.PropertyBindable, com.globalmentor.beans.PropertyConstrainable, Component, Control, InputFocusableComponent, Displayable, Enableable, InfoModel, LabelModel, Model, PresentationModel, DepictedObject
Direct Known Subclasses:
AbstractActionControl, AbstractValueControl, ResourceCollectControl

public abstract class AbstractControl extends AbstractComponent implements Control
An abstract implementation of a model component that allows user interaction to modify the model.
Author:
Garret Wilson
  • Constructor Details

    • AbstractControl

      public AbstractControl(InfoModel infoModel, Enableable enableable)
      Info model and enableable object constructor.
      Parameters:
      infoModel - The component info model.
      enableable - The enableable object in which to store enabled status.
      Throws:
      NullPointerException - if the given info model and/or enableable object is null.
  • Method Details

    • getEnableable

      protected Enableable getEnableable()
      Returns:
      The enableable object decorated by this component.
    • getStatus

      public Control.Status getStatus()
      Specified by:
      getStatus in interface Control
      Returns:
      The status of the current user input, or null if there is no status to report.
    • setStatus

      protected void setStatus(Control.Status newStatus)
      Sets the status of the current user input. This is a bound property.
      Parameters:
      newStatus - The new status of the current user input, or null if there is no status to report.
      See Also:
    • updateStatus

      protected void updateStatus()
      Rechecks user input status of this component, and updates the status.
      See Also:
    • determineStatus

      protected Control.Status determineStatus()
      Checks the user input status of the control. If the component has a notification of Notification.Severity.WARN, the status is determined to be Control.Status.WARNING. If the component has a notification of Notification.Severity.ERROR, the status is determined to be Control.Status.ERROR. Otherwise, this version returns null. If the control is disabled null is returned.
      Returns:
      The current user input status of the control.
    • 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.

      This version also updates the status.

      Overrides:
      updateValid in class AbstractComponent
      See Also:
    • 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.

      This version updates the component status if the notification changes.

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

      public void reset()
      Resets the control to its default value.

      This version clears any notification.

      Specified by:
      reset in interface Control
      See Also:
    • isEnabled

      public boolean isEnabled()
      Specified by:
      isEnabled in interface Enableable
      Returns:
      Whether the object is enabled and can receive user input.
    • setEnabled

      public void setEnabled(boolean newEnabled)
      Description copied from interface: Enableable
      Sets whether the object is enabled and can receive user input. This is a bound property of type Boolean.
      Specified by:
      setEnabled in interface Enableable
      Parameters:
      newEnabled - true if the object should indicate and accept user input.
      See Also: