站内搜索: 请输入搜索关键词
当前页面: 在线文档首页 > NetBeans API Javadoc (Current Development Version)

HyperlinkProvider (Editor Library) - NetBeans API Javadoc (Current Development Version)

org.netbeans.modules.editor.lib/1 1.14.0 3

org.netbeans.lib.editor.hyperlink.spi
Interface HyperlinkProvider


public interface HyperlinkProvider

This interface should be implemented by anyone who whats to provide hyperlinking functionality in the source code.
There should be one provider instance per mime-type. Its methods are called for all the opened editors of the given mime-type where the hyperlinking functionality gets requested.

The providers need to be registered. For NetBeans IDE, the default approach is to use System FileSystem.
The HyperlinkProvider(s) should be registered as ".instance" objects under Editors/<mime-type>/HyperlinkProviders directory.

Please see HyperlinkProviderManager for more details.

Note: there is no assurance on the order of calling of the methods in this class. The callers may call the methods in any order and even do not call some of these methods at all.

Since:
1.0

Method Summary
 int[] getHyperlinkSpan(Document doc, int offset)
          Should determine the span of hyperlink on given offset.
 boolean isHyperlinkPoint(Document doc, int offset)
          Should determine whether there should be a hyperlink on the given offset in the given document.
 void performClickAction(Document doc, int offset)
          The implementor should perform an action corresponding to clicking on the hyperlink on the given offset.
 

Method Detail

isHyperlinkPoint

boolean isHyperlinkPoint(Document doc,
                         int offset)
Should determine whether there should be a hyperlink on the given offset in the given document. May be called any number of times for given parameters.
This method is called from event dispatch thread. It should run very fast as it is called very often.

Parameters:
doc - document on which to operate.
offset - >=0 offset to test (it generally should be offset < doc.getLength(), but the implementations should not depend on it)
Returns:
true if the provided offset should be in a hyperlink false otherwise

getHyperlinkSpan

int[] getHyperlinkSpan(Document doc,
                       int offset)
Should determine the span of hyperlink on given offset. Generally, if isHyperlinkPoint returns true for a given parameters, this class should return a valid span, but it is not strictly required.
This method is called from event dispatch thread. This method should run very fast as it is called very often.

Parameters:
doc - document on which to operate.
offset - >=0 offset to test (it generally should be offset < doc.getLength(), but the implementations should not depend on it)
Returns:
a two member array which contains starting and ending offset of a hyperlink that should be on a given offset

performClickAction

void performClickAction(Document doc,
                        int offset)
The implementor should perform an action corresponding to clicking on the hyperlink on the given offset. The nature of the action is given by the nature of given hyperlink, but generally should open some resource or move cursor to certain place in the current document.

Parameters:
doc - document on which to operate.
offset - >=0 offset to test (it generally should be offset < doc.getLength(), but the implementations should not depend on it)

org.netbeans.modules.editor.lib/1 1.14.0 3

Built on May 28 2007.  |  Portions Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.