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);
}
}
Aggregations