|
Link Here
|
| 12 |
package org.eclipse.jface.text.contentassist; |
12 |
package org.eclipse.jface.text.contentassist; |
| 13 |
|
13 |
|
| 14 |
import java.util.ArrayList; |
14 |
import java.util.ArrayList; |
|
|
15 |
import java.util.Arrays; |
| 16 |
import java.util.Comparator; |
| 15 |
import java.util.List; |
17 |
import java.util.List; |
| 16 |
|
18 |
|
| 17 |
import org.eclipse.osgi.util.TextProcessor; |
19 |
import org.eclipse.osgi.util.TextProcessor; |
|
Link Here
|
| 429 |
*/ |
431 |
*/ |
| 430 |
private boolean fIsColoredLabelsSupportEnabled= false; |
432 |
private boolean fIsColoredLabelsSupportEnabled= false; |
| 431 |
|
433 |
|
|
|
434 |
private ICompletionProposalSorter fSorter; |
| 432 |
|
435 |
|
| 433 |
/** |
436 |
/** |
| 434 |
* Creates a new completion proposal popup for the given elements. |
437 |
* Creates a new completion proposal popup for the given elements. |
|
Link Here
|
| 1096 |
if (oldProposals != fFilteredProposals) // reentrant call was first - abort |
1099 |
if (oldProposals != fFilteredProposals) // reentrant call was first - abort |
| 1097 |
return; |
1100 |
return; |
| 1098 |
|
1101 |
|
|
|
1102 |
sortProposals(proposals); |
| 1103 |
|
| 1099 |
if (Helper.okToUse(fProposalTable)) { |
1104 |
if (Helper.okToUse(fProposalTable)) { |
| 1100 |
if (oldProposal instanceof ICompletionProposalExtension2 && fViewer != null) |
1105 |
if (oldProposal instanceof ICompletionProposalExtension2 && fViewer != null) |
| 1101 |
((ICompletionProposalExtension2) oldProposal).unselected(fViewer); |
1106 |
((ICompletionProposalExtension2) oldProposal).unselected(fViewer); |
|
Link Here
|
| 1831 |
return new ProposalSelectionHandler(operationCode); |
1836 |
return new ProposalSelectionHandler(operationCode); |
| 1832 |
} |
1837 |
} |
| 1833 |
|
1838 |
|
|
|
1839 |
/** |
| 1840 |
* Sets the sorter to use when reordering is required by one of the completion engines. |
| 1841 |
* |
| 1842 |
* @param sorter the sorter new sorter to be used. May be <code>null</code>. |
| 1843 |
* |
| 1844 |
* @since 3.8 |
| 1845 |
*/ |
| 1846 |
public void setSorter(ICompletionProposalSorter sorter) { |
| 1847 |
fSorter= sorter; |
| 1848 |
} |
| 1849 |
|
| 1850 |
/** |
| 1851 |
* Sorts the given proposal array if a sorter is configured. Does nothing otherwise. |
| 1852 |
* |
| 1853 |
* @param proposals the new proposals to display in the popup window |
| 1854 |
*/ |
| 1855 |
private void sortProposals(final ICompletionProposal[] proposals) { |
| 1856 |
if (fSorter != null) { |
| 1857 |
Arrays.sort(proposals, new Comparator() { |
| 1858 |
public int compare(Object o1, Object o2) { |
| 1859 |
return fSorter.compare((ICompletionProposal)o1, |
| 1860 |
(ICompletionProposal)o2); |
| 1861 |
} |
| 1862 |
}); |
| 1863 |
} |
| 1864 |
} |
| 1834 |
} |
1865 |
} |