org.pietschy.command
Class CommandHyperlinkListener

java.lang.Object
  extended by org.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 that will interogate the href of the link and fire the appropriate command. Commands can be specified in the anchor using the following syntax

command://my.command.id?hintName1=hintValue,hintName2=hintVale

A simple command would be specified using

command://my.command.name

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

The buildAnchorString(org.pietschy.command.ActionCommand, java.util.Map, java.lang.String, java.lang.String) method can be used to create a correctly formatted URL string from a specified command.


Constructor Summary
CommandHyperlinkListener()
          Creates a new HyperlinkListener that will search for commands using the specified default CommandManager instance.
CommandHyperlinkListener(CommandManager commandManager)
          Creates a new HyperlinkListener that will search for commands using the specified CommandManager.
 
Method Summary
static java.lang.String buildAnchorString(ActionCommand 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(ActionCommand command, java.util.Map hints)
          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(ActionCommand command, java.util.Map hints, java.lang.String text)
           
static java.lang.String buildAnchorString(ActionCommand command, java.util.Map hints, java.lang.String text, java.lang.String toolTip)
           
static java.lang.String buildAnchorString(ActionCommand command, java.lang.String text)
          Builds an <a> tag for the specified command but that uses the specified text instead of the Commands normal text.
protected  java.lang.String getCommandIdFromUrl(java.lang.String url)
           
protected  java.util.Map getHints(java.lang.String url)
           
protected  javax.swing.JPopupMenu getPopupFor(CommandGroup group)
           
 void hyperlinkUpdate(javax.swing.event.HyperlinkEvent e)
           
static void main(java.lang.String[] args)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CommandHyperlinkListener

public CommandHyperlinkListener(CommandManager commandManager)
Creates a new HyperlinkListener that will search for commands using the specified CommandManager.

Parameters:
commandManager - the container used to locate commands.

CommandHyperlinkListener

public CommandHyperlinkListener()
Creates a new HyperlinkListener that will search for commands using the specified default CommandManager instance. It is equivalent to calling CommandHyperlinkListener(org.pietschy.command.CommandManager) with CommandManager.defaultInstance as the argument.

Method Detail

hyperlinkUpdate

public void hyperlinkUpdate(javax.swing.event.HyperlinkEvent e)
Specified by:
hyperlinkUpdate in interface javax.swing.event.HyperlinkListener

getCommandIdFromUrl

protected java.lang.String getCommandIdFromUrl(java.lang.String url)

getHints

protected java.util.Map getHints(java.lang.String url)

getPopupFor

protected javax.swing.JPopupMenu getPopupFor(CommandGroup group)

buildAnchorString

public static java.lang.String buildAnchorString(ActionCommand command,
                                                 java.util.Map hints,
                                                 java.lang.String text,
                                                 java.lang.String toolTip)
Parameters:
command -
hints -
text -
Returns:

buildAnchorString

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

buildAnchorString

public static java.lang.String buildAnchorString(ActionCommand command,
                                                 java.lang.String text)
Builds an <a> tag for the specified command but that uses the specified text instead of the Commands normal text.

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

buildAnchorString

public static java.lang.String buildAnchorString(ActionCommand 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 specified, the default face is used otherwise.

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 hints)
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 specified, the default face is used otherwise.

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

main

public static void main(java.lang.String[] args)