KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > debug > internal > ui > launchConfigurations > WorkingSetComparator


1 /*******************************************************************************
2  * Copyright (c) 2000, 2005 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.debug.internal.ui.launchConfigurations;
12
13 import java.util.Comparator JavaDoc;
14
15 import org.eclipse.debug.ui.RefreshTab;
16 import org.eclipse.ui.IWorkingSet;
17
18 /**
19  * Comparator for refresh scope launch configuration attribute
20  * <code>ATTR_REFRESH_SCOPE</code>.
21  */

22 public class WorkingSetComparator implements Comparator JavaDoc {
23
24     /* (non-Javadoc)
25      * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
26      */

27     public int compare(Object JavaDoc o1, Object JavaDoc o2) {
28         String JavaDoc one= (String JavaDoc)o1;
29         String JavaDoc two= (String JavaDoc)o2;
30         if (one == null || two == null) {
31             if (one == two) {
32                 return 0;
33             }
34             return -1;
35         }
36         if (one.startsWith("${working_set:") && two.startsWith("${working_set:")) { //$NON-NLS-1$//$NON-NLS-2$
37
IWorkingSet workingSet1 = RefreshTab.getWorkingSet(one);
38             IWorkingSet workingSet2 = RefreshTab.getWorkingSet(two);
39             if (workingSet1 == null || workingSet2 == null) {
40                 if (workingSet1 == workingSet2) {
41                     return 0;
42                 }
43                 return -1;
44             }
45             if (workingSet1.equals(workingSet2)) {
46                 return 0;
47             }
48             return -1;
49         }
50         return one.compareTo(two);
51     }
52 }
53
Popular Tags