Search in sources :

Example 1 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 2 with IInformationProvider

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

the class QuickTypeHierarchyHandler method openPresentation.

@Override
protected void openPresentation(final XtextEditor editor, final IJavaElement javaElement, final EObject selectedElement) {
    final ISourceViewer sourceViewer = editor.getInternalSourceViewer();
    ITextRegion significantTextRegion = locationInFileProvider.getSignificantTextRegion(selectedElement);
    InformationPresenter presenter = new HierarchyInformationPresenter(sourceViewer, javaElement, new Region(significantTextRegion.getOffset(), significantTextRegion.getLength()));
    presenter.setDocumentPartitioning(IDocumentExtension3.DEFAULT_PARTITIONING);
    presenter.setAnchor(AbstractInformationControlManager.ANCHOR_GLOBAL);
    IInformationProvider provider = new JavaElementProvider(editor, 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(sourceViewer);
    presenter.showInformation();
}
Also used : JavaElementProvider(org.eclipse.jdt.internal.ui.text.JavaElementProvider) ITextRegion(org.eclipse.xtext.util.ITextRegion) IInformationProvider(org.eclipse.jface.text.information.IInformationProvider) Region(org.eclipse.jface.text.Region) ITextRegion(org.eclipse.xtext.util.ITextRegion) ISourceViewer(org.eclipse.jface.text.source.ISourceViewer) InformationPresenter(org.eclipse.jface.text.information.InformationPresenter)

Example 3 with IInformationProvider

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

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());
    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)

Example 4 with IInformationProvider

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

the class MarkupSourceViewerConfiguration method getOutlineInformationPresenter.

/**
 * provide access to an information presenter that can be used to pop-up a quick outline. Source viewers should
 * configure as follows:
 *
 * <pre>
 * public void configure(SourceViewerConfiguration configuration) {
 * 	super.configure(configuration);
 * 	if (configuration instanceof MarkupSourceViewerConfiguration) {
 * 		outlinePresenter = ((MarkupSourceViewerConfiguration) configuration)
 * 				.getOutlineInformationPresenter(this);
 * 		outlinePresenter.install(this);
 * 	}
 * }
 * </pre>
 *
 * @param sourceViewer
 *            the source viewer for which the presenter should be created
 * @return the presenter
 */
public IInformationPresenter getOutlineInformationPresenter(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 5 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)

Aggregations

IInformationProvider (org.eclipse.jface.text.information.IInformationProvider)10 InformationPresenter (org.eclipse.jface.text.information.InformationPresenter)8 IInformationPresenter (org.eclipse.jface.text.information.IInformationPresenter)6 IInformationControlCreator (org.eclipse.jface.text.IInformationControlCreator)4 JavaElementProvider (org.eclipse.jdt.internal.ui.text.JavaElementProvider)2 Region (org.eclipse.jface.text.Region)2 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 DisposeListener (org.eclipse.swt.events.DisposeListener)1 Point (org.eclipse.swt.graphics.Point)1