Package org.eclipse.jface.text.hyperlink
Class HyperlinkManager
java.lang.Object
org.eclipse.jface.text.hyperlink.HyperlinkManager
- All Implemented Interfaces:
EventListener
,ITextListener
,FocusListener
,KeyListener
,MouseListener
,MouseMoveListener
,MouseTrackListener
,SWTEventListener
,Listener
public class HyperlinkManager
extends Object
implements ITextListener, Listener, KeyListener, MouseListener, MouseMoveListener, FocusListener, MouseTrackListener
Default implementation of a hyperlink manager.
- Since:
- 3.1
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic final class
Detection strategy. -
Field Summary
Modifier and TypeFieldDescriptionstatic final HyperlinkManager.DETECTION_STRATEGY
All detected hyperlinks from all detectors are collected and passed to the hyperlink presenter.static final HyperlinkManager.DETECTION_STRATEGY
The first detected hyperlink is passed to the hyperlink presenter and no further detector is consulted.static final HyperlinkManager.DETECTION_STRATEGY
All detected hyperlinks from all detectors are collected and all those with the longest region are passed to the hyperlink presenter.static final HyperlinkManager.DETECTION_STRATEGY
All detected hyperlinks from all detectors are collected and form all those with the longest region only the first one is passed to the hyperlink presenter.static final int
Text operation code for requesting to open the hyperlink at the caret position. -
Constructor Summary
ConstructorDescriptionHyperlinkManager
(HyperlinkManager.DETECTION_STRATEGY detectionStrategy) Creates a new hyperlink manager. -
Method Summary
Modifier and TypeMethodDescriptionprotected int
computeLongestHyperlinkLength
(List<? extends IHyperlink> hyperlinks) Computes the length of the longest detected hyperlink.protected void
Deactivates the currently shown hyperlinks.protected IHyperlink[]
Finds hyperlinks at the current offset.void
Sent when a control gets focus.void
focusLost
(FocusEvent event) Sent when a control loses focus.protected int
Returns the offset in the given viewer that corresponds to the current cursor location.void
handleEvent
(Event event) Sent when an event that the receiver has registered for occurs.void
install
(ITextViewer textViewer, IHyperlinkPresenter hyperlinkPresenter, IHyperlinkDetector[] hyperlinkDetectors, int eventStateMask) Installs this hyperlink manager with the given arguments.void
keyPressed
(KeyEvent event) Sent when a key is pressed on the system keyboard.void
keyReleased
(KeyEvent event) Sent when a key is released on the system keyboard.void
Sent when a mouse button is pressed twice within the (operating system specified) double click period.void
mouseDown
(MouseEvent event) Sent when a mouse button is pressed.void
Sent when the mouse pointer passes into the area of the screen covered by a control.void
Sent when the mouse pointer passes out of the area of the screen covered by a control.void
Sent when the mouse pointer hovers (that is, stops moving for an (operating system specified) period of time) over a control.void
mouseMove
(MouseEvent event) Sent when the mouse moves.void
Sent when a mouse button is released.boolean
Opens the hyperlink at the caret location or opens a chooser if more than one hyperlink is available.void
setHyperlinkDetectors
(IHyperlinkDetector[] hyperlinkDetectors) Sets the hyperlink detectors for this hyperlink manager.void
setHyperlinkStateMask
(int eventStateMask) Sets the SWT event state mask which in combination with the left mouse button triggers the hyperlink mode.void
textChanged
(TextEvent event) The visual representation of a text viewer this listener is registered with has been changed.void
Uninstalls this hyperlink manager.
-
Field Details
-
OPEN_HYPERLINK
public static final int OPEN_HYPERLINKText operation code for requesting to open the hyperlink at the caret position.- Since:
- 3.6
- See Also:
-
FIRST
The first detected hyperlink is passed to the hyperlink presenter and no further detector is consulted. -
ALL
All detected hyperlinks from all detectors are collected and passed to the hyperlink presenter.This strategy is only allowed if
IHyperlinkPresenter.canShowMultipleHyperlinks()
returnstrue
. -
LONGEST_REGION_ALL
All detected hyperlinks from all detectors are collected and all those with the longest region are passed to the hyperlink presenter.This strategy is only allowed if
IHyperlinkPresenter.canShowMultipleHyperlinks()
returnstrue
. -
LONGEST_REGION_FIRST
All detected hyperlinks from all detectors are collected and form all those with the longest region only the first one is passed to the hyperlink presenter.
-
-
Constructor Details
-
HyperlinkManager
Creates a new hyperlink manager.- Parameters:
detectionStrategy
- the detection strategy one of {ALL
,FIRST
,LONGEST_REGION_ALL
,LONGEST_REGION_FIRST
}
-
-
Method Details
-
install
public void install(ITextViewer textViewer, IHyperlinkPresenter hyperlinkPresenter, IHyperlinkDetector[] hyperlinkDetectors, int eventStateMask) Installs this hyperlink manager with the given arguments.- Parameters:
textViewer
- the text viewerhyperlinkPresenter
- the hyperlink presenterhyperlinkDetectors
- the array of hyperlink detectors, must not be emptyeventStateMask
- the SWT event state mask to activate hyperlink mode
-
setHyperlinkDetectors
Sets the hyperlink detectors for this hyperlink manager.It is allowed to call this method after this hyperlink manger has been installed.
- Parameters:
hyperlinkDetectors
- and array of hyperlink detectors, must not be empty
-
setHyperlinkStateMask
public void setHyperlinkStateMask(int eventStateMask) Sets the SWT event state mask which in combination with the left mouse button triggers the hyperlink mode.It is allowed to call this method after this hyperlink manger has been installed.
Note that
IHyperlinkDetectorExtension2
s may specify additional state masks.- Parameters:
eventStateMask
- the SWT event state mask to activate hyperlink mode
-
uninstall
public void uninstall()Uninstalls this hyperlink manager. -
deactivate
protected void deactivate()Deactivates the currently shown hyperlinks. -
findHyperlinks
Finds hyperlinks at the current offset.- Returns:
- the hyperlinks or
null
if none.
-
computeLongestHyperlinkLength
Computes the length of the longest detected hyperlink.- Parameters:
hyperlinks
- the list of hyperlinks- Returns:
- the length of the longest detected
-
getCurrentTextOffset
protected int getCurrentTextOffset()Returns the offset in the given viewer that corresponds to the current cursor location.- Returns:
- the offset in the given viewer that corresponds to the current cursor location.
-
keyPressed
Description copied from interface:KeyListener
Sent when a key is pressed on the system keyboard.- Specified by:
keyPressed
in interfaceKeyListener
- Parameters:
event
- an event containing information about the key press
-
keyReleased
Description copied from interface:KeyListener
Sent when a key is released on the system keyboard.- Specified by:
keyReleased
in interfaceKeyListener
- Parameters:
event
- an event containing information about the key release
-
mouseDoubleClick
Description copied from interface:MouseListener
Sent when a mouse button is pressed twice within the (operating system specified) double click period.- Specified by:
mouseDoubleClick
in interfaceMouseListener
- Parameters:
e
- an event containing information about the mouse double click- See Also:
-
mouseDown
Description copied from interface:MouseListener
Sent when a mouse button is pressed.- Specified by:
mouseDown
in interfaceMouseListener
- Parameters:
event
- an event containing information about the mouse button press
-
mouseUp
Description copied from interface:MouseListener
Sent when a mouse button is released.- Specified by:
mouseUp
in interfaceMouseListener
- Parameters:
e
- an event containing information about the mouse button release
-
mouseMove
Description copied from interface:MouseMoveListener
Sent when the mouse moves.- Specified by:
mouseMove
in interfaceMouseMoveListener
- Parameters:
event
- an event containing information about the mouse move
-
focusGained
Description copied from interface:FocusListener
Sent when a control gets focus.- Specified by:
focusGained
in interfaceFocusListener
- Parameters:
e
- an event containing information about the focus change
-
focusLost
Description copied from interface:FocusListener
Sent when a control loses focus.- Specified by:
focusLost
in interfaceFocusListener
- Parameters:
event
- an event containing information about the focus change
-
handleEvent
Description copied from interface:Listener
Sent when an event that the receiver has registered for occurs.- Specified by:
handleEvent
in interfaceListener
- Parameters:
event
- the event which occurred
-
textChanged
Description copied from interface:ITextListener
The visual representation of a text viewer this listener is registered with has been changed.- Specified by:
textChanged
in interfaceITextListener
- Parameters:
event
- the description of the change
-
mouseExit
Sent when the mouse pointer passes out of the area of the screen covered by a control.- Specified by:
mouseExit
in interfaceMouseTrackListener
- Parameters:
e
- an event containing information about the mouse exit- Since:
- 3.4
-
mouseEnter
Sent when the mouse pointer passes into the area of the screen covered by a control.- Specified by:
mouseEnter
in interfaceMouseTrackListener
- Parameters:
e
- an event containing information about the mouse enter- Since:
- 3.4
-
mouseHover
Sent when the mouse pointer hovers (that is, stops moving for an (operating system specified) period of time) over a control.- Specified by:
mouseHover
in interfaceMouseTrackListener
- Parameters:
e
- an event containing information about the hover- Since:
- 3.4
-
openHyperlink
public boolean openHyperlink()Opens the hyperlink at the caret location or opens a chooser if more than one hyperlink is available.- Returns:
true
if at least one hyperlink has been found at the caret location,false
otherwise- Since:
- 3.6
- See Also:
-