Search in sources :

Example 6 with IEditingSupportRegistry

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

the class CompletionProposalPopup method displayProposals.

/**
 * Displays this popup and install the additional info controller, so that additional info
 * is displayed when a proposal is selected and additional info is available.
 */
void displayProposals() {
    if (!Helper.okToUse(fProposalShell) || !Helper.okToUse(fProposalTable))
        return;
    if (fContentAssistant.addContentAssistListener(this, ContentAssistant.PROPOSAL_SELECTOR)) {
        ensureDocumentListenerInstalled();
        if (fFocusHelper == null) {
            fFocusHelper = new IEditingSupport() {

                @Override
                public boolean isOriginator(DocumentEvent event, IRegion focus) {
                    // this helper just covers the focus change to the proposal shell, no remote editions
                    return false;
                }

                @Override
                public boolean ownsFocusShell() {
                    return true;
                }
            };
        }
        if (fViewer instanceof IEditingSupportRegistry) {
            IEditingSupportRegistry registry = (IEditingSupportRegistry) fViewer;
            registry.register(fFocusHelper);
        }
        /* https://bugs.eclipse.org/bugs/show_bug.cgi?id=52646
			 * on GTK, setVisible and such may run the event loop
			 * (see also https://bugs.eclipse.org/bugs/show_bug.cgi?id=47511)
			 * Since the user may have already canceled the popup or selected
			 * an entry (ESC or RETURN), we have to double check whether
			 * the table is still okToUse. See comments below
			 */
        // may run event loop on GTK
        fProposalShell.setVisible(true);
        // transfer focus since no verify key listener can be attached
        if (!fContentAssistSubjectControlAdapter.supportsVerifyKeyListener() && Helper.okToUse(fProposalShell))
            // may run event loop on GTK ??
            fProposalShell.setFocus();
        if (fAdditionalInfoController != null && Helper.okToUse(fProposalTable)) {
            fAdditionalInfoController.install(fProposalTable);
            fAdditionalInfoController.handleTableSelectionChanged();
        }
    } else
        hide();
}
Also used : IEditingSupport(org.eclipse.jface.text.IEditingSupport) IEditingSupportRegistry(org.eclipse.jface.text.IEditingSupportRegistry) DocumentEvent(org.eclipse.jface.text.DocumentEvent) IRegion(org.eclipse.jface.text.IRegion)

Aggregations

IEditingSupportRegistry (org.eclipse.jface.text.IEditingSupportRegistry)6 DocumentEvent (org.eclipse.jface.text.DocumentEvent)3 IDocument (org.eclipse.jface.text.IDocument)3 IEditingSupport (org.eclipse.jface.text.IEditingSupport)2 IRegion (org.eclipse.jface.text.IRegion)2 IRewriteTarget (org.eclipse.jface.text.IRewriteTarget)2 ITextViewerExtension (org.eclipse.jface.text.ITextViewerExtension)2 Point (org.eclipse.swt.graphics.Point)2 IDocumentListener (org.eclipse.jface.text.IDocumentListener)1 ICompletionProposalExtension (org.eclipse.jface.text.contentassist.ICompletionProposalExtension)1 ICompletionProposalExtension2 (org.eclipse.jface.text.contentassist.ICompletionProposalExtension2)1 IContextInformation (org.eclipse.jface.text.contentassist.IContextInformation)1 Shell (org.eclipse.swt.widgets.Shell)1