Search in sources :

Example 6 with IInformationProvider

use of org.eclipse.jface.text.information.IInformationProvider in project mylyn.docs by eclipse.

the class InformationPresenterUtil method getHtmlInformationPresenter.

/**
 * Get an information presenter to present the provided HTML content. The returned presenter is ready for displaying
 * the information, all that is left to do is call {@link InformationPresenter#showInformation()}.
 *
 * @param viewer
 *            the viewer for which the information control should be created
 * @param constraint
 *            the size constraint
 * @param toolBarManager
 *            the tool bar manager, or null if there should be none
 * @param htmlContent
 *            the HTML content to be displayed by the information presenter.
 * @return the presenter
 */
public static InformationPresenter getHtmlInformationPresenter(ISourceViewer viewer, SizeConstraint constraint, final ToolBarManager toolBarManager, String htmlContent) {
    Control control = viewer.getTextWidget();
    InformationPresenter presenter = (InformationPresenter) control.getData(DATA_INFORMATION_PRESENTER);
    // bug 270059: ensure that the size/positioning math works by specifying the offet of the
    // current selection.
    int offset = viewer.getSelectedRange().x;
    IInformationControlCreator informationControlCreator;
    if (presenter == null) {
        informationControlCreator = new IInformationControlCreator() {

            @SuppressWarnings("deprecation")
            public IInformationControl createInformationControl(Shell shell) {
                try {
                    // DefaultInformationControl(Shell parent, ToolBarManager toolBarManager, IInformationPresenter presenter);
                    return DefaultInformationControl.class.getConstructor(Shell.class, ToolBarManager.class, IInformationPresenter.class).newInstance(shell, toolBarManager, new HtmlTextPresenter());
                } catch (NoSuchMethodException e) {
                    // no way with 3.3 to get V_SCROLL and a ToolBarManager
                    return new DefaultInformationControl(shell, SWT.RESIZE, SWT.V_SCROLL | SWT.H_SCROLL, new HtmlTextPresenter());
                } catch (Exception e) {
                    throw new IllegalStateException(e);
                }
            }
        };
        presenter = new InformationPresenter(informationControlCreator) {

            @Override
            public IInformationProvider getInformationProvider(String contentType) {
                IInformationProvider informationProvider = super.getInformationProvider(contentType);
                if (informationProvider == null) {
                    informationProvider = super.getInformationProvider(IDocument.DEFAULT_CONTENT_TYPE);
                }
                return informationProvider;
            }
        };
        presenter.install(viewer);
        presenter.setAnchor(AbstractInformationControlManager.ANCHOR_BOTTOM);
        // default values from AbstractInformationControlManager
        presenter.setMargins(6, 6);
        presenter.setOffset(offset);
        presenter.install(viewer);
        final InformationPresenter informationPresenter = presenter;
        viewer.getTextWidget().addDisposeListener(new DisposeListener() {

            public void widgetDisposed(DisposeEvent e) {
                try {
                    informationPresenter.uninstall();
                } catch (Exception e2) {
                }
                informationPresenter.dispose();
            }
        });
        control.setData(DATA_INFORMATION_PRESENTER, presenter);
        control.setData(DATA_INFORMATION_CONTROL_CREATOR, informationControlCreator);
    } else {
        informationControlCreator = (IInformationControlCreator) control.getData(DATA_INFORMATION_CONTROL_CREATOR);
        presenter.disposeInformationControl();
    }
    presenter.setSizeConstraints(constraint.horizontalWidthInChars, constraint.verticalWidthInChars, constraint.enforceAsMinimumSize, constraint.enforceAsMaximumSize);
    InformationProvider informationProvider = new InformationProvider(new org.eclipse.jface.text.Region(offset, 0), htmlContent, informationControlCreator);
    for (String contentType : FastMarkupPartitioner.ALL_CONTENT_TYPES) {
        presenter.setInformationProvider(informationProvider, contentType);
    }
    presenter.setInformationProvider(informationProvider, IDocument.DEFAULT_CONTENT_TYPE);
    return presenter;
}
Also used : DisposeListener(org.eclipse.swt.events.DisposeListener) DefaultInformationControl(org.eclipse.jface.text.DefaultInformationControl) DisposeEvent(org.eclipse.swt.events.DisposeEvent) IInformationControlCreator(org.eclipse.jface.text.IInformationControlCreator) IInformationControl(org.eclipse.jface.text.IInformationControl) DefaultInformationControl(org.eclipse.jface.text.DefaultInformationControl) Control(org.eclipse.swt.widgets.Control) Shell(org.eclipse.swt.widgets.Shell) IInformationControl(org.eclipse.jface.text.IInformationControl) IInformationProvider(org.eclipse.jface.text.information.IInformationProvider) HtmlTextPresenter(org.eclipse.mylyn.wikitext.ui.viewer.HtmlTextPresenter) IInformationProvider(org.eclipse.jface.text.information.IInformationProvider) InformationPresenter(org.eclipse.jface.text.information.InformationPresenter) IInformationPresenter(org.eclipse.jface.text.DefaultInformationControl.IInformationPresenter)

Example 7 with IInformationProvider

use of org.eclipse.jface.text.information.IInformationProvider in project KaiZen-OpenAPI-Editor by RepreZen.

the class JsonSourceViewerConfiguration method getOutlinePresenter.

public IInformationPresenter getOutlinePresenter(ISourceViewer sourceViewer) {
    if (informationPresenter == null) {
        IInformationControlCreator controlCreator = getOutlineInformationControlCreator();
        informationPresenter = new InformationPresenter(controlCreator);
        informationPresenter.setDocumentPartitioning(getConfiguredDocumentPartitioning(sourceViewer));
        // Register information provider
        IInformationProvider provider = new InformationProvider(controlCreator);
        String[] contentTypes = getConfiguredContentTypes(sourceViewer);
        for (String contentType : contentTypes) {
            informationPresenter.setInformationProvider(provider, contentType);
        }
        informationPresenter.setSizeConstraints(60, 20, true, true);
    }
    return informationPresenter;
}
Also used : IInformationControlCreator(org.eclipse.jface.text.IInformationControlCreator) IInformationProvider(org.eclipse.jface.text.information.IInformationProvider) IInformationProvider(org.eclipse.jface.text.information.IInformationProvider) IInformationPresenter(org.eclipse.jface.text.information.IInformationPresenter) InformationPresenter(org.eclipse.jface.text.information.InformationPresenter)

Example 8 with IInformationProvider

use of org.eclipse.jface.text.information.IInformationProvider in project eclipse.platform by eclipse-platform.

the class AntEditorSourceViewerConfiguration method getInformationPresenter.

@Override
public IInformationPresenter getInformationPresenter(ISourceViewer sourceViewer) {
    InformationPresenter presenter = new InformationPresenter(getInformationPresenterControlCreator());
    presenter.setDocumentPartitioning(getConfiguredDocumentPartitioning(sourceViewer));
    IInformationProvider provider = new AntInformationProvider(new XMLTextHover(fEditor));
    presenter.setInformationProvider(provider, IDocument.DEFAULT_CONTENT_TYPE);
    presenter.setInformationProvider(provider, AntEditorPartitionScanner.XML_CDATA);
    presenter.setInformationProvider(provider, AntEditorPartitionScanner.XML_COMMENT);
    presenter.setInformationProvider(provider, AntEditorPartitionScanner.XML_DTD);
    presenter.setInformationProvider(provider, AntEditorPartitionScanner.XML_TAG);
    presenter.setSizeConstraints(60, 10, true, true);
    return presenter;
}
Also used : XMLTextHover(org.eclipse.ant.internal.ui.editor.text.XMLTextHover) IInformationProvider(org.eclipse.jface.text.information.IInformationProvider) IInformationPresenter(org.eclipse.jface.text.information.IInformationPresenter) InformationPresenter(org.eclipse.jface.text.information.InformationPresenter) AntInformationProvider(org.eclipse.ant.internal.ui.editor.text.AntInformationProvider)

Example 9 with IInformationProvider

use of org.eclipse.jface.text.information.IInformationProvider in project xtext-eclipse by eclipse.

the class JvmImplementationOpener method openQuickHierarchy.

protected void openQuickHierarchy(ITextViewer textViewer, IJavaElement element, IRegion region) {
    HierarchyInformationPresenter presenter = new HierarchyInformationPresenter((ISourceViewer) textViewer, element, region);
    presenter.setDocumentPartitioning(IDocumentExtension3.DEFAULT_PARTITIONING);
    presenter.setAnchor(AbstractInformationControlManager.ANCHOR_GLOBAL);
    IInformationProvider provider = new JavaElementProvider(null, false);
    presenter.setInformationProvider(provider, IDocument.DEFAULT_CONTENT_TYPE);
    presenter.setInformationProvider(provider, IJavaPartitions.JAVA_DOC);
    presenter.setInformationProvider(provider, IJavaPartitions.JAVA_MULTI_LINE_COMMENT);
    presenter.setInformationProvider(provider, IJavaPartitions.JAVA_SINGLE_LINE_COMMENT);
    presenter.setInformationProvider(provider, IJavaPartitions.JAVA_STRING);
    presenter.setInformationProvider(provider, IJavaPartitions.JAVA_CHARACTER);
    presenter.setSizeConstraints(50, 20, true, false);
    presenter.install(textViewer);
    presenter.showInformation();
}
Also used : JavaElementProvider(org.eclipse.jdt.internal.ui.text.JavaElementProvider) HierarchyInformationPresenter(org.eclipse.xtext.xbase.ui.hierarchy.HierarchyInformationPresenter) IInformationProvider(org.eclipse.jface.text.information.IInformationProvider)

Example 10 with IInformationProvider

use of org.eclipse.jface.text.information.IInformationProvider in project dbeaver by serge-rider.

the class SQLEditorSourceViewerConfiguration method getInformationPresenter.

@Override
public IInformationPresenter getInformationPresenter(ISourceViewer sourceViewer) {
    InformationPresenter presenter = new InformationPresenter(getInformationControlCreator(sourceViewer));
    presenter.setDocumentPartitioning(getConfiguredDocumentPartitioning(sourceViewer));
    // Register information provider
    IInformationProvider provider = new SQLInformationProvider(getSQLEditor(), contextInformer);
    String[] contentTypes = getConfiguredContentTypes(sourceViewer);
    for (String contentType : contentTypes) {
        presenter.setInformationProvider(provider, contentType);
    }
    presenter.setSizeConstraints(60, 10, true, true);
    return presenter;
}
Also used : IInformationProvider(org.eclipse.jface.text.information.IInformationProvider) IInformationPresenter(org.eclipse.jface.text.information.IInformationPresenter) InformationPresenter(org.eclipse.jface.text.information.InformationPresenter)

Aggregations

IInformationProvider (org.eclipse.jface.text.information.IInformationProvider)11 InformationPresenter (org.eclipse.jface.text.information.InformationPresenter)9 IInformationPresenter (org.eclipse.jface.text.information.IInformationPresenter)7 IInformationControlCreator (org.eclipse.jface.text.IInformationControlCreator)4 JavaElementProvider (org.eclipse.jdt.internal.ui.text.JavaElementProvider)2 Region (org.eclipse.jface.text.Region)2 AntInformationProvider (org.eclipse.ant.internal.ui.editor.text.AntInformationProvider)1 XMLTextHover (org.eclipse.ant.internal.ui.editor.text.XMLTextHover)1 BadLocationException (org.eclipse.jface.text.BadLocationException)1 DefaultInformationControl (org.eclipse.jface.text.DefaultInformationControl)1 IInformationPresenter (org.eclipse.jface.text.DefaultInformationControl.IInformationPresenter)1 IDocument (org.eclipse.jface.text.IDocument)1 IInformationControl (org.eclipse.jface.text.IInformationControl)1 IRegion (org.eclipse.jface.text.IRegion)1 IInformationProviderExtension2 (org.eclipse.jface.text.information.IInformationProviderExtension2)1 IAnnotationHoverExtension (org.eclipse.jface.text.source.IAnnotationHoverExtension)1 ILineRange (org.eclipse.jface.text.source.ILineRange)1 ISourceViewer (org.eclipse.jface.text.source.ISourceViewer)1 HtmlTextPresenter (org.eclipse.mylyn.wikitext.ui.viewer.HtmlTextPresenter)1 DisposeEvent (org.eclipse.swt.events.DisposeEvent)1