Class AbstractActionValueControl<V>

    • Constructor Detail

      • AbstractActionValueControl

        public AbstractActionValueControl​(InfoModel infoModel,
                                          ActionModel actionModel,
                                          ValueModel<V> valueModel,
                                          Enableable enableable)
        Info model, action model, value model, and enableable object constructor.
        Parameters:
        infoModel - The component info model.
        actionModel - The component action model.
        valueModel - The component value model.
        enableable - The enableable object in which to store enabled status.
        Throws:
        java.lang.NullPointerException - if the given info model, action model, and/or enableable object is null.
    • Method Detail

      • getValueModel

        protected ValueModel<V> getValueModel()
        Returns:
        The value model used by this component.
      • getValueGlyphURI

        public java.net.URI getValueGlyphURI​(V value)
        Description copied from interface: ActionValueControl
        Retrieves the icon associated with a given value.
        Specified by:
        getValueGlyphURI in interface ActionValueControl<V>
        Parameters:
        value - The value for which an associated icon should be returned, or null to retrieve the icon associated with the null value.
        Returns:
        The value icon URI, which may be a resource URI, or null if the value has no associated icon URI.
      • setValueGlyphURI

        public void setValueGlyphURI​(V value,
                                     java.net.URI newValueIcon)
        Description copied from interface: ActionValueControl
        Sets the URI of the icon associated with a value. This method fires a property change event for the changed icon if its value changes.
        Specified by:
        setValueGlyphURI in interface ActionValueControl<V>
        Parameters:
        value - The value with which the icon should be associated, or null if the icon should be associated with the null value.
        newValueIcon - The new URI of the value icon, which may be a resource URI.
        See Also:
        ActionValueControl.VALUE_GLYPH_URI_PROPERTY
      • firePropertyChange

        protected <VV> void firePropertyChange​(java.lang.String propertyName,
                                               VV oldValue,
                                               VV newValue)

        This version first updates the valid status if the value is reported as being changed.

        Overrides:
        firePropertyChange in class com.globalmentor.beans.BoundPropertyObject
      • determineValid

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

        This version checks the validity of the value model.

        Overrides:
        determineValid in class AbstractComponent
        Returns:
        true if the component and all children passes all validity tests, else false.
      • 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 AbstractComponent.updateValid().

        This version validates the associated value model.

        Specified by:
        validate in interface Component
        Overrides:
        validate in class AbstractComponent
        Returns:
        The current state of Component.isValid() as a convenience.
      • getValue

        public V getValue()
        Specified by:
        getValue in interface com.globalmentor.model.Valued<V>
        Specified by:
        getValue in interface ValuedComponent<V>
        Specified by:
        getValue in interface ValueModel<V>
        Returns:
        The input value, or null if there is no input value.
      • setValue

        public void setValue​(V newValue)
                      throws java.beans.PropertyVetoException
        Description copied from interface: ValueModel
        Sets the new value. This is a bound property that only fires a change event when the new value is different via the equals() method. If a validator is installed, the value will first be validated before the current value is changed. Validation always occurs if a validator is installed, even if the value is not changing. If the value change is vetoed by the installed validator, the validation exception will be accessible via Throwable.getCause().
        Specified by:
        setValue in interface com.globalmentor.model.MutableValued<V>
        Specified by:
        setValue in interface ValuedComponent<V>
        Specified by:
        setValue in interface ValueModel<V>
        Parameters:
        newValue - The new value.
        Throws:
        java.beans.PropertyVetoException - if the provided value is not valid or the change has otherwise been vetoed.
        See Also:
        ValueModel.getValidator(), ValueModel.VALUE_PROPERTY
      • clearValue

        public void clearValue()
        Description copied from interface: ValueModel
        Clears the value by setting the value to null, which may be invalid according to any installed validators. No validation occurs.
        Specified by:
        clearValue in interface ValueModel<V>
        See Also:
        ValueModel.VALUE_PROPERTY
      • resetValue

        public void resetValue()
        Description copied from interface: ValueModel
        Resets the value to a default value, which may be invalid according to any installed validators. No validation occurs.
        Specified by:
        resetValue in interface ValueModel<V>
        See Also:
        ValueModel.VALUE_PROPERTY
      • getValidator

        public Validator<V> getValidator()
        Specified by:
        getValidator in interface ValueModel<V>
        Returns:
        The validator for this model, or null if no validator is installed.
      • isValidValue

        public boolean isValidValue()
        Description copied from interface: ValueModel
        Determines whether the value of this model is valid.
        Specified by:
        isValidValue in interface ValueModel<V>
        Returns:
        Whether the value of this model is valid.