org.pietschy.command

Class CommandHyperlinkListener

Implemented Interfaces:
HyperlinkListener

public class CommandHyperlinkListener
extends java.lang.Object
implements HyperlinkListener

A javax.swing.event.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 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 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 String
buildAnchorString(ActionCommand command, 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 String
buildAnchorString(ActionCommand command, Map hints, String text)
static String
buildAnchorString(ActionCommand command, Map hints, String text, String toolTip)
static String
buildAnchorString(ActionCommand command, String text)
Builds an <a> tag for the specified command but that uses the specified text instead of the Commands normal text.
protected String
getCommandIdFromUrl(String url)
protected Map
getHints(String url)
protected JPopupMenu
getPopupFor(CommandGroup group)
void
hyperlinkUpdate(HyperlinkEvent e)
static void
main(String[] args)

Constructor Details

CommandHyperlinkListener

public CommandHyperlinkListener()

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.

Method Details

buildAnchorString

public static 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 String buildAnchorString(ActionCommand command,
                                       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.

buildAnchorString

public static String buildAnchorString(ActionCommand command,
                                       Map hints,
                                       String text)

buildAnchorString

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

buildAnchorString

public static String buildAnchorString(ActionCommand command,
                                       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.

getCommandIdFromUrl

protected String getCommandIdFromUrl(String url)

getHints

protected Map getHints(String url)

getPopupFor

protected JPopupMenu getPopupFor(CommandGroup group)

hyperlinkUpdate

public void hyperlinkUpdate(HyperlinkEvent e)

main

public static void main(String[] args)