source: other-projects/rsyntax-textarea/src/java/org/fife/ui/rsyntaxtextarea/parser/ToolTipInfo.java@ 25584

Last change on this file since 25584 was 25584, checked in by davidb, 12 years ago

Initial cut an a text edit area for GLI that supports color syntax highlighting

File size: 2.5 KB
Line 
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 */
9package org.fife.ui.rsyntaxtextarea.parser;
10
11import java.net.URL;
12import javax.swing.event.HyperlinkListener;
13
14import org.fife.ui.rsyntaxtextarea.RSyntaxTextArea;
15import 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 */
27public 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}
Note: See TracBrowser for help on using the repository browser.