Class DefaultHyperlinkListener
- java.lang.Object
-
- com.biomatters.geneious.publicapi.components.DefaultHyperlinkListener
-
- All Implemented Interfaces:
java.util.EventListener
,javax.swing.event.HyperlinkListener
public class DefaultHyperlinkListener extends java.lang.Object implements javax.swing.event.HyperlinkListener
A simple implementation ofHyperlinkListener
which invokes the system's default browser. It also attempts to ensure that the hand cursor is displayed when the mouse is placed over a hyperlink.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
DefaultHyperlinkListener.SerializableRunnable
An interface intended for use withgetUrlForMethod(SerializableRunnable)
-
Constructor Summary
Constructors Constructor Description DefaultHyperlinkListener()
Construct a new DefaultHyperlinkListener
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static boolean
followHyperlink(java.lang.String hyperlink)
Follows a hyperlink, either by opening it in an external web browser (if it is a URL), or selecting the document (if it is a Geneious URN)static java.lang.String
getUrlForMethod(DefaultHyperlinkListener.SerializableRunnable runnable)
Creates a URL that calls the given runnable when clicked on.void
hyperlinkUpdate(javax.swing.event.HyperlinkEvent e)
-
-
-
Method Detail
-
hyperlinkUpdate
public void hyperlinkUpdate(javax.swing.event.HyperlinkEvent e)
- Specified by:
hyperlinkUpdate
in interfacejavax.swing.event.HyperlinkListener
-
followHyperlink
public static boolean followHyperlink(java.lang.String hyperlink)
Follows a hyperlink, either by opening it in an external web browser (if it is a URL), or selecting the document (if it is a Geneious URN)- Parameters:
hyperlink
- the hyperlink. Must not be null.- Returns:
- true if the link was successfully followed.
- Since:
- API 4.1100 (Geneious 11.0.0)
-
getUrlForMethod
public static java.lang.String getUrlForMethod(DefaultHyperlinkListener.SerializableRunnable runnable)
Creates a URL that calls the given runnable when clicked on.
Warning: This method will fail when used with lambdas due to problems combining lambdas with separate class loaders. Therefore the SerializableRunnable passed in should ideally be a static instance field.
e.g.private static DefaultHyperlinkListener.SerializableRunnable showDialog = new DefaultHyperlinkListener.SerializableRunnable() { public void run() { Dialogs.showDialog("test dialog"); }; public static String getHtmlMessageWithLinkToShowDialog() { return "<html>a message with a <a href=\"" + DefaultHyperlinkListener.getUrlForMethod(showDialog) + "\">link</a></html>"; }
- Parameters:
runnable
- a runnable in invoke when the a hyperlink containing the returned URL is clicked on.- Returns:
- a URL that can appear inside a hyperlink which will cause a DefaultHyperlinkListener to invoke the runnable when clicked on.
- Since:
- API 4.1000 (Geneious 10.0.0)
- See Also:
StringUtilities.createHyperlink(String, String)
-
-