public class HyperlinkManager extends Object implements ITextListener, Listener, KeyListener, MouseListener, MouseMoveListener, FocusListener, MouseTrackListener
| Modifier and Type | Class and Description |
|---|---|
static class |
HyperlinkManager.DETECTION_STRATEGY
Detection strategy.
|
| Modifier and Type | Field and Description |
|---|---|
static HyperlinkManager.DETECTION_STRATEGY |
ALL
All detected hyperlinks from all detectors are collected
and passed to the hyperlink presenter.
|
static HyperlinkManager.DETECTION_STRATEGY |
FIRST
The first detected hyperlink is passed to the
hyperlink presenter and no further detector
is consulted.
|
static HyperlinkManager.DETECTION_STRATEGY |
LONGEST_REGION_ALL
All detected hyperlinks from all detectors are collected
and all those with the longest region are passed to the
hyperlink presenter.
|
static HyperlinkManager.DETECTION_STRATEGY |
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.
|
static int |
OPEN_HYPERLINK
Text operation code for requesting to open the hyperlink at the caret position.
|
| Constructor and Description |
|---|
HyperlinkManager(HyperlinkManager.DETECTION_STRATEGY detectionStrategy)
Creates a new hyperlink manager.
|
| Modifier and Type | Method and Description |
|---|---|
protected int |
computeLongestHyperlinkLength(List hyperlinks)
Computes the length of the longest detected hyperlink.
|
protected void |
deactivate()
Deactivates the currently shown hyperlinks.
|
protected IHyperlink[] |
findHyperlinks()
Finds hyperlinks at the current offset.
|
void |
focusGained(FocusEvent e)
Sent when a control gets focus.
|
void |
focusLost(FocusEvent event)
Sent when a control loses focus.
|
protected int |
getCurrentTextOffset()
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 |
mouseDoubleClick(MouseEvent e)
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 |
mouseEnter(MouseEvent e)
Sent when the mouse pointer passes into the area of
the screen covered by a control.
|
void |
mouseExit(MouseEvent e)
Sent when the mouse pointer passes out of the area of
the screen covered by a control.
|
void |
mouseHover(MouseEvent e)
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 |
mouseUp(MouseEvent e)
Sent when a mouse button is released.
|
boolean |
openHyperlink()
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 |
uninstall()
Uninstalls this hyperlink manager.
|
public static final int OPEN_HYPERLINK
openHyperlink(),
Constant Field Valuespublic static final HyperlinkManager.DETECTION_STRATEGY FIRST
public static final HyperlinkManager.DETECTION_STRATEGY ALL
This strategy is only allowed if IHyperlinkPresenter.canShowMultipleHyperlinks()
returns true.
public static final HyperlinkManager.DETECTION_STRATEGY LONGEST_REGION_ALL
This strategy is only allowed if IHyperlinkPresenter.canShowMultipleHyperlinks()
returns true.
public static final HyperlinkManager.DETECTION_STRATEGY LONGEST_REGION_FIRST
public HyperlinkManager(HyperlinkManager.DETECTION_STRATEGY detectionStrategy)
detectionStrategy - the detection strategy one of {ALL, FIRST, LONGEST_REGION_ALL, LONGEST_REGION_FIRST}public void install(ITextViewer textViewer, IHyperlinkPresenter hyperlinkPresenter, IHyperlinkDetector[] hyperlinkDetectors, int eventStateMask)
textViewer - the text viewerhyperlinkPresenter - the hyperlink presenterhyperlinkDetectors - the array of hyperlink detectors, must not be emptyeventStateMask - the SWT event state mask to activate hyperlink modepublic void setHyperlinkDetectors(IHyperlinkDetector[] hyperlinkDetectors)
It is allowed to call this method after this hyperlink manger has been installed.
hyperlinkDetectors - and array of hyperlink detectors, must not be emptypublic void setHyperlinkStateMask(int eventStateMask)
It is allowed to call this method after this hyperlink manger has been installed.
Note that IHyperlinkDetectorExtension2s may specify additional state masks.
eventStateMask - the SWT event state mask to activate hyperlink modepublic void uninstall()
protected void deactivate()
protected IHyperlink[] findHyperlinks()
null if none.protected int computeLongestHyperlinkLength(List hyperlinks)
hyperlinks - the list of hyperlinksprotected int getCurrentTextOffset()
public void keyPressed(KeyEvent event)
KeyListenerkeyPressed in interface KeyListenerevent - an event containing information about the key presspublic void keyReleased(KeyEvent event)
KeyListenerkeyReleased in interface KeyListenerevent - an event containing information about the key releasepublic void mouseDoubleClick(MouseEvent e)
MouseListenermouseDoubleClick in interface MouseListenere - an event containing information about the mouse double clickDisplay.getDoubleClickTime()public void mouseDown(MouseEvent event)
MouseListenermouseDown in interface MouseListenerevent - an event containing information about the mouse button presspublic void mouseUp(MouseEvent e)
MouseListenermouseUp in interface MouseListenere - an event containing information about the mouse button releasepublic void mouseMove(MouseEvent event)
MouseMoveListenermouseMove in interface MouseMoveListenerevent - an event containing information about the mouse movepublic void focusGained(FocusEvent e)
FocusListenerfocusGained in interface FocusListenere - an event containing information about the focus changepublic void focusLost(FocusEvent event)
FocusListenerfocusLost in interface FocusListenerevent - an event containing information about the focus changepublic void handleEvent(Event event)
ListenerhandleEvent in interface Listenerevent - the event which occurredpublic void textChanged(TextEvent event)
ITextListenertextChanged in interface ITextListenerevent - the description of the changepublic void mouseExit(MouseEvent e)
mouseExit in interface MouseTrackListenere - an event containing information about the mouse exitpublic void mouseEnter(MouseEvent e)
mouseEnter in interface MouseTrackListenere - an event containing information about the mouse enterpublic void mouseHover(MouseEvent e)
mouseHover in interface MouseTrackListenere - an event containing information about the hoverpublic boolean openHyperlink()
true if at least one hyperlink has been found at the caret location, false otherwiseOPEN_HYPERLINK
Copyright (c) 2000, 2014 Eclipse Contributors and others. All rights reserved.Guidelines for using Eclipse APIs.