LPEX
4.4.0

com.ibm.lpex.alef
Class LpexHyperlinkManager

java.lang.Object
  extended by com.ibm.lpex.alef.LpexHyperlinkManager

public class LpexHyperlinkManager
extends Object

Default implementation of a hyperlink manager for an LPEX text viewer.

This class uses Eclipse's HyperlinkManager.DETECTION_STRATEGY definitions.


Constructor Summary
LpexHyperlinkManager(HyperlinkManager.DETECTION_STRATEGY detectionStrategy)
          Creates a new LPEX hyperlink manager.
 
Method Summary
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)
           
 void focusLost(FocusEvent e)
           
protected  int getCurrentTextOffset()
          Returns the current text offset at the mouse-pointer location.
 void handleEvent(Event event)
           
 void install(LpexTextViewer textViewer, IHyperlinkPresenter hyperlinkPresenter, IHyperlinkDetector[] hyperlinkDetectors, int eventStateMask)
          Installs this hyperlink manager with the given arguments in the text viewer.
 void keyPressed(KeyEvent event)
           
 void keyReleased(KeyEvent event)
           
 void mouseDoubleClick(MouseEvent e)
           
 void mouseDown(MouseEvent event)
           
 void mouseMove(MouseEvent event)
           
 void mouseUp(MouseEvent e)
           
 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 mouse button 1 triggers the hyperlink mode.
 void textChanged(TextEvent event)
           
 void uninstall()
          Uninstalls this hyperlink manager from the text viewer.
 void widgetDisposed(DisposeEvent e)
          An LpexWindow of the associated viewer is being disposed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LpexHyperlinkManager

public LpexHyperlinkManager(HyperlinkManager.DETECTION_STRATEGY detectionStrategy)
Creates a new LPEX hyperlink manager.

Parameters:
detectionStrategy - the detection strategy one of HyperlinkManager.ALL, HyperlinkManager.FIRST, HyperlinkManager.LONGEST_REGION_ALL, HyperlinkManager.LONGEST_REGION_FIRST
Method Detail

install

public void install(LpexTextViewer textViewer,
                    IHyperlinkPresenter hyperlinkPresenter,
                    IHyperlinkDetector[] hyperlinkDetectors,
                    int eventStateMask)
Installs this hyperlink manager with the given arguments in the text viewer.

Parameters:
textViewer - an LpexTextViewer
hyperlinkPresenter - the hyperlink presenter
hyperlinkDetectors - the array of hyperlink detectors, must not be empty
eventStateMask - the SWT event state mask to activate hyperlink mode

setHyperlinkDetectors

public void setHyperlinkDetectors(IHyperlinkDetector[] hyperlinkDetectors)
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 mouse button 1 triggers the hyperlink mode. It is allowed to call this method after this hyperlink manager has been installed.

Parameters:
eventStateMask - the SWT event state mask to activate hyperlink mode

uninstall

public void uninstall()
Uninstalls this hyperlink manager from the text viewer.


deactivate

protected void deactivate()
Deactivates the currently shown hyperlinks.


findHyperlinks

protected IHyperlink[] findHyperlinks()
Finds hyperlinks at the current offset.

Returns:
the hyperlinks or null if none.

computeLongestHyperlinkLength

protected int computeLongestHyperlinkLength(List<?> hyperlinks)
Computes the length of the longest detected hyperlink.

Parameters:
hyperlinks -
Returns:
the length of the longest detected

getCurrentTextOffset

protected int getCurrentTextOffset()
Returns the current text offset at the mouse-pointer location. Also records the LpexWindow at that location.

Returns:
the current text offset

keyPressed

public void keyPressed(KeyEvent event)

keyReleased

public void keyReleased(KeyEvent event)

mouseDoubleClick

public void mouseDoubleClick(MouseEvent e)

mouseDown

public void mouseDown(MouseEvent event)

mouseUp

public void mouseUp(MouseEvent e)

mouseMove

public void mouseMove(MouseEvent event)

focusGained

public void focusGained(FocusEvent e)

focusLost

public void focusLost(FocusEvent e)

handleEvent

public void handleEvent(Event event)

textChanged

public void textChanged(TextEvent event)

widgetDisposed

public void widgetDisposed(DisposeEvent e)
An LpexWindow of the associated viewer is being disposed.


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:
4.2
See Also:
#OPEN_HYPERLINK

LPEX
4.4.0

Copyright � 2016 IBM Corp. All Rights Reserved.

Note: This documentation is for part of an interim API that is still under development and expected to change significantly before reaching stability. It is being made available at this early stage to solicit feedback from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken (repeatedly) as the API evolves.