Class LinkAction<T>

  • All Implemented Interfaces:
    java.awt.event.ActionListener, java.awt.event.ItemListener, java.io.Serializable, java.lang.Cloneable, java.util.EventListener, javax.swing.Action
    Direct Known Subclasses:
    LinkModelAction

    public abstract class LinkAction<T>
    extends AbstractActionExt
    Convenience implementation to simplify JXHyperlink configuration and provide minimal api as needed by a org.jdesktop.swingx.hyperlink.LinkRenderer.

    PENDING: rename to AbstractLinkAction

    See Also:
    Serialized Form
    • Field Detail

      • VISITED_KEY

        public static final java.lang.String VISITED_KEY
        Key for the visited property value.
        See Also:
        Constant Field Values
      • target

        protected T target
        the object the actionPerformed can act on.
    • Constructor Detail

      • LinkAction

        public LinkAction()
        Instantiates a LinkAction with null target.
      • LinkAction

        public LinkAction​(T target)
        Instantiates a LinkAction with a target of type targetClass. The visited property is initialized as defined by installTarget()
        Parameters:
        target - the target this action should act on.
    • Method Detail

      • setVisited

        public void setVisited​(boolean visited)
        Set the visited property.
        Parameters:
        visited -
      • isVisited

        public boolean isVisited()
        Returns:
        visited state
      • getTarget

        public T getTarget()
      • setTarget

        public void setTarget​(T target)
        PRE: isTargetable(target)
        Parameters:
        target -
      • installTarget

        protected void installTarget()
        hook for subclasses to update internal state after a new target has been set.

        Subclasses are free to decide the details. Here:

        • the text property is set to target.toString or empty String if the target is null
        • visited is set to false.
      • uninstallTarget

        protected void uninstallTarget()
        hook for subclasses to cleanup before the old target is overwritten.

        Subclasses are free to decide the details. Here: does nothing.

      • itemStateChanged

        public void itemStateChanged​(java.awt.event.ItemEvent e)
        Description copied from class: AbstractActionExt
        Callback method as ItemListener. Updates internal state based on the given ItemEvent.

        Here: synchs selected property if isStateAction(), does nothing otherwise.

        Specified by:
        itemStateChanged in interface java.awt.event.ItemListener
        Overrides:
        itemStateChanged in class AbstractActionExt
        Parameters:
        e - the ItemEvent fired by a ItemSelectable on changing the selected state.
      • setStateAction

        public void setStateAction​(boolean state)
        Set the state property. Overridden to to nothing. PENDING: really?
        Overrides:
        setStateAction in class AbstractActionExt
        Parameters:
        state - if true then this action will fire ItemEvents