This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

View | Details | Raw Unified | Return to bug 53454
Collapse All | Expand All

(-)arch/arch-editor.xml (-3 / +35 lines)
Lines 678-684 Link Here
678
        </question>
678
        </question>
679
-->
679
-->
680
<answer id="lookup-register">
680
<answer id="lookup-register">
681
    No.
681
    <code>org.netbeans.modules.editor.hyperlink.LayerHyperlinkProviderManager</code>
682
    is registered using <code>META-INF/services</code>.
683
    <br/>
684
    It is an extension of <code>org.netbeans.lib.editor.hyperlink.HyperlinkProviderManager</code>
685
    allowing to instantiate the <code>org.netbeans.lib.editor.hyperlink.spi.HyperlinkProvider</code>
686
    instances from the xml layer of the System FS for particular mime-types.
682
</answer>
687
</answer>
683
688
684
689
Lines 983-988 Link Here
983
    <p>
988
    <p>
984
    Please see <a href="http://www.netbeans.org/source/browse/editor/src/org/netbeans/modules/editor/resources/layer.xml">layer.xml</a> for further details.
989
    Please see <a href="http://www.netbeans.org/source/browse/editor/src/org/netbeans/modules/editor/resources/layer.xml">layer.xml</a> for further details.
985
    </p>
990
    </p>
991
    
992
    <p>
993
    The <code>org.netbeans.lib.editor.hyperlink.spi.HyperlinkProvider</code>
994
    instances can be registered by editors for the particular mime-types
995
    into <i>Editors/|mime-type|/HyperlinkProviders</i>.
996
    <br/>
997
    There can be multiple providers registered and their order
998
    will be respected during querying by the hyperlinking infrastructure
999
    (first provider which recognizes the given offset as a hyperlinking point
1000
    will be used).
1001
    </p>
986
</answer>
1002
</answer>
987
1003
988
1004
Lines 1079-1086 Link Here
1079
The editor functionality are mainly implementations of the Swing Text package APIs
1095
The editor functionality are mainly implementations of the Swing Text package APIs
1080
plus extension features such as Syntax Coloring, Code Completion,
1096
plus extension features such as Syntax Coloring, Code Completion,
1081
Word Matching, Abbreviations or Macros.
1097
Word Matching, Abbreviations or Macros.
1082
There are no official APIs yet but the Code Folding API
1098
1083
and other extensions APIs are being formed.
1099
<h4>Hyperlink SPI</h4>
1100
<api group="java" name="EditorHyperlinkSPI" type="export" category="devel">
1101
    Hyperlink SPI in <code>org.netbeans.lib.editor.hyperlink.spi</code>
1102
    allows the editors for a particular mime-type to respond to the situation
1103
    when a user hovers over the text with a Ctrl key pressed.
1104
</api> 
1105
1106
<br/>
1107
The Hyperlink SPI resolves whether the text under the mouse is hyperlink-able
1108
and defines the span of the hyperlink and the action to be performed
1109
when the user clicks on the hyperlink.
1110
<br/>
1111
The SPI consists of a single <code>HyperlinkProvider</code>
1112
class that contains a javadoc with instructions
1113
about how to register the implementation in the xml layer for the given
1114
mime-type (mentioned in the layer section here as well).
1115
1084
</answer>
1116
</answer>
1085
1117
1086
1118
(-)libsrc/org/netbeans/lib/editor/hyperlink/spi/HyperlinkProvider.java (+94 lines)
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/&lt;mime-type&gt;/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 &gt;=0 offset to test (it generally should be offset &lt; 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 &gt;=0 offset to test (it generally should be offset &lt; 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 &gt;=0 offset to test (it generally should be offset &lt; doc.getLength(), but
90
     *               the implementations should not depend on it)
91
     */
92
    void performClickAction(Document doc, int offset);
93
    
94
}

Return to bug 53454