[25584] | 1 | /*
|
---|
| 2 | * 07/29/2009
|
---|
| 3 | *
|
---|
| 4 | * ToolTipInfo.java - A tool tip's text and hyperlink listener.
|
---|
| 5 | *
|
---|
| 6 | * This library is distributed under a modified BSD license. See the included
|
---|
| 7 | * RSyntaxTextArea.License.txt file for details.
|
---|
| 8 | */
|
---|
| 9 | package org.fife.ui.rsyntaxtextarea.parser;
|
---|
| 10 |
|
---|
| 11 | import java.net.URL;
|
---|
| 12 | import javax.swing.event.HyperlinkListener;
|
---|
| 13 |
|
---|
| 14 | import org.fife.ui.rsyntaxtextarea.RSyntaxTextArea;
|
---|
| 15 | import org.fife.ui.rsyntaxtextarea.focusabletip.FocusableTip;
|
---|
| 16 |
|
---|
| 17 |
|
---|
| 18 | /**
|
---|
| 19 | * Wrapper for a tool tip and a listener for hyperlink events in the tool
|
---|
| 20 | * tip (assuming the tip is HTML). If the {@link RSyntaxTextArea} instance
|
---|
| 21 | * has {@link FocusableTip}s enabled, and the user clicks on a hyperlink in
|
---|
| 22 | * the tool tip, the specified {@link HyperlinkListener} will be called.
|
---|
| 23 | *
|
---|
| 24 | * @author Robert Futrell
|
---|
| 25 | * @version 1.0
|
---|
| 26 | */
|
---|
| 27 | public class ToolTipInfo {
|
---|
| 28 |
|
---|
| 29 | private String text;
|
---|
| 30 | private HyperlinkListener listener;
|
---|
| 31 | private URL imageBase;
|
---|
| 32 |
|
---|
| 33 |
|
---|
| 34 | /**
|
---|
| 35 | * Constructor.
|
---|
| 36 | *
|
---|
| 37 | * @param text The tool tip text, or <code>null</code> for none.
|
---|
| 38 | * @param listener The hyperlink listener, or <code>null</code> for none.
|
---|
| 39 | */
|
---|
| 40 | public ToolTipInfo(String text, HyperlinkListener listener) {
|
---|
| 41 | this(text, listener, null);
|
---|
| 42 | }
|
---|
| 43 |
|
---|
| 44 |
|
---|
| 45 | /**
|
---|
| 46 | * Constructor.
|
---|
| 47 | *
|
---|
| 48 | * @param text The tool tip text, or <code>null</code> for none.
|
---|
| 49 | * @param l The hyperlink listener, or <code>null</code> for none.
|
---|
| 50 | * @param imageBase The base URL for images in the HTML <code>text</code>,
|
---|
| 51 | * or <code>null</code> for the default.
|
---|
| 52 | */
|
---|
| 53 | public ToolTipInfo(String text, HyperlinkListener l, URL imageBase) {
|
---|
| 54 | this.text = text;
|
---|
| 55 | this.listener = l;
|
---|
| 56 | this.imageBase = imageBase;
|
---|
| 57 | }
|
---|
| 58 |
|
---|
| 59 |
|
---|
| 60 | /**
|
---|
| 61 | * Returns the listener to call when hyperlinks are clicked in the tool
|
---|
| 62 | * tip.
|
---|
| 63 | *
|
---|
| 64 | * @return The listener, or <code>null</code> for none.
|
---|
| 65 | */
|
---|
| 66 | public HyperlinkListener getHyperlinkListener() {
|
---|
| 67 | return listener;
|
---|
| 68 | }
|
---|
| 69 |
|
---|
| 70 |
|
---|
| 71 | /**
|
---|
| 72 | * Returns the base URL that any images in the HTML tool tip live in.
|
---|
| 73 | * This allows you to reference images in a jar file in your
|
---|
| 74 | * {@link FocusableTip}s.
|
---|
| 75 | * Note that if what {@link #getToolTipText()} returns isn't HTML, this
|
---|
| 76 | * value is effectively ignored.
|
---|
| 77 | *
|
---|
| 78 | * @return The image base, or <code>null</code> for the default.
|
---|
| 79 | */
|
---|
| 80 | public URL getImageBase() {
|
---|
| 81 | return imageBase;
|
---|
| 82 | }
|
---|
| 83 |
|
---|
| 84 |
|
---|
| 85 | /**
|
---|
| 86 | * Returns the tool tip text to display.
|
---|
| 87 | *
|
---|
| 88 | * @return The tool tip text, or <code>null</code> for none.
|
---|
| 89 | */
|
---|
| 90 | public String getToolTipText() {
|
---|
| 91 | return text;
|
---|
| 92 | }
|
---|
| 93 |
|
---|
| 94 |
|
---|
| 95 | } |
---|