Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,12 @@

import java.util.Comparator;

import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.core.runtime.Assert;
import org.eclipse.jface.viewers.AcceptAllFilter;
import org.eclipse.jface.viewers.IFilter;
import org.eclipse.jface.viewers.deferred.ConcurrentTableUpdator.Range;

/**
* Contains the algorithm for performing background sorting and filtering in a virtual
Expand Down Expand Up @@ -124,10 +123,6 @@ public void update(Object[] changed) {
private IProgressMonitor sortingProgressMonitor = new NullProgressMonitor();
private Thread sortThread = null;

private volatile FastProgressReporter sortMon = new FastProgressReporter();

private volatile Range range = new Range(0,0);

/**
* Creates a new background content provider
*
Expand Down Expand Up @@ -307,42 +302,35 @@ private void doSort(IProgressMonitor mon) {
break;
}

try {
ConcurrentTableUpdator.Range updateRange = updator.getVisibleRange();
sortMon = new FastProgressReporter();
range = updateRange;
int sortStart = updateRange.start;
int sortLength = updateRange.length;
ConcurrentTableUpdator.Range updateRange = updator.getVisibleRange();
int sortStart = updateRange.start;
int sortLength = updateRange.length;

if (limit != -1) {
collection.retainFirst(limit, sortMon);
}

sortLength = Math.min(sortLength, totalElements - sortStart);
sortLength = Math.max(sortLength, 0);
if (limit != -1) {
collection.retainFirst(limit);
}

Object[] objectsOfInterest = new Object[sortLength];
sortLength = Math.min(sortLength, totalElements - sortStart);
sortLength = Math.max(sortLength, 0);

collection.getRange(objectsOfInterest, sortStart, true, sortMon);
Object[] objectsOfInterest = new Object[sortLength];

// Send the new elements to the table
for (int i = 0; i < sortLength; i++) {
Object object = objectsOfInterest[i];
updator.replace(object, sortStart + i);
}
collection.getRange(objectsOfInterest, sortStart, true);

objectsOfInterest = new Object[collection.size()];
// Send the new elements to the table
for (int i = 0; i < sortLength; i++) {
Object object = objectsOfInterest[i];
updator.replace(object, sortStart + i);
}

collection.getFirst(objectsOfInterest, true, sortMon);
objectsOfInterest = new Object[collection.size()];

// Send the new elements to the table
for (int i = 0; i < totalElements; i++) {
Object object = objectsOfInterest[i];
updator.replace(object, i);
}
collection.getFirst(objectsOfInterest, true);

} catch (InterruptedException e) {
continue;
// Send the new elements to the table
for (int i = 0; i < totalElements; i++) {
Object object = objectsOfInterest[i];
updator.replace(object, i);
}

dirty = false;
Expand Down Expand Up @@ -371,7 +359,6 @@ private static void filteredAdd(LazySortedCollection collection, Object[] toAdd,
public void setSortOrder(Comparator sorter) {
Assert.isNotNull(sorter);
this.sortOrder = sorter;
sortMon.cancel();
refresh();
}

Expand All @@ -383,7 +370,6 @@ public void setSortOrder(Comparator sorter) {
public void setFilter(IFilter toSet) {
Assert.isNotNull(toSet);
this.filter = toSet;
sortMon.cancel();
refresh();
}

Expand Down Expand Up @@ -417,13 +403,6 @@ public int getLimit() {
*/
public void checkVisibleRange(int includeIndex) {
updator.checkVisibleRange(includeIndex);
ConcurrentTableUpdator.Range newRange = updator.getVisibleRange();
ConcurrentTableUpdator.Range oldRange = range;

// If we're in the middle of processing an invalid range, cancel the sort
if (newRange.start != oldRange.start || newRange.length != oldRange.length) {
sortMon.cancel();
}
}

/**
Expand Down Expand Up @@ -475,7 +454,6 @@ public void run() {
*/
private void makeDirty() {
synchronized (lock) {
sortMon.cancel();
// request sorting
sortScheduled = true;
if (!sortThreadStarted) {
Expand All @@ -495,7 +473,6 @@ private void makeDirty() {
* ways.
*/
private void cancelSortJob() {
sortMon.cancel();
sortingProgressMonitor.setCanceled(true);
}

Expand Down

This file was deleted.

Loading
Loading