01: /*******************************************************************************
02: * Copyright (c) 2007 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.pde.internal.ui.editor.contentassist;
11:
12: import java.util.Comparator;
13:
14: import org.eclipse.pde.internal.core.ischema.ISchemaElement;
15:
16: /**
17: * XMLElementProposalComparator
18: *
19: */
20: public class XMLElementProposalComparator implements Comparator {
21:
22: /**
23: *
24: */
25: public XMLElementProposalComparator() {
26: // NO-OP
27: }
28:
29: /* (non-Javadoc)
30: * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
31: */
32: public int compare(Object object1, Object object2) {
33: String proposal1 = getSortKey((ISchemaElement) object1);
34: String proposal2 = getSortKey((ISchemaElement) object2);
35:
36: return proposal1.compareToIgnoreCase(proposal2);
37: }
38:
39: /**
40: * @param proposal
41: * @return
42: */
43: private String getSortKey(ISchemaElement proposal) {
44: return proposal.getName();
45: }
46:
47: }
|