Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 52c784d2e0d5ef17da4ca60924cb226f3bb8d917 (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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/*******************************************************************************
 * Copyright (c) 2000, 2013 IBM Corporation and others.
 * 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:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/
package org.eclipse.ui.externaltools.internal.launchConfigurations;

import java.util.Comparator;

import org.eclipse.debug.ui.RefreshTab;
import org.eclipse.ui.IWorkingSet;

/**
 * Comparator for refresh scope launch configuration attribute
 * <code>ATTR_REFRESH_SCOPE</code>.
 */
public class WorkingSetComparator implements Comparator<String> {

	/* (non-Javadoc)
	 * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
	 */
	@Override
	public int compare(String o1, String o2) {
		if (o1 == null || o2 == null) {
			if (o1 == o2) {
				return 0;
			}
			return -1;
		}
		if (o1.startsWith("${working_set:") && o2.startsWith("${working_set:")) { //$NON-NLS-1$//$NON-NLS-2$
			IWorkingSet workingSet1 = RefreshTab.getWorkingSet(o1);
			IWorkingSet workingSet2 = RefreshTab.getWorkingSet(o2);
			if (workingSet1 == null || workingSet2 == null) {
				if (workingSet1 == workingSet2) {
					return 0;
				}
				return -1;
			}
			if (workingSet1.equals(workingSet2)) {
				return 0;
			}
			return -1;
		}
		return o1.compareTo(o2);
	}
}

Back to the top