Search in sources :

Example 6 with IInformationControlCreator

use of org.eclipse.jface.text.IInformationControlCreator 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 IInformationControlCreator

use of org.eclipse.jface.text.IInformationControlCreator in project eclipse-cs by checkstyle.

the class ConfigPropertyWidgetFile method createContentAssistant.

/**
 * Creates the content assistant.
 *
 * @return the content assistant
 */
private SubjectControlContentAssistant createContentAssistant() {
    final SubjectControlContentAssistant contentAssistant = new SubjectControlContentAssistant();
    contentAssistant.setRestoreCompletionProposalSize(CheckstyleUIPlugin.getDefault().getDialogSettings());
    IContentAssistProcessor processor = new PropertiesContentAssistProcessor();
    contentAssistant.setContentAssistProcessor(processor, IDocument.DEFAULT_CONTENT_TYPE);
    contentAssistant.setContextInformationPopupOrientation(IContentAssistant.CONTEXT_INFO_ABOVE);
    contentAssistant.setInformationControlCreator(new IInformationControlCreator() {

        /*
       * @see IInformationControlCreator#createInformationControl(Shell)
       */
        @Override
        public IInformationControl createInformationControl(Shell parent) {
            return new DefaultInformationControl(parent);
        }
    });
    return contentAssistant;
}
Also used : IInformationControlCreator(org.eclipse.jface.text.IInformationControlCreator) Shell(org.eclipse.swt.widgets.Shell) IInformationControl(org.eclipse.jface.text.IInformationControl) DefaultInformationControl(org.eclipse.jface.text.DefaultInformationControl) IContentAssistProcessor(org.eclipse.jface.text.contentassist.IContentAssistProcessor) SubjectControlContentAssistant(org.eclipse.jface.contentassist.SubjectControlContentAssistant) PropertiesContentAssistProcessor(net.sf.eclipsecs.ui.config.PropertiesContentAssistProcessor)

Example 8 with IInformationControlCreator

use of org.eclipse.jface.text.IInformationControlCreator in project eclipse-cs by checkstyle.

the class ConfigPropertyWidgetRegex method createContentAssistant.

/**
 * Creates the content assistant.
 *
 * @return the content assistant
 */
private SubjectControlContentAssistant createContentAssistant() {
    final SubjectControlContentAssistant contentAssistant = new SubjectControlContentAssistant();
    contentAssistant.setRestoreCompletionProposalSize(CheckstyleUIPlugin.getDefault().getDialogSettings());
    IContentAssistProcessor processor = new RegExContentAssistProcessor(true);
    contentAssistant.setContentAssistProcessor(processor, IDocument.DEFAULT_CONTENT_TYPE);
    contentAssistant.setContextInformationPopupOrientation(IContentAssistant.CONTEXT_INFO_ABOVE);
    contentAssistant.setInformationControlCreator(new IInformationControlCreator() {

        /*
       * @see IInformationControlCreator#createInformationControl(Shell)
       */
        @Override
        public IInformationControl createInformationControl(Shell parent) {
            return new DefaultInformationControl(parent);
        }
    });
    return contentAssistant;
}
Also used : IInformationControlCreator(org.eclipse.jface.text.IInformationControlCreator) Shell(org.eclipse.swt.widgets.Shell) IInformationControl(org.eclipse.jface.text.IInformationControl) DefaultInformationControl(org.eclipse.jface.text.DefaultInformationControl) IContentAssistProcessor(org.eclipse.jface.text.contentassist.IContentAssistProcessor) SubjectControlContentAssistant(org.eclipse.jface.contentassist.SubjectControlContentAssistant) RegExContentAssistProcessor(net.sf.eclipsecs.ui.util.regex.RegExContentAssistProcessor)

Example 9 with IInformationControlCreator

use of org.eclipse.jface.text.IInformationControlCreator in project eclipse-cs by checkstyle.

the class ResolvablePropertyEditDialog method createContentAssistant.

/**
 * Creates the content assistant.
 *
 * @return the content assistant
 */
private SubjectControlContentAssistant createContentAssistant() {
    final SubjectControlContentAssistant contentAssistant = new SubjectControlContentAssistant();
    contentAssistant.setRestoreCompletionProposalSize(CheckstyleUIPlugin.getDefault().getDialogSettings());
    IContentAssistProcessor processor = new PropertiesContentAssistProcessor();
    contentAssistant.setContentAssistProcessor(processor, IDocument.DEFAULT_CONTENT_TYPE);
    contentAssistant.setContextInformationPopupOrientation(IContentAssistant.CONTEXT_INFO_ABOVE);
    contentAssistant.setInformationControlCreator(new IInformationControlCreator() {

        /*
       * @see IInformationControlCreator#createInformationControl(Shell)
       */
        @Override
        public IInformationControl createInformationControl(Shell parent) {
            return new DefaultInformationControl(parent);
        }
    });
    return contentAssistant;
}
Also used : IInformationControlCreator(org.eclipse.jface.text.IInformationControlCreator) Shell(org.eclipse.swt.widgets.Shell) IInformationControl(org.eclipse.jface.text.IInformationControl) DefaultInformationControl(org.eclipse.jface.text.DefaultInformationControl) IContentAssistProcessor(org.eclipse.jface.text.contentassist.IContentAssistProcessor) SubjectControlContentAssistant(org.eclipse.jface.contentassist.SubjectControlContentAssistant)

Example 10 with IInformationControlCreator

use of org.eclipse.jface.text.IInformationControlCreator in project webtools.sourceediting by eclipse.

the class StructuredTextViewerConfiguration method getInformationPresenterControlCreator.

/**
 * Returns the information presenter control creator. The creator is a
 * factory creating the presenter controls for the given source viewer.
 *
 * @param sourceViewer
 *            the source viewer to be configured by this configuration
 * @return an information control creator
 */
private IInformationControlCreator getInformationPresenterControlCreator(ISourceViewer sourceViewer) {
    return new IInformationControlCreator() {

        public IInformationControl createInformationControl(Shell parent) {
            int shellStyle = SWT.RESIZE | SWT.TOOL;
            int style = SWT.V_SCROLL | SWT.H_SCROLL;
            return new DefaultInformationControl(parent, shellStyle, style, new HTMLTextPresenter(false));
        }
    };
}
Also used : IInformationControlCreator(org.eclipse.jface.text.IInformationControlCreator) Shell(org.eclipse.swt.widgets.Shell) DefaultInformationControl(org.eclipse.jface.text.DefaultInformationControl) HTMLTextPresenter(org.eclipse.wst.sse.ui.internal.derived.HTMLTextPresenter)

Aggregations

IInformationControlCreator (org.eclipse.jface.text.IInformationControlCreator)28 Shell (org.eclipse.swt.widgets.Shell)16 DefaultInformationControl (org.eclipse.jface.text.DefaultInformationControl)14 IInformationControl (org.eclipse.jface.text.IInformationControl)11 InformationPresenter (org.eclipse.jface.text.information.InformationPresenter)7 IContentAssistProcessor (org.eclipse.jface.text.contentassist.IContentAssistProcessor)5 IInformationPresenter (org.eclipse.jface.text.information.IInformationPresenter)5 SubjectControlContentAssistant (org.eclipse.jface.contentassist.SubjectControlContentAssistant)4 IInformationProvider (org.eclipse.jface.text.information.IInformationProvider)4 Point (org.eclipse.swt.graphics.Point)4 RegExContentAssistProcessor (net.sf.eclipsecs.ui.util.regex.RegExContentAssistProcessor)2 ISourceViewer (org.eclipse.jface.text.source.ISourceViewer)2 ProjectionSupport (org.eclipse.jface.text.source.projection.ProjectionSupport)2 HtmlTextPresenter (org.eclipse.mylyn.wikitext.ui.viewer.HtmlTextPresenter)2 Control (org.eclipse.swt.widgets.Control)2 HTMLTextPresenter (org.eclipse.wst.sse.ui.internal.derived.HTMLTextPresenter)2 ContentAssistant (com.cubrid.common.ui.query.control.jface.text.contentassist.ContentAssistant)1 IContentAssistant (com.cubrid.common.ui.query.control.jface.text.contentassist.IContentAssistant)1 GroovyASTCompletionProcessor (eu.esdihumboldt.hale.ui.util.groovy.internal.contentassist.GroovyASTCompletionProcessor)1 PropertiesContentAssistProcessor (net.sf.eclipsecs.ui.config.PropertiesContentAssistProcessor)1