added code completion for HTML mode
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / ui / text / java / PHPCompletionProposalComparator.java
1 package net.sourceforge.phpdt.internal.ui.text.java;
2
3 import java.util.Comparator;
4
5 public class PHPCompletionProposalComparator implements Comparator {
6
7         private boolean fOrderAlphabetically;
8
9         /**
10          * Constructor for CompletionProposalComparator.
11          */
12         public PHPCompletionProposalComparator() {
13                 fOrderAlphabetically= false;
14         }
15         
16         public void setOrderAlphabetically(boolean orderAlphabetically) {
17                 fOrderAlphabetically= orderAlphabetically;
18         }
19         
20         /* (non-Javadoc)
21          * @see Comparator#compare(Object, Object)
22          */
23         public int compare(Object o1, Object o2) {
24                 IPHPCompletionProposal c1= (IPHPCompletionProposal) o1;
25                 IPHPCompletionProposal c2= (IPHPCompletionProposal) o2;
26                 if (!fOrderAlphabetically) {
27                         int relevanceDif= c2.getRelevance() - c1.getRelevance();
28                         if (relevanceDif != 0) {
29                                 return relevanceDif;
30                         }
31                 }
32                 return c1.getDisplayString().compareToIgnoreCase(c2.getDisplayString());
33         }       
34         
35 }