KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > lib > editor > hyperlink > spi > HyperlinkProvider


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.lib.editor.hyperlink.spi;
21
22 import javax.swing.text.Document JavaDoc;
23
24 /**
25  * This interface should be implemented by anyone who whats to provide hyperlinking
26  * functionality in the source code.
27  * <br>
28  * There should be one provider instance per mime-type.
29  * Its methods are called for all the opened editors of the given mime-type
30  * where the hyperlinking functionality gets requested.
31  *
32  * <p>
33  * The providers need to be registered.
34  * For NetBeans IDE, the default approach is to use System FileSystem.
35  * <br>
36  * The HyperlinkProvider(s) should be registered as ".instance" objects under
37  * <code>Editors/&lt;mime-type&gt;/HyperlinkProviders</code> directory.
38  * </p>
39  *
40  * <p>
41  * Please see {@link org.netbeans.lib.editor.hyperlink.HyperlinkProviderManager}
42  * for more details.
43  * </p>
44  *
45  * <p>
46  * Note: there is no assurance on the order of calling of the methods in this class.
47  * The callers may call the methods in any order and even do not call some of these methods
48  * at all.
49  * </p>
50  *
51  * @author Jan Lahoda
52  * @since 1.0
53  */

54 public interface HyperlinkProvider {
55     
56     /**
57      * Should determine whether there should be a hyperlink on the given offset
58      * in the given document. May be called any number of times for given parameters.
59      * <br>
60      * This method is called from event dispatch thread.
61      * It should run very fast as it is called very often.
62      *
63      * @param doc document on which to operate.
64      * @param offset &gt;=0 offset to test (it generally should be offset &lt; doc.getLength(), but
65      * the implementations should not depend on it)
66      * @return true if the provided offset should be in a hyperlink
67      * false otherwise
68      */

69     boolean isHyperlinkPoint(Document JavaDoc doc, int offset);
70     
71     /**
72      * Should determine the span of hyperlink on given offset. Generally, if
73      * isHyperlinkPoint returns true for a given parameters, this class should
74      * return a valid span, but it is not strictly required.
75      * <br>
76      * This method is called from event dispatch thread.
77      * This method should run very fast as it is called very often.
78      *
79      * @param doc document on which to operate.
80      * @param offset &gt;=0 offset to test (it generally should be offset &lt; doc.getLength(), but
81      * the implementations should not depend on it)
82      * @return a two member array which contains starting and ending offset of a hyperlink
83      * that should be on a given offset
84      */

85     int[] getHyperlinkSpan(Document JavaDoc doc, int offset);
86     
87     /**
88      * The implementor should perform an action
89      * corresponding to clicking on the hyperlink on the given offset. The
90      * nature of the action is given by the nature of given hyperlink, but
91      * generally should open some resource or move cursor
92      * to certain place in the current document.
93      *
94      * @param doc document on which to operate.
95      * @param offset &gt;=0 offset to test (it generally should be offset &lt; doc.getLength(), but
96      * the implementations should not depend on it)
97      */

98     void performClickAction(Document JavaDoc doc, int offset);
99     
100 }
101
Popular Tags