Project: JDT
Bug 156239 [CommonNavigator][Java] PackageExplorerContentProvider forces unnecessary refreshes in working set mode
Reported: 2006-09-05 14:25:55 | Status: verified fixed

The test case here has two working sets, each containing several projects, displayed in the Project Explorer, with "Show Top Level Elements" set to "Working Sets". Whenever a Java type is opened, the Java type in the viewer "becomes" a working copy, which causes the PackageExplorerContentProvider to respond in its elementChanged() method. Currently, elementChanged() first checks if the input was deleted (PackageExplorerContentProvider.inputDeleted()). If inputDeleted() returns true, then it forces a complete refresh of the viewer. This causes jumpiness if the viewer is scrolled outside of the scope of the current selection. The inputDeleted() method is already updated for the JDT WorkingSetModel: private boolean inputDeleted() { if (fInput == null) return false; if ((fInput instanceof IJavaElement) && ((IJavaElement) fInput).exists()) return false; if ((fInput instanceof IResource) && ((IResource) fInput).exists()) return false; if (fInput instanceof WorkingSetModel) return false; postRefresh(fInput, ORIGINAL, fInput); return true; } However, as of 3.2.1, the Project Explorer supports working sets, using the Platform/UI's support for the IWorkingSet API. Because the PackageExplorerContentProvider doesn't recognize IWorkingSet and return false, the viewer is structurally refreshed for each opened Java file. Instead, the inputDeleted() method should check for IWorkingSet: private boolean inputDeleted() { if (fInput == null) return false; if ((fInput instanceof IJavaElement) && ((IJavaElement) fInput).exists()) return false; if ((fInput instanceof IResource) && ((IResource) fInput).exists()) return false; if (fInput instanceof WorkingSetModel) return false; if (fInput instanceof IWorkingSet) return false; postRefresh(fInput, ORIGINAL, fInput); return true; } I will attach a patch.

Files changed in fix:
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/packageview/PackageExplorerContentProvider.java