Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.pietschy.command
Class CommandHyperlinkListener

    java.lang.Object
      com.pietschy.command.CommandHyperlinkListener

All Implemented Interfaces:
  java.util.EventListener, javax.swing.event.HyperlinkListener

    public class CommandHyperlinkListener

extends java.lang.Object
implements javax.swing.event.HyperlinkListener

A `HyperlinkListener` implementation that will use the href attribute of the link to lookup and activate the associated command. The following anchor syntax is supported:

      command://command-id?parameterName1=value,paramterName2=Value

A simple command would be specified using

      command://command-id

If the command is an `ActionCommand` it will be invoked, otherwise if it is a `CommandGroup` then a popup will be displayed using the `Face.HTML_POPUP` context.

The `buildAnchorString(Command)` methods can be used to create a correctly formatted anchor strings from a given command.

The `command://` protocol is not registered with the standard URL infrastructure.

Nested Class Summary
`static class` | `CommandHyperlinkListener.CommandContainerLocator` A locator that locates commands from a `CommandContainer`.
`static class` | `CommandHyperlinkListener.CommandListLocator` A locator built from a simple list of commands.

Constructor Summary
`CommandHyperlinkListener(Command... commands)` Creates a new `HyperlinkListener` that will use the specified list of commands.
`CommandHyperlinkListener(CommandContainer container)` Creates a new `HyperlinkListener` that will search for commands using the specified container.
`CommandHyperlinkListener(com.pietschy.command.CommandHyperlinkListener.CommandLocator commandLocator)` Creates a new `HyperlinkListener` that will search for commands using the specified command source.

Method Summary
`static java.lang.String` | `buildAnchorString(ActionCommand command, java.util.Map<java.lang.String,java.lang.String> parameters)` Builds an <a> tag for the specified command using the commands text attribute to populate the link text and the short description to populate the tooltip.
`static java.lang.String` | `buildAnchorString(ActionCommand command, java.util.Map parameters, java.lang.String text, java.lang.String tooltip)` Builds an anchor string for the specified command using the specified parameters, text and tooltip.
`static java.lang.String` | `buildAnchorString(Command command)` Builds an <a> tag for the specified command using the commands text attribute to populate the links text and the short description to populate the tooltip.
`static java.lang.String` | `buildAnchorString(Command command, java.lang.String text, java.lang.String tooltip)` Builds an anchor string for the specified command using the specified text and tooltip.
`(package private) java.lang.String` | `extractCommandId(java.lang.String url)` Extracts the command id from urls of the form "command://command-id?param=value"
`(package private) java.util.Map<java.lang.Object,java.lang.Object>` | `extractParameters(java.lang.String url)` Extracts the command paramters from urls of the form "command://command-id?param=value"
`protected Command` | `getCommand(java.lang.String commandId)`
`void` | `hyperlinkUpdate(javax.swing.event.HyperlinkEvent e)` Handles a hyperlink update event.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### CommandHyperlinkListener

    public CommandHyperlinkListener(CommandContainer container)

  Creates a new `HyperlinkListener` that will search for commands using the specified container.

  Parameters:
    `container` - the container used to locate commands.

### CommandHyperlinkListener

    public CommandHyperlinkListener(Command... commands)

  Creates a new `HyperlinkListener` that will use the specified list of commands.

  Parameters:
    `commands` - a list of commands for the listener to use.

### CommandHyperlinkListener

    public CommandHyperlinkListener(com.pietschy.command.CommandHyperlinkListener.CommandLocator commandLocator)

  Creates a new `HyperlinkListener` that will search for commands using the specified command source.

  Parameters:
    `commandLocator` - the locator for retriving commands from an id.

Method Detail

### hyperlinkUpdate

    public void hyperlinkUpdate(javax.swing.event.HyperlinkEvent e)

  Handles a hyperlink update event.

  Specified by:
    `hyperlinkUpdate` in interface `javax.swing.event.HyperlinkListener`
  Parameters:
    `e` - the event.

### getCommand

    protected Command getCommand(java.lang.String commandId)

### extractCommandId

    java.lang.String extractCommandId(java.lang.String url)

  Extracts the command id from urls of the form "command://command-id?param=value"

  Parameters:
    `url` - the url.

### extractParameters

    java.util.Map<java.lang.Object,java.lang.Object> extractParameters(java.lang.String url)

  Extracts the command paramters from urls of the form "command://command-id?param=value"

  Parameters:
    `url` - the url.

### buildAnchorString

    public static java.lang.String buildAnchorString(ActionCommand command,
                                                     java.util.Map parameters,
                                                     java.lang.String text,
                                                     java.lang.String tooltip)

  Builds an anchor string for the specified command using the specified parameters, text and tooltip. The results will be of the editor:

         <a href="command-id?param=value" title="tooltip">text<a>

  Parameters:
    `command` - the command
    `parameters` - the parameters
    `text` - the text to display
    `tooltip` - the tooltip to display

### buildAnchorString

    public static java.lang.String buildAnchorString(Command command,
                                                     java.lang.String text,
                                                     java.lang.String tooltip)

  Builds an anchor string for the specified command using the specified text and tooltip. The results will be of the editor:

         <a href="command-id" title="tooltip">text<a>

  Parameters:
    `command` - the command
    `text` - the text to display
    `tooltip` - the tooltip to display

### buildAnchorString

    public static java.lang.String buildAnchorString(Command command)

  Builds an <a> tag for the specified command using the commands text attribute to populate the links text and the short description to populate the tooltip. The "html" face is used if defined.

  Parameters:
    `command` - the command to be activated by the link
  Returns:
    a formated <a> tag to be inserted into html.

### buildAnchorString

    public static java.lang.String buildAnchorString(ActionCommand command,
                                                     java.util.Map<java.lang.String,java.lang.String> parameters)

  Builds an <a> tag for the specified command using the commands text attribute to populate the link text and the short description to populate the tooltip. The "html" face is used if available.

  Parameters:
    `command` - the command to be activated by the link
    `parameters` - a map of hints to be specified to the command when it executes.
  Returns:
    a formated <a> tag to be inserted into html.

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2006 - 2007 Andrew Pietsch