org.eclipse.xtext.ui.editor.hover
Class AbstractCompositeHover

java.lang.Object
  extended by org.eclipse.xtext.ui.editor.hover.AbstractCompositeHover
All Implemented Interfaces:
org.eclipse.jface.text.ITextHover, org.eclipse.jface.text.ITextHoverExtension, org.eclipse.jface.text.ITextHoverExtension2, ISourceViewerAware
Direct Known Subclasses:
DefaultCompositeHover

public abstract class AbstractCompositeHover
extends java.lang.Object
implements org.eclipse.jface.text.ITextHover, org.eclipse.jface.text.ITextHoverExtension, org.eclipse.jface.text.ITextHoverExtension2, ISourceViewerAware

The CompositeHover is a hover which delegates calls to a list of hovers. It iterates through this list of hovers and chooses the first one which provides a region in getHoverRegion(). Override the method createHovers() to configure the list of hovers.

Author:
Christoph Kulla - Initial contribution and API

Constructor Summary
AbstractCompositeHover()
           
 
Method Summary
protected abstract  java.util.List<org.eclipse.jface.text.ITextHover> createHovers()
           
 org.eclipse.jface.text.IInformationControlCreator getHoverControlCreator()
          Returns the hover control creator of this text hover or null
 java.lang.String getHoverInfo(org.eclipse.jface.text.ITextViewer textViewer, org.eclipse.jface.text.IRegion hoverRegion)
          Deprecated. 
 java.lang.Object getHoverInfo2(org.eclipse.jface.text.ITextViewer textViewer, org.eclipse.jface.text.IRegion hoverRegion)
          Returns the information which should be presented when a hover popup is shown for the specified hover region.
 org.eclipse.jface.text.IRegion getHoverRegion(org.eclipse.jface.text.ITextViewer textViewer, int offset)
          Returns the text region which should serve as the source of information to compute the hover popup display information.
 java.util.List<org.eclipse.jface.text.ITextHover> getHovers()
           
 void setSourceViewer(org.eclipse.jface.text.source.ISourceViewer sourceViewer)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractCompositeHover

public AbstractCompositeHover()
Method Detail

getHovers

public java.util.List<org.eclipse.jface.text.ITextHover> getHovers()

createHovers

protected abstract java.util.List<org.eclipse.jface.text.ITextHover> createHovers()

setSourceViewer

public void setSourceViewer(org.eclipse.jface.text.source.ISourceViewer sourceViewer)
Specified by:
setSourceViewer in interface ISourceViewerAware

getHoverRegion

public org.eclipse.jface.text.IRegion getHoverRegion(org.eclipse.jface.text.ITextViewer textViewer,
                                                     int offset)
Description copied from interface: org.eclipse.jface.text.ITextHover
Returns the text region which should serve as the source of information to compute the hover popup display information. The popup has been requested for the given offset.

For example, if hover information can be provided on a per method basis in a source viewer, the offset should be used to find the enclosing method and the source range of the method should be returned.

Specified by:
getHoverRegion in interface org.eclipse.jface.text.ITextHover
Parameters:
textViewer - the viewer on which the hover popup should be shown
offset - the offset for which the hover request has been issued
Returns:
the hover region used to compute the hover display information

getHoverInfo

@Deprecated
public java.lang.String getHoverInfo(org.eclipse.jface.text.ITextViewer textViewer,
                                                org.eclipse.jface.text.IRegion hoverRegion)
Deprecated. 

Description copied from interface: org.eclipse.jface.text.ITextHover
Returns the information which should be presented when a hover popup is shown for the specified hover region. The hover region has the same semantics as the region returned by getHoverRegion. If the returned information is null or empty no hover popup will be shown.

Specified by:
getHoverInfo in interface org.eclipse.jface.text.ITextHover
Parameters:
textViewer - the viewer on which the hover popup should be shown
hoverRegion - the text range in the viewer which is used to determine the hover display information
Returns:
the hover popup display information, or null if none available

getHoverInfo2

public java.lang.Object getHoverInfo2(org.eclipse.jface.text.ITextViewer textViewer,
                                      org.eclipse.jface.text.IRegion hoverRegion)
Description copied from interface: org.eclipse.jface.text.ITextHoverExtension2
Returns the information which should be presented when a hover popup is shown for the specified hover region. The hover region has the same semantics as the region returned by ITextHover.getHoverRegion(ITextViewer, int). If the returned information is null, no hover popup will be shown.

Note: Implementers have to ensure that ITextHoverExtension.getHoverControlCreator() returns IInformationControls that implement IInformationControlExtension2 and whose IInformationControlExtension2.setInput(Object) can handle the information objects returned by this method.

Callers should ignore the text returned by ITextHover.getHoverInfo(ITextViewer, IRegion).

Specified by:
getHoverInfo2 in interface org.eclipse.jface.text.ITextHoverExtension2
Parameters:
textViewer - the viewer on which the hover popup should be shown
hoverRegion - the text range in the viewer which is used to determine the hover display information
Returns:
the hover popup display information, or null if none available

getHoverControlCreator

public org.eclipse.jface.text.IInformationControlCreator getHoverControlCreator()
Description copied from interface: org.eclipse.jface.text.ITextHoverExtension
Returns the hover control creator of this text hover or null

Specified by:
getHoverControlCreator in interface org.eclipse.jface.text.ITextHoverExtension
Returns:
the hover control creator or null