|
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
|
| 553 |
private ICompletionProposal[] computeProposals(int offset) { |
563 |
private ICompletionProposal[] computeProposals(int offset) { |
| 554 |
if (fContentAssistSubjectControl != null) |
564 |
if (fContentAssistSubjectControl != null) |
| 555 |
return fContentAssistant.computeCompletionProposals(fContentAssistSubjectControl, offset); |
565 |
return fContentAssistant.computeCompletionProposals(fContentAssistSubjectControl, offset); |
| 556 |
return fContentAssistant.computeCompletionProposals(fViewer, offset); |
566 |
ICompletionProposal[] proposals= fContentAssistant.computeCompletionProposals(fViewer, offset); |
|
|
567 |
return proposals; |
| 557 |
} |
568 |
} |
| 558 |
|
569 |
|
| 559 |
/** |
570 |
/** |
|
Link Here
|
| 1018 |
if (Helper.okToUse(fProposalShell)) { |
1029 |
if (Helper.okToUse(fProposalShell)) { |
| 1019 |
|
1030 |
|
| 1020 |
fContentAssistant.removeContentAssistListener(this, ContentAssistant.PROPOSAL_SELECTOR); |
1031 |
fContentAssistant.removeContentAssistListener(this, ContentAssistant.PROPOSAL_SELECTOR); |
| 1021 |
|
1032 |
fContentAssistant.setSorter(null); |
| 1022 |
fPopupCloser.uninstall(); |
1033 |
fPopupCloser.uninstall(); |
| 1023 |
fProposalShell.setVisible(false); |
1034 |
fProposalShell.setVisible(false); |
| 1024 |
fProposalShell.dispose(); |
1035 |
fProposalShell.dispose(); |
|
Link Here
|
| 1105 |
fEmptyProposal.fDisplayString= fEmptyMessage != null ? fEmptyMessage : JFaceTextMessages.getString("CompletionProposalPopup.no_proposals"); //$NON-NLS-1$ |
1116 |
fEmptyProposal.fDisplayString= fEmptyMessage != null ? fEmptyMessage : JFaceTextMessages.getString("CompletionProposalPopup.no_proposals"); //$NON-NLS-1$ |
| 1106 |
proposals= new ICompletionProposal[] { fEmptyProposal }; |
1117 |
proposals= new ICompletionProposal[] { fEmptyProposal }; |
| 1107 |
} |
1118 |
} |
|
|
1119 |
|
| 1120 |
sortProposals(proposals); |
| 1108 |
|
1121 |
|
| 1109 |
fFilteredProposals= proposals; |
1122 |
fFilteredProposals= proposals; |
| 1110 |
final int newLen= proposals.length; |
1123 |
final int newLen= proposals.length; |
|
Link Here
|
| 1831 |
return new ProposalSelectionHandler(operationCode); |
1844 |
return new ProposalSelectionHandler(operationCode); |
| 1832 |
} |
1845 |
} |
| 1833 |
|
1846 |
|
|
|
1847 |
/** |
| 1848 |
* Sets the sorter to use when reordering is required by one of the completion engines. |
| 1849 |
* |
| 1850 |
* @param sorter the new sorter to be used. May be <code>null</code>. |
| 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 |
} |