01: /*******************************************************************************
02: * Copyright (c) 2005, 2006 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.ui.tests.navigator.extension;
11:
12: import java.text.Collator;
13:
14: import org.eclipse.jface.viewers.Viewer;
15: import org.eclipse.jface.viewers.ViewerSorter;
16:
17: public class TestDataSorter extends ViewerSorter {
18:
19: public TestDataSorter() {
20: super ();
21: }
22:
23: public TestDataSorter(Collator collator) {
24: super (collator);
25: }
26:
27: /* (non-Javadoc)
28: * @see org.eclipse.jface.viewers.ViewerSorter#compare(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
29: */
30: public int compare(Viewer viewer, Object e1, Object e2) {
31:
32: if (e1 instanceof TestExtensionTreeData) {
33: if (e2 instanceof TestExtensionTreeData) {
34: TestExtensionTreeData lvalue = (TestExtensionTreeData) e1;
35: TestExtensionTreeData rvalue = (TestExtensionTreeData) e2;
36:
37: return lvalue.getName().compareTo(rvalue.getName());
38: }
39: return -1;
40: } else if (e2 instanceof TestExtensionTreeData) {
41: return +1;
42: }
43:
44: return super.compare(viewer, e1, e2);
45: }
46:
47: }
|