Skip to main content
summaryrefslogtreecommitdiffstats
blob: 1afbbfc088f5bb024b245334e70f0a9f971ef4f7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/*******************************************************************************
 * Copyright (c) 2004, 2007 Boeing.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     Boeing - initial API and implementation
 *******************************************************************************/
package org.eclipse.osee.framework.ui.plugin.util;

import java.text.Collator;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerComparator;
import org.eclipse.jface.viewers.ViewerSorter;

/**
 * @author Donald G. Dunne
 */
public class StringViewerSorter extends ViewerComparator {

   public StringViewerSorter() {
      // do nothing
   }

   public StringViewerSorter(Collator collator) {
      super(collator);
   }

   @Override
   public int compare(Viewer viewer, Object e1, Object e2) {
	  String s1 = e1 != null ? e1.toString() : null;
	  String s2 = e2 != null ? e2.toString() : null;
      return getComparator().compare(s1, s2);
   }
}

Back to the top