use of org.eclipse.jface.text.ITextHover in project webtools.sourceediting by eclipse.
the class BestMatchHover method getHoverInfo.
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.text.ITextHover#getHoverInfo(org.eclipse.jface.text.ITextViewer,
* org.eclipse.jface.text.IRegion)
*/
public String getHoverInfo(ITextViewer viewer, IRegion hoverRegion) {
String displayText = null;
controlCreatorProvider = null;
// already have a best match hover picked out from getHoverRegion call
if (fBestMatchHover != null) {
displayText = fBestMatchHover.getHoverInfo(viewer, hoverRegion);
}
// either had no best match hover or best match hover returned null
if (displayText == null) {
// go through list of text hovers and return first display string
Iterator i = getTextHovers().iterator();
while ((i.hasNext()) && (displayText == null)) {
ITextHover hover = (ITextHover) i.next();
displayText = hover.getHoverInfo(viewer, hoverRegion);
if (displayText != null) {
controlCreatorProvider = hover;
}
}
} else {
controlCreatorProvider = fBestMatchHover;
}
return displayText;
}
use of org.eclipse.jface.text.ITextHover in project webtools.sourceediting by eclipse.
the class BestMatchHover method getHoverInfo2.
public Object getHoverInfo2(ITextViewer textViewer, IRegion hoverRegion) {
Object information = null;
controlCreatorProvider = null;
// already have a best match hover picked out from getHoverRegion call
if (fBestMatchHover instanceof ITextHoverExtension2) {
information = ((ITextHoverExtension2) fBestMatchHover).getHoverInfo2(textViewer, hoverRegion);
} else if (fBestMatchHover != null) {
information = fBestMatchHover.getHoverInfo(textViewer, hoverRegion);
}
// either had no best match hover or best match hover returned null
if (information == null) {
// go through list of text hovers and return first display string
Iterator i = getTextHovers().iterator();
while ((i.hasNext()) && (information == null)) {
ITextHover hover = (ITextHover) i.next();
if (hover == fBestMatchHover)
continue;
if (hover instanceof ITextHoverExtension2) {
information = ((ITextHoverExtension2) hover).getHoverInfo2(textViewer, hoverRegion);
} else {
information = hover.getHoverInfo(textViewer, hoverRegion);
}
if (information != null) {
controlCreatorProvider = hover;
}
}
} else {
controlCreatorProvider = fBestMatchHover;
}
return information;
}
use of org.eclipse.jface.text.ITextHover in project webtools.sourceediting by eclipse.
the class StructuredTextViewerConfiguration method createDocumentationHovers.
/**
* Create documentation hovers based on hovers contributed via
* <code>org.eclipse.wst.sse.ui.editorConfiguration</code> extension
* point
*
* @param partitionType
* @return
*/
private ITextHover[] createDocumentationHovers(String partitionType) {
List extendedTextHover = ExtendedConfigurationBuilder.getInstance().getConfigurations(ExtendedConfigurationBuilder.DOCUMENTATIONTEXTHOVER, partitionType);
ITextHover[] hovers = (ITextHover[]) extendedTextHover.toArray(new ITextHover[extendedTextHover.size()]);
return hovers;
}
use of org.eclipse.jface.text.ITextHover in project liferay-ide by liferay.
the class PortletJSPSourceViewerConfiguration method createDocumentationHovers.
@SuppressWarnings({ "rawtypes", "unchecked" })
protected ITextHover[] createDocumentationHovers(String partitionType) {
ExtendedConfigurationBuilder instance = ExtendedConfigurationBuilder.getInstance();
List extendedTextHover = instance.getConfigurations(ExtendedConfigurationBuilder.DOCUMENTATIONTEXTHOVER, partitionType);
return (ITextHover[]) extendedTextHover.toArray(new ITextHover[extendedTextHover.size()]);
}
use of org.eclipse.jface.text.ITextHover in project liferay-ide by liferay.
the class PortletJSPSourceViewerConfiguration method getTextHover.
@Override
public ITextHover getTextHover(ISourceViewer sourceViewer, String contentType, int stateMask) {
ITextHover textHover = null;
TextHoverManager textHoverManager = SSEUIPlugin.getDefault().getTextHoverManager();
TextHoverManager.TextHoverDescriptor[] hoverDescs = textHoverManager.getTextHovers();
int i = 0;
while ((i < hoverDescs.length) && (textHover == null)) {
if (hoverDescs[i].isEnabled() && (computeStateMask(hoverDescs[i].getModifierString()) == stateMask)) {
String hoverType = hoverDescs[i].getId();
if (TextHoverManager.PROBLEM_HOVER.equalsIgnoreCase(hoverType)) {
textHover = new ProblemAnnotationHoverProcessor();
} else if (TextHoverManager.ANNOTATION_HOVER.equalsIgnoreCase(hoverType)) {
textHover = new AnnotationHoverProcessor();
} else if (TextHoverManager.COMBINATION_HOVER.equalsIgnoreCase(hoverType)) {
textHover = (ITextHover) new LiferayCustomXmlHover();
} else if (TextHoverManager.DOCUMENTATION_HOVER.equalsIgnoreCase(hoverType)) {
ITextHover[] hovers = createDocumentationHovers(contentType);
if (ListUtil.isNotEmpty(hovers)) {
textHover = hovers[0];
}
}
}
i++;
}
return textHover;
}
Aggregations