11/*******************************************************************************
2- * Copyright (c) 2006, 2016 IBM Corporation and others.
2+ * Copyright (c) 2006, 2024 IBM Corporation and others.
33 *
44 * This program and the accompanying materials
55 * are made available under the terms of the Eclipse Public License 2.0
2121import org .eclipse .jface .viewers .ILabelProvider ;
2222import org .eclipse .jface .viewers .StructuredViewer ;
2323import org .eclipse .jface .viewers .Viewer ;
24- import org .eclipse .jface .viewers .ViewerSorter ;
24+ import org .eclipse .jface .viewers .ViewerComparator ;
2525
2626/**
2727 * @since 3.2
2828 */
29- public class WorkingSetSorter extends ViewerSorter {
29+ public class WorkingSetSorter extends ViewerComparator {
3030
3131 @ Override
3232 public int compare (Viewer viewer , Object e1 , Object e2 ) {
@@ -36,15 +36,14 @@ public int compare(Viewer viewer, Object e1, Object e2) {
3636 } else if (e2 == WorkingSetsContentProvider .OTHERS_WORKING_SET ) {
3737 return -1 ;
3838 }
39- if (viewer instanceof StructuredViewer ) {
40- ILabelProvider labelProvider = (ILabelProvider ) (( StructuredViewer ) viewer ) .getLabelProvider ();
39+ if (viewer instanceof StructuredViewer sViewer ) {
40+ ILabelProvider labelProvider = (ILabelProvider ) sViewer .getLabelProvider ();
4141
42- if (labelProvider instanceof DecoratingStyledCellLabelProvider ) {
42+ if (labelProvider instanceof DecoratingStyledCellLabelProvider dprov ) {
4343 // Bug 512637: use the real label provider to avoid unstable
4444 // sort behavior if the decoration is running while sorting.
4545 // decorations are usually visual aids to the user and
4646 // shouldn't be used in ordering.
47- DecoratingStyledCellLabelProvider dprov = (DecoratingStyledCellLabelProvider ) labelProvider ;
4847 IStyledLabelProvider styledLabelProvider = dprov .getStyledStringProvider ();
4948 String text1 = styledLabelProvider .getStyledText (e1 ).getString ();
5049 String text2 = styledLabelProvider .getStyledText (e2 ).getString ();
@@ -54,12 +53,11 @@ public int compare(Viewer viewer, Object e1, Object e2) {
5453 return -1 ;
5554 }
5655
57- if (labelProvider instanceof DecoratingLabelProvider ) {
56+ if (labelProvider instanceof DecoratingLabelProvider dprov ) {
5857 // Bug 364735: use the real label provider to avoid unstable
5958 // sort behavior if the decoration is running while sorting.
6059 // decorations are usually visual aids to the user and
6160 // shouldn't be used in ordering.
62- DecoratingLabelProvider dprov = (DecoratingLabelProvider ) labelProvider ;
6361 labelProvider = dprov .getLabelProvider ();
6462 }
6563
0 commit comments