15
15
16
16
import java .util .Comparator ;
17
17
18
+ import org .eclipse .core .runtime .Assert ;
18
19
import org .eclipse .core .runtime .IProgressMonitor ;
19
20
import org .eclipse .core .runtime .NullProgressMonitor ;
20
21
import org .eclipse .jface .resource .JFaceResources ;
21
- import org .eclipse .core .runtime .Assert ;
22
22
import org .eclipse .jface .viewers .AcceptAllFilter ;
23
23
import org .eclipse .jface .viewers .IFilter ;
24
- import org .eclipse .jface .viewers .deferred .ConcurrentTableUpdator .Range ;
25
24
26
25
/**
27
26
* Contains the algorithm for performing background sorting and filtering in a virtual
@@ -124,10 +123,6 @@ public void update(Object[] changed) {
124
123
private IProgressMonitor sortingProgressMonitor = new NullProgressMonitor ();
125
124
private Thread sortThread = null ;
126
125
127
- private volatile FastProgressReporter sortMon = new FastProgressReporter ();
128
-
129
- private volatile Range range = new Range (0 ,0 );
130
-
131
126
/**
132
127
* Creates a new background content provider
133
128
*
@@ -307,42 +302,35 @@ private void doSort(IProgressMonitor mon) {
307
302
break ;
308
303
}
309
304
310
- try {
311
- ConcurrentTableUpdator .Range updateRange = updator .getVisibleRange ();
312
- sortMon = new FastProgressReporter ();
313
- range = updateRange ;
314
- int sortStart = updateRange .start ;
315
- int sortLength = updateRange .length ;
305
+ ConcurrentTableUpdator .Range updateRange = updator .getVisibleRange ();
306
+ int sortStart = updateRange .start ;
307
+ int sortLength = updateRange .length ;
316
308
317
- if (limit != -1 ) {
318
- collection .retainFirst (limit , sortMon );
319
- }
320
-
321
- sortLength = Math .min (sortLength , totalElements - sortStart );
322
- sortLength = Math .max (sortLength , 0 );
309
+ if (limit != -1 ) {
310
+ collection .retainFirst (limit );
311
+ }
323
312
324
- Object [] objectsOfInterest = new Object [sortLength ];
313
+ sortLength = Math .min (sortLength , totalElements - sortStart );
314
+ sortLength = Math .max (sortLength , 0 );
325
315
326
- collection . getRange ( objectsOfInterest , sortStart , true , sortMon ) ;
316
+ Object [] objectsOfInterest = new Object [ sortLength ] ;
327
317
328
- // Send the new elements to the table
329
- for (int i = 0 ; i < sortLength ; i ++) {
330
- Object object = objectsOfInterest [i ];
331
- updator .replace (object , sortStart + i );
332
- }
318
+ collection .getRange (objectsOfInterest , sortStart , true );
333
319
334
- objectsOfInterest = new Object [collection .size ()];
320
+ // Send the new elements to the table
321
+ for (int i = 0 ; i < sortLength ; i ++) {
322
+ Object object = objectsOfInterest [i ];
323
+ updator .replace (object , sortStart + i );
324
+ }
335
325
336
- collection . getFirst ( objectsOfInterest , true , sortMon ) ;
326
+ objectsOfInterest = new Object [ collection . size ()] ;
337
327
338
- // Send the new elements to the table
339
- for (int i = 0 ; i < totalElements ; i ++) {
340
- Object object = objectsOfInterest [i ];
341
- updator .replace (object , i );
342
- }
328
+ collection .getFirst (objectsOfInterest , true );
343
329
344
- } catch (InterruptedException e ) {
345
- continue ;
330
+ // Send the new elements to the table
331
+ for (int i = 0 ; i < totalElements ; i ++) {
332
+ Object object = objectsOfInterest [i ];
333
+ updator .replace (object , i );
346
334
}
347
335
348
336
dirty = false ;
@@ -371,7 +359,6 @@ private static void filteredAdd(LazySortedCollection collection, Object[] toAdd,
371
359
public void setSortOrder (Comparator sorter ) {
372
360
Assert .isNotNull (sorter );
373
361
this .sortOrder = sorter ;
374
- sortMon .cancel ();
375
362
refresh ();
376
363
}
377
364
@@ -383,7 +370,6 @@ public void setSortOrder(Comparator sorter) {
383
370
public void setFilter (IFilter toSet ) {
384
371
Assert .isNotNull (toSet );
385
372
this .filter = toSet ;
386
- sortMon .cancel ();
387
373
refresh ();
388
374
}
389
375
@@ -417,13 +403,6 @@ public int getLimit() {
417
403
*/
418
404
public void checkVisibleRange (int includeIndex ) {
419
405
updator .checkVisibleRange (includeIndex );
420
- ConcurrentTableUpdator .Range newRange = updator .getVisibleRange ();
421
- ConcurrentTableUpdator .Range oldRange = range ;
422
-
423
- // If we're in the middle of processing an invalid range, cancel the sort
424
- if (newRange .start != oldRange .start || newRange .length != oldRange .length ) {
425
- sortMon .cancel ();
426
- }
427
406
}
428
407
429
408
/**
@@ -475,7 +454,6 @@ public void run() {
475
454
*/
476
455
private void makeDirty () {
477
456
synchronized (lock ) {
478
- sortMon .cancel ();
479
457
// request sorting
480
458
sortScheduled = true ;
481
459
if (!sortThreadStarted ) {
@@ -495,7 +473,6 @@ private void makeDirty() {
495
473
* ways.
496
474
*/
497
475
private void cancelSortJob () {
498
- sortMon .cancel ();
499
476
sortingProgressMonitor .setCanceled (true );
500
477
}
501
478
0 commit comments