|
Link Here
|
| 8 |
* Contributors: |
8 |
* Contributors: |
| 9 |
* IBM Corporation - initial API and implementation |
9 |
* IBM Corporation - initial API and implementation |
| 10 |
* Sean Montgomery, sean_montgomery@comcast.net - https://bugs.eclipse.org/bugs/show_bug.cgi?id=116454 |
10 |
* Sean Montgomery, sean_montgomery@comcast.net - https://bugs.eclipse.org/bugs/show_bug.cgi?id=116454 |
|
|
11 |
* Marcel Bruch, bruch@cs.tu-darmstadt.de - [content assist] Allow to re-sort proposals - https://bugs.eclipse.org/bugs/show_bug.cgi?id=350991 |
| 11 |
*******************************************************************************/ |
12 |
*******************************************************************************/ |
| 12 |
package org.eclipse.jface.text.contentassist; |
13 |
package org.eclipse.jface.text.contentassist; |
| 13 |
|
14 |
|
| 14 |
import java.util.ArrayList; |
15 |
import java.util.ArrayList; |
|
|
16 |
import java.util.Arrays; |
| 17 |
import java.util.Comparator; |
| 15 |
import java.util.List; |
18 |
import java.util.List; |
| 16 |
|
19 |
|
| 17 |
import org.eclipse.osgi.util.TextProcessor; |
20 |
import org.eclipse.osgi.util.TextProcessor; |
|
Link Here
|
| 429 |
*/ |
432 |
*/ |
| 430 |
private boolean fIsColoredLabelsSupportEnabled= false; |
433 |
private boolean fIsColoredLabelsSupportEnabled= false; |
| 431 |
|
434 |
|
|
|
435 |
/** |
| 436 |
* The most recent sorter. Used when sorting proposals after filtering is requested by a completion engine. The sorter may |
| 437 |
* be <code>null</code>. |
| 438 |
* |
| 439 |
* @since 3.8 |
| 440 |
*/ |
| 441 |
private ICompletionProposalSorter fSorter; |
| 432 |
|
442 |
|
| 433 |
/** |
443 |
/** |
| 434 |
* Creates a new completion proposal popup for the given elements. |
444 |
* Creates a new completion proposal popup for the given elements. |
|
Link Here
|
| 1084 |
} |
1094 |
} |
| 1085 |
|
1095 |
|
| 1086 |
/** |
1096 |
/** |
| 1087 |
* Initializes the proposal selector with these given proposals. |
1097 |
* Initializes the proposal selector with these given proposals. If a proposal sorter is |
|
|
1098 |
* configured, the given proposals are sorted before. |
| 1099 |
* |
| 1088 |
* @param proposals the proposals |
1100 |
* @param proposals the proposals |
| 1089 |
* @param isFilteredSubset if <code>true</code>, the proposal table is |
1101 |
* @param isFilteredSubset if <code>true</code>, the proposal table is |
| 1090 |
* not cleared, but the proposals that are not in the passed array |
1102 |
* not cleared, but the proposals that are not in the passed array |
|
Link Here
|
| 1106 |
proposals= new ICompletionProposal[] { fEmptyProposal }; |
1118 |
proposals= new ICompletionProposal[] { fEmptyProposal }; |
| 1107 |
} |
1119 |
} |
| 1108 |
|
1120 |
|
|
|
1121 |
sortProposals(proposals); |
| 1109 |
fFilteredProposals= proposals; |
1122 |
fFilteredProposals= proposals; |
| 1110 |
final int newLen= proposals.length; |
1123 |
final int newLen= proposals.length; |
| 1111 |
if (USE_VIRTUAL) { |
1124 |
if (USE_VIRTUAL) { |
|
Link Here
|
| 1831 |
return new ProposalSelectionHandler(operationCode); |
1844 |
return new ProposalSelectionHandler(operationCode); |
| 1832 |
} |
1845 |
} |
| 1833 |
|
1846 |
|
|
|
1847 |
/** |
| 1848 |
* Sets the sorter to use when resorting is required by one of the completion engines. |
| 1849 |
* |
| 1850 |
* @param sorter the new sorter to be used, or <code>null</code> if no sorter is needed |
| 1851 |
* @since 3.8 |
| 1852 |
*/ |
| 1853 |
public void setSorter(ICompletionProposalSorter sorter) { |
| 1854 |
fSorter= sorter; |
| 1855 |
} |
| 1856 |
|
| 1857 |
/** |
| 1858 |
* Sorts the given proposal array if a sorter is configured. Does nothing otherwise. |
| 1859 |
* |
| 1860 |
* @param proposals the new proposals to display in the popup window |
| 1861 |
* @since 3.8 |
| 1862 |
*/ |
| 1863 |
private void sortProposals(final ICompletionProposal[] proposals) { |
| 1864 |
if (fSorter != null) { |
| 1865 |
Arrays.sort(proposals, new Comparator() { |
| 1866 |
public int compare(Object o1, Object o2) { |
| 1867 |
return fSorter.compare((ICompletionProposal)o1, |
| 1868 |
(ICompletionProposal)o2); |
| 1869 |
} |
| 1870 |
}); |
| 1871 |
} |
| 1872 |
} |
| 1834 |
} |
1873 |
} |