Search in sources :

Example 16 with IInformationControlCreator

use of org.eclipse.jface.text.IInformationControlCreator in project hale by halestudio.

the class SimpleGroovySourceViewerConfiguration method getContentAssistant.

/*
	 * @see SourceViewerConfiguration#getContentAssistant(ISourceViewer)
	 */
@Override
public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) {
    // if (getEditor() != null) {
    // 
    ContentAssistant assistant = new ContentAssistant();
    assistant.setDocumentPartitioning(getConfiguredDocumentPartitioning(sourceViewer));
    assistant.enableColoredLabels(true);
    IContentAssistProcessor testProcessor = new GroovyASTCompletionProcessor(fCustomCompletions);
    assistant.setContentAssistProcessor(testProcessor, IDocument.DEFAULT_CONTENT_TYPE);
    // assistant.setRestoreCompletionProposalSize(getSettings("completion_proposal_size")); //$NON-NLS-1$
    // 
    // IContentAssistProcessor javaProcessor= new JavaCompletionProcessor(getEditor(), assistant, IDocument.DEFAULT_CONTENT_TYPE);
    // assistant.setContentAssistProcessor(javaProcessor, IDocument.DEFAULT_CONTENT_TYPE);
    // 
    // ContentAssistProcessor singleLineProcessor= new JavaCompletionProcessor(getEditor(), assistant, IJavaPartitions.JAVA_SINGLE_LINE_COMMENT);
    // assistant.setContentAssistProcessor(singleLineProcessor, IJavaPartitions.JAVA_SINGLE_LINE_COMMENT);
    // 
    // ContentAssistProcessor stringProcessor= new JavaCompletionProcessor(getEditor(), assistant, IJavaPartitions.JAVA_STRING);
    // assistant.setContentAssistProcessor(stringProcessor, IJavaPartitions.JAVA_STRING);
    // 
    // ContentAssistProcessor multiLineProcessor= new JavaCompletionProcessor(getEditor(), assistant, IJavaPartitions.JAVA_MULTI_LINE_COMMENT);
    // assistant.setContentAssistProcessor(multiLineProcessor, IJavaPartitions.JAVA_MULTI_LINE_COMMENT);
    // 
    // ContentAssistProcessor javadocProcessor= new JavadocCompletionProcessor(getEditor(), assistant);
    // assistant.setContentAssistProcessor(javadocProcessor, IJavaPartitions.JAVA_DOC);
    // 
    // ContentAssistPreference.configure(assistant, fPreferenceStore);
    // 
    // assistant.setContextInformationPopupOrientation(IContentAssistant.CONTEXT_INFO_ABOVE);
    // set how to show "additional information" in a completion proposal
    assistant.setInformationControlCreator(new IInformationControlCreator() {

        @Override
        public IInformationControl createInformationControl(Shell parent) {
            return new DefaultInformationControl(parent, true);
        }
    });
    return assistant;
// }
// return null;
}
Also used : GroovyASTCompletionProcessor(eu.esdihumboldt.hale.ui.util.groovy.internal.contentassist.GroovyASTCompletionProcessor) 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) IContentAssistant(org.eclipse.jface.text.contentassist.IContentAssistant) ContentAssistant(org.eclipse.jface.text.contentassist.ContentAssistant)

Example 17 with IInformationControlCreator

use of org.eclipse.jface.text.IInformationControlCreator in project erlide_eclipse by erlang.

the class AbstractErlangEditor method createPartControl.

@Override
public void createPartControl(final Composite parent) {
    super.createPartControl(parent);
    final IInformationControlCreator informationControlCreator = getSourceViewerConfiguration().getInformationControlCreator(getSourceViewer());
    fInformationPresenter = new InformationPresenter(informationControlCreator);
    // sizes: see org.eclipse.jface.text.TextViewer.TEXT_HOVER_*_CHARS
    fInformationPresenter.setSizeConstraints(100, 12, true, true);
    fInformationPresenter.install(getSourceViewer());
    fInformationPresenter.setDocumentPartitioning(getSourceViewerConfiguration().getConfiguredDocumentPartitioning(getSourceViewer()));
}
Also used : IInformationControlCreator(org.eclipse.jface.text.IInformationControlCreator) InformationPresenter(org.eclipse.jface.text.information.InformationPresenter)

Example 18 with IInformationControlCreator

use of org.eclipse.jface.text.IInformationControlCreator in project cubrid-manager by CUBRID.

the class SQLViewerConfiguration method getRecentlyUsedContentAssistant.

/**
	 * get recently used content assistant
	 *
	 * @param sourceViewer the source viewer to be configured by this
	 *        configuration
	 * @return a content assistant
	 */
public IContentAssistant getRecentlyUsedContentAssistant(ISourceViewer sourceViewer) {
    ContentAssistant assistant = new ContentAssistant();
    assistant.setInformationControlCreator(new IInformationControlCreator() {

        public IInformationControl createInformationControl(Shell parent) {
            DefaultInformationControl control = new DefaultInformationControl(parent);
            return control;
        }
    });
    recentlyUsedSQLContentAssistProcessor = new RecentSQLContentAssistProcessor(databaseProvider);
    assistant.setContentAssistProcessor(recentlyUsedSQLContentAssistProcessor, IDocument.DEFAULT_CONTENT_TYPE);
    return assistant;
}
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) IContentAssistant(com.cubrid.common.ui.query.control.jface.text.contentassist.IContentAssistant) ContentAssistant(com.cubrid.common.ui.query.control.jface.text.contentassist.ContentAssistant)

Example 19 with IInformationControlCreator

use of org.eclipse.jface.text.IInformationControlCreator in project eclipse.platform.text by eclipse.

the class FocusedInformationPresenter method openFocusedAnnotationHover.

/**
 * Tries show a focused ("sticky") annotation hover.
 *
 * @param annotationHover the annotation hover to show
 * @param line the line for which to show the hover
 * @return <code>true</code> if successful, <code>false</code> otherwise
 */
public boolean openFocusedAnnotationHover(IAnnotationHover annotationHover, int line) {
    try {
        // compute the hover information
        Object hoverInfo;
        if (annotationHover instanceof IAnnotationHoverExtension) {
            IAnnotationHoverExtension extension = (IAnnotationHoverExtension) annotationHover;
            ILineRange hoverLineRange = extension.getHoverLineRange(fSourceViewer, line);
            if (hoverLineRange == null)
                return false;
            // allow any number of lines being displayed, as we support scrolling
            final int maxVisibleLines = Integer.MAX_VALUE;
            hoverInfo = extension.getHoverInfo(fSourceViewer, hoverLineRange, maxVisibleLines);
        } else {
            hoverInfo = annotationHover.getHoverInfo(fSourceViewer, line);
        }
        // hover region: the beginning of the concerned line to place the control right over the line
        IDocument document = fSourceViewer.getDocument();
        int offset = document.getLineOffset(line);
        String contentType = TextUtilities.getContentType(document, fSourceViewerConfiguration.getConfiguredDocumentPartitioning(fSourceViewer), offset, true);
        IInformationControlCreator controlCreator = null;
        if (// this is undocumented, but left here for backwards compatibility
        annotationHover instanceof IInformationProviderExtension2)
            controlCreator = ((IInformationProviderExtension2) annotationHover).getInformationPresenterControlCreator();
        else if (annotationHover instanceof IAnnotationHoverExtension)
            controlCreator = ((IAnnotationHoverExtension) annotationHover).getHoverControlCreator();
        IInformationProvider informationProvider = new InformationProvider(new Region(offset, 0), hoverInfo, controlCreator);
        setOffset(offset);
        setAnchor(AbstractInformationControlManager.ANCHOR_RIGHT);
        // AnnotationBarHoverManager sets (5,0), minus SourceViewer.GAP_SIZE_1
        setMargins(4, 0);
        setInformationProvider(informationProvider, contentType);
        showInformation();
        return true;
    } catch (BadLocationException e) {
        return false;
    }
}
Also used : IInformationControlCreator(org.eclipse.jface.text.IInformationControlCreator) IInformationProviderExtension2(org.eclipse.jface.text.information.IInformationProviderExtension2) ILineRange(org.eclipse.jface.text.source.ILineRange) IInformationProvider(org.eclipse.jface.text.information.IInformationProvider) Region(org.eclipse.jface.text.Region) IRegion(org.eclipse.jface.text.IRegion) IInformationProvider(org.eclipse.jface.text.information.IInformationProvider) IAnnotationHoverExtension(org.eclipse.jface.text.source.IAnnotationHoverExtension) IDocument(org.eclipse.jface.text.IDocument) BadLocationException(org.eclipse.jface.text.BadLocationException)

Example 20 with IInformationControlCreator

use of org.eclipse.jface.text.IInformationControlCreator in project eclipse.platform.text by eclipse.

the class CompositeInformationControl method createContent.

@Override
public void createContent(Composite parent) {
    // TODO maybe use canReuse or canReplace
    this.controls = new LinkedHashMap<>();
    GridLayout layout = new GridLayout(1, false);
    parent.setLayout(layout);
    boolean firstControl = true;
    for (Entry<ITextHover, IInformationControlCreator> hoverControlCreator : this.creators.entrySet()) {
        IInformationControl informationControl = hoverControlCreator.getValue().createInformationControl(parent.getShell());
        if (informationControl instanceof AbstractInformationControl) {
            List<Control> children = Arrays.asList(((AbstractInformationControl) informationControl).getShell().getChildren());
            children.remove(parent);
            if (children.size() == 0) {
                continue;
            }
            for (Control control : children) {
                control.setParent(parent);
                control.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
            }
            if (!firstControl) {
                ((GridData) children.get(0).getLayoutData()).verticalIndent = 15;
            }
            controls.put(hoverControlCreator.getKey(), informationControl);
            firstControl = false;
        } else {
            GenericEditorPlugin.getDefault().getLog().log(new Status(IStatus.WARNING, GenericEditorPlugin.BUNDLE_ID, // $NON-NLS-1$
            "Only text hovers producing an AbstractInformationControl can be aggregated; got a " + informationControl.getClass().getSimpleName()));
            informationControl.dispose();
        }
    }
}
Also used : Status(org.eclipse.core.runtime.Status) IStatus(org.eclipse.core.runtime.IStatus) IInformationControlCreator(org.eclipse.jface.text.IInformationControlCreator) GridLayout(org.eclipse.swt.layout.GridLayout) IInformationControl(org.eclipse.jface.text.IInformationControl) AbstractInformationControl(org.eclipse.jface.text.AbstractInformationControl) Control(org.eclipse.swt.widgets.Control) ITextHover(org.eclipse.jface.text.ITextHover) IInformationControl(org.eclipse.jface.text.IInformationControl) AbstractInformationControl(org.eclipse.jface.text.AbstractInformationControl) GridData(org.eclipse.swt.layout.GridData)

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