1
1
/*******************************************************************************
2
- * Copyright (c) 2006, 2016 IBM Corporation and others.
2
+ * Copyright (c) 2006, 2024 IBM Corporation and others.
3
3
*
4
4
* This program and the accompanying materials
5
5
* are made available under the terms of the Eclipse Public License 2.0
21
21
import org .eclipse .jface .viewers .ILabelProvider ;
22
22
import org .eclipse .jface .viewers .StructuredViewer ;
23
23
import org .eclipse .jface .viewers .Viewer ;
24
- import org .eclipse .jface .viewers .ViewerSorter ;
24
+ import org .eclipse .jface .viewers .ViewerComparator ;
25
25
26
26
/**
27
27
* @since 3.2
28
28
*/
29
- public class WorkingSetSorter extends ViewerSorter {
29
+ public class WorkingSetSorter extends ViewerComparator {
30
30
31
31
@ Override
32
32
public int compare (Viewer viewer , Object e1 , Object e2 ) {
@@ -36,15 +36,14 @@ public int compare(Viewer viewer, Object e1, Object e2) {
36
36
} else if (e2 == WorkingSetsContentProvider .OTHERS_WORKING_SET ) {
37
37
return -1 ;
38
38
}
39
- if (viewer instanceof StructuredViewer ) {
40
- ILabelProvider labelProvider = (ILabelProvider ) (( StructuredViewer ) viewer ) .getLabelProvider ();
39
+ if (viewer instanceof StructuredViewer sViewer ) {
40
+ ILabelProvider labelProvider = (ILabelProvider ) sViewer .getLabelProvider ();
41
41
42
- if (labelProvider instanceof DecoratingStyledCellLabelProvider ) {
42
+ if (labelProvider instanceof DecoratingStyledCellLabelProvider dprov ) {
43
43
// Bug 512637: use the real label provider to avoid unstable
44
44
// sort behavior if the decoration is running while sorting.
45
45
// decorations are usually visual aids to the user and
46
46
// shouldn't be used in ordering.
47
- DecoratingStyledCellLabelProvider dprov = (DecoratingStyledCellLabelProvider ) labelProvider ;
48
47
IStyledLabelProvider styledLabelProvider = dprov .getStyledStringProvider ();
49
48
String text1 = styledLabelProvider .getStyledText (e1 ).getString ();
50
49
String text2 = styledLabelProvider .getStyledText (e2 ).getString ();
@@ -54,12 +53,11 @@ public int compare(Viewer viewer, Object e1, Object e2) {
54
53
return -1 ;
55
54
}
56
55
57
- if (labelProvider instanceof DecoratingLabelProvider ) {
56
+ if (labelProvider instanceof DecoratingLabelProvider dprov ) {
58
57
// Bug 364735: use the real label provider to avoid unstable
59
58
// sort behavior if the decoration is running while sorting.
60
59
// decorations are usually visual aids to the user and
61
60
// shouldn't be used in ordering.
62
- DecoratingLabelProvider dprov = (DecoratingLabelProvider ) labelProvider ;
63
61
labelProvider = dprov .getLabelProvider ();
64
62
}
65
63
0 commit comments