uk.ac.starlink.connect

## Class ConnectorAction

- java.lang.Object
- - javax.swing.AbstractAction
  - - uk.ac.starlink.connect.ConnectorAction

- All Implemented Interfaces:
    java.awt.event.ActionListener, java.io.Serializable, java.lang.Cloneable, java.util.EventListener, javax.swing.Action

      public class ConnectorAction
      extends javax.swing.AbstractAction

  Action which controls logging in to and out of a remote service using a `Connector` object. This action can be put into a button whose text will read "Log In" and "Log Out" as appropriate. It has a property with the key `CONNECTION_PROPERTY` which contains the active `Connection` object, so that PropertyChangeListeners may be configured to watch when a connection is established or broken. A log in attempt will pop up a modal dialogue asking for the various authorization information required to attempt the connection.
  Since:
    18 Feb 2005
  See Also:
    Serialized Form

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static java.lang.String` | `CONNECTION_PROPERTY` Key for the property which stores a `Connection` object.

    - ### Fields inherited from class javax.swing.AbstractAction

      `changeSupport, enabled`

    - ### Fields inherited from interface javax.swing.Action

      `ACCELERATOR_KEY, ACTION_COMMAND_KEY, DEFAULT, DISPLAYED_MNEMONIC_INDEX_KEY, LARGE_ICON_KEY, LONG_DESCRIPTION, MNEMONIC_KEY, NAME, SELECTED_KEY, SHORT_DESCRIPTION, SMALL_ICON`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `ConnectorAction(Connector connector)` Constructor.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `actionPerformed(java.awt.event.ActionEvent evt)`
    `protected javax.swing.JDialog` | `createDialog(java.awt.Component parent)` Constructs the dialogue which is used to ask the user for authorization information.
    `Connection` | `getConnection()` Returns the currently active connection.
    `Connector` | `getConnector()` Returns the connector used by this action.
    `void` | `setEnabled(boolean enabled)`

    - ### Methods inherited from class javax.swing.AbstractAction

      `addPropertyChangeListener, clone, firePropertyChange, getKeys, getPropertyChangeListeners, getValue, isEnabled, putValue, removePropertyChangeListener`

    - ### Methods inherited from class java.lang.Object

      `equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### CONNECTION_PROPERTY

          public static final java.lang.String CONNECTION_PROPERTY

      Key for the property which stores a `Connection` object.
      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### ConnectorAction

          public ConnectorAction(Connector connector)

      Constructor.
      Parameters:
        `connector` - connector describing the service this action can connect to

  - ### Method Detail

    - #### actionPerformed

          public void actionPerformed(java.awt.event.ActionEvent evt)

    - #### createDialog

          protected javax.swing.JDialog createDialog(java.awt.Component parent)

      Constructs the dialogue which is used to ask the user for authorization information.
      Parameters:
        `parent` - parent component
      Returns:
        dialogue

    - #### setEnabled

          public void setEnabled(boolean enabled)

      Specified by:
        `setEnabled` in interface `javax.swing.Action`
      Overrides:
        `setEnabled` in class `javax.swing.AbstractAction`

    - #### getConnector

          public Connector getConnector()

      Returns the connector used by this action.
      Returns:
        connector

    - #### getConnection

          public Connection getConnection()

      Returns the currently active connection. May be null if no connection is active. If the connection has expired, this may result in the connection property being reset to `null`. Thus it's very likely that the connection returned from this method will be active, but it can't be guaranteed that it won't have expired between this method returning it and the caller receiving it.
      Returns:
        connection, hopefully an active one