Added
Link Here
|
1 |
/* |
2 |
* Sun Public License Notice |
3 |
* |
4 |
* The contents of this file are subject to the Sun Public License |
5 |
* Version 1.0 (the "License"). You may not use this file except in |
6 |
* compliance with the License. A copy of the License is available at |
7 |
* http://www.sun.com/ |
8 |
* |
9 |
* The Original Code is NetBeans. The Initial Developer of the Original |
10 |
* Code is Sun Microsystems, Inc. Portions Copyright 1997-2004 Sun |
11 |
* Microsystems, Inc. All Rights Reserved. |
12 |
*/ |
13 |
|
14 |
package org.netbeans.lib.editor.hyperlink.spi; |
15 |
|
16 |
import javax.swing.text.Document; |
17 |
|
18 |
/** |
19 |
* This interface should be implemented by anyone who whats to provide hyperlinking |
20 |
* functionality in the source code. |
21 |
* <br> |
22 |
* There should be one provider instance per mime-type. |
23 |
* Its methods are called for all the opened editors of the given mime-type |
24 |
* where the hyperlinking functionality gets requested. |
25 |
* |
26 |
* <p> |
27 |
* The providers need to be registered. |
28 |
* For NetBeans IDE, the default approach is to use System FileSystem. |
29 |
* <br> |
30 |
* The HyperlinkProvider(s) should be registered as ".instance" objects under |
31 |
* <code>Editors/<mime-type>/HyperlinkProviders</code> directory. |
32 |
* </p> |
33 |
* |
34 |
* <p> |
35 |
* Please see {@link org.netbeans.lib.editor.hyperlink.HyperlinkProviderManager} |
36 |
* for more details. |
37 |
* </p> |
38 |
* |
39 |
* <p> |
40 |
* Note: there is no assurance on the order of calling of the methods in this class. |
41 |
* The callers may call the methods in any order and even do not call some of these methods |
42 |
* at all. |
43 |
* </p> |
44 |
* |
45 |
* @author Jan Lahoda |
46 |
* @since 1.0 |
47 |
*/ |
48 |
public interface HyperlinkProvider { |
49 |
|
50 |
/** |
51 |
* Should determine whether there should be a hyperlink on the given offset |
52 |
* in the given document. May be called any number of times for given parameters. |
53 |
* <br> |
54 |
* This method is called from event dispatch thread. |
55 |
* It should run very fast as it is called very often. |
56 |
* |
57 |
* @param doc document on which to operate. |
58 |
* @param offset >=0 offset to test (it generally should be offset < doc.getLength(), but |
59 |
* the implementations should not depend on it) |
60 |
* @return true if the provided offset should be in a hyperlink |
61 |
* false otherwise |
62 |
*/ |
63 |
boolean isHyperlinkPoint(Document doc, int offset); |
64 |
|
65 |
/** |
66 |
* Should determine the span of hyperlink on given offset. Generally, if |
67 |
* isHyperlinkPoint returns true for a given parameters, this class should |
68 |
* return a valid span, but it is not strictly required. |
69 |
* <br> |
70 |
* This method is called from event dispatch thread. |
71 |
* This method should run very fast as it is called very often. |
72 |
* |
73 |
* @param doc document on which to operate. |
74 |
* @param offset >=0 offset to test (it generally should be offset < doc.getLength(), but |
75 |
* the implementations should not depend on it) |
76 |
* @return a two member array which contains starting and ending offset of a hyperlink |
77 |
* that should be on a given offset |
78 |
*/ |
79 |
int[] getHyperlinkSpan(Document doc, int offset); |
80 |
|
81 |
/** |
82 |
* The implementor should perform an action |
83 |
* corresponding to clicking on the hyperlink on the given offset. The |
84 |
* nature of the action is given by the nature of given hyperlink, but |
85 |
* generally should open some resource or move cursor |
86 |
* to certain place in the current document. |
87 |
* |
88 |
* @param doc document on which to operate. |
89 |
* @param offset >=0 offset to test (it generally should be offset < doc.getLength(), but |
90 |
* the implementations should not depend on it) |
91 |
*/ |
92 |
void performClickAction(Document doc, int offset); |
93 |
|
94 |
} |