Search in sources :

Example 1 with ICompletionProposalExtension6

use of org.eclipse.jface.text.contentassist.ICompletionProposalExtension6 in project eclipse.platform.text by eclipse.

the class CompletionProposalPopup2 method setProposals.

/**
 * Initializes the proposal selector with these given proposals.
 *
 * @param proposals the proposals
 */
private void setProposals(ICompletionProposal[] proposals) {
    if (Helper2.okToUse(fProposalTable)) {
        ICompletionProposal oldProposal = getSelectedProposal();
        if (oldProposal instanceof ICompletionProposalExtension2)
            ((ICompletionProposalExtension2) oldProposal).unselected(fViewer);
        fFilteredProposals = proposals;
        int selectionIndex = 0;
        fProposalTable.setRedraw(false);
        try {
            fProposalTable.removeAll();
            Point selection = fViewer.getSelectedRange();
            int endOffset;
            endOffset = selection.x + selection.y;
            IDocument document = fViewer.getDocument();
            boolean validate = false;
            if (selection.y != 0 && document != null)
                validate = true;
            TableItem item;
            ICompletionProposal p;
            for (int i = 0; i < proposals.length; i++) {
                p = proposals[i];
                item = new TableItem(fProposalTable, SWT.NULL);
                if (p.getImage() != null)
                    item.setImage(p.getImage());
                String displayString;
                StyleRange[] styleRanges = null;
                if (fIsColoredLabelsSupportEnabled && p instanceof ICompletionProposalExtension6) {
                    StyledString styledString = ((ICompletionProposalExtension6) p).getStyledDisplayString();
                    displayString = styledString.getString();
                    styleRanges = styledString.getStyleRanges();
                } else
                    displayString = p.getDisplayString();
                item.setText(displayString);
                if (fIsColoredLabelsSupportEnabled)
                    TableOwnerDrawSupport.storeStyleRanges(item, 0, styleRanges);
                item.setData(p);
                if (validate && validateProposal(document, p, endOffset, null)) {
                    selectionIndex = i;
                    validate = false;
                }
            }
        } finally {
            fProposalTable.setRedraw(true);
        }
        resizeProposalSelector(false);
        selectProposal(selectionIndex, false);
    }
}
Also used : ICompletionProposal(org.eclipse.jface.text.contentassist.ICompletionProposal) TableItem(org.eclipse.swt.widgets.TableItem) StyleRange(org.eclipse.swt.custom.StyleRange) ICompletionProposalExtension2(org.eclipse.jface.text.contentassist.ICompletionProposalExtension2) Point(org.eclipse.swt.graphics.Point) StyledString(org.eclipse.jface.viewers.StyledString) StyledString(org.eclipse.jface.viewers.StyledString) Point(org.eclipse.swt.graphics.Point) IDocument(org.eclipse.jface.text.IDocument) ICompletionProposalExtension6(org.eclipse.jface.text.contentassist.ICompletionProposalExtension6)

Aggregations

IDocument (org.eclipse.jface.text.IDocument)1 ICompletionProposal (org.eclipse.jface.text.contentassist.ICompletionProposal)1 ICompletionProposalExtension2 (org.eclipse.jface.text.contentassist.ICompletionProposalExtension2)1 ICompletionProposalExtension6 (org.eclipse.jface.text.contentassist.ICompletionProposalExtension6)1 StyledString (org.eclipse.jface.viewers.StyledString)1 StyleRange (org.eclipse.swt.custom.StyleRange)1 Point (org.eclipse.swt.graphics.Point)1 TableItem (org.eclipse.swt.widgets.TableItem)1