1515
1616import java .util .Comparator ;
1717
18+ import org .eclipse .core .runtime .Assert ;
1819import org .eclipse .core .runtime .IProgressMonitor ;
1920import org .eclipse .core .runtime .NullProgressMonitor ;
2021import org .eclipse .jface .resource .JFaceResources ;
21- import org .eclipse .core .runtime .Assert ;
2222import org .eclipse .jface .viewers .AcceptAllFilter ;
2323import org .eclipse .jface .viewers .IFilter ;
24- import org .eclipse .jface .viewers .deferred .ConcurrentTableUpdator .Range ;
2524
2625/**
2726 * Contains the algorithm for performing background sorting and filtering in a virtual
@@ -124,10 +123,6 @@ public void update(Object[] changed) {
124123 private IProgressMonitor sortingProgressMonitor = new NullProgressMonitor ();
125124 private Thread sortThread = null ;
126125
127- private volatile FastProgressReporter sortMon = new FastProgressReporter ();
128-
129- private volatile Range range = new Range (0 ,0 );
130-
131126 /**
132127 * Creates a new background content provider
133128 *
@@ -307,42 +302,35 @@ private void doSort(IProgressMonitor mon) {
307302 break ;
308303 }
309304
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 ;
316308
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+ }
323312
324- Object [] objectsOfInterest = new Object [sortLength ];
313+ sortLength = Math .min (sortLength , totalElements - sortStart );
314+ sortLength = Math .max (sortLength , 0 );
325315
326- collection . getRange ( objectsOfInterest , sortStart , true , sortMon ) ;
316+ Object [] objectsOfInterest = new Object [ sortLength ] ;
327317
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 );
333319
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+ }
335325
336- collection . getFirst ( objectsOfInterest , true , sortMon ) ;
326+ objectsOfInterest = new Object [ collection . size ()] ;
337327
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 );
343329
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 );
346334 }
347335
348336 dirty = false ;
@@ -371,7 +359,6 @@ private static void filteredAdd(LazySortedCollection collection, Object[] toAdd,
371359 public void setSortOrder (Comparator sorter ) {
372360 Assert .isNotNull (sorter );
373361 this .sortOrder = sorter ;
374- sortMon .cancel ();
375362 refresh ();
376363 }
377364
@@ -383,7 +370,6 @@ public void setSortOrder(Comparator sorter) {
383370 public void setFilter (IFilter toSet ) {
384371 Assert .isNotNull (toSet );
385372 this .filter = toSet ;
386- sortMon .cancel ();
387373 refresh ();
388374 }
389375
@@ -417,13 +403,6 @@ public int getLimit() {
417403 */
418404 public void checkVisibleRange (int includeIndex ) {
419405 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- }
427406 }
428407
429408 /**
@@ -475,7 +454,6 @@ public void run() {
475454 */
476455 private void makeDirty () {
477456 synchronized (lock ) {
478- sortMon .cancel ();
479457 // request sorting
480458 sortScheduled = true ;
481459 if (!sortThreadStarted ) {
@@ -495,7 +473,6 @@ private void makeDirty() {
495473 * ways.
496474 */
497475 private void cancelSortJob () {
498- sortMon .cancel ();
499476 sortingProgressMonitor .setCanceled (true );
500477 }
501478
0 commit comments