Search in sources :

Example 16 with ITextHover

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;
}
Also used : ITextHover(org.eclipse.jface.text.ITextHover) Iterator(java.util.Iterator)

Example 17 with ITextHover

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;
}
Also used : ITextHover(org.eclipse.jface.text.ITextHover) Iterator(java.util.Iterator) ITextHoverExtension2(org.eclipse.jface.text.ITextHoverExtension2)

Example 18 with ITextHover

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;
}
Also used : ITextHover(org.eclipse.jface.text.ITextHover) List(java.util.List) ArrayList(java.util.ArrayList)

Example 19 with ITextHover

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()]);
}
Also used : ITextHover(org.eclipse.jface.text.ITextHover) List(java.util.List) ExtendedConfigurationBuilder(org.eclipse.wst.sse.ui.internal.ExtendedConfigurationBuilder)

Example 20 with ITextHover

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;
}
Also used : LiferayCustomXmlHover(com.liferay.ide.xml.search.ui.editor.LiferayCustomXmlHover) ITextHover(org.eclipse.jface.text.ITextHover) AnnotationHoverProcessor(org.eclipse.wst.sse.ui.internal.taginfo.AnnotationHoverProcessor) ProblemAnnotationHoverProcessor(org.eclipse.wst.sse.ui.internal.taginfo.ProblemAnnotationHoverProcessor) TextHoverManager(org.eclipse.wst.sse.ui.internal.taginfo.TextHoverManager) ProblemAnnotationHoverProcessor(org.eclipse.wst.sse.ui.internal.taginfo.ProblemAnnotationHoverProcessor)

Aggregations

ITextHover (org.eclipse.jface.text.ITextHover)23 IRegion (org.eclipse.jface.text.IRegion)8 Region (org.eclipse.jface.text.Region)5 AbstractCompositeHover (org.eclipse.xtext.ui.editor.hover.AbstractCompositeHover)4 AbstractEditorTest (org.eclipse.xtext.ui.testing.AbstractEditorTest)4 Test (org.junit.Test)4 ArrayList (java.util.ArrayList)3 Iterator (java.util.Iterator)3 List (java.util.List)3 AnnotationHoverProcessor (org.eclipse.wst.sse.ui.internal.taginfo.AnnotationHoverProcessor)3 ProblemAnnotationHoverProcessor (org.eclipse.wst.sse.ui.internal.taginfo.ProblemAnnotationHoverProcessor)3 ITextHoverExtension2 (org.eclipse.jface.text.ITextHoverExtension2)2 ITextViewer (org.eclipse.jface.text.ITextViewer)2 Point (org.eclipse.swt.graphics.Point)2 CompoundRegion (com.liferay.ide.xml.search.ui.editor.CompoundRegion)1 InfoRegion (com.liferay.ide.xml.search.ui.editor.InfoRegion)1 LiferayCustomXmlHover (com.liferay.ide.xml.search.ui.editor.LiferayCustomXmlHover)1 MarkerRegion (com.liferay.ide.xml.search.ui.editor.MarkerRegion)1 TemporaryRegion (com.liferay.ide.xml.search.ui.editor.TemporaryRegion)1 Method (java.lang.reflect.Method)1