Bug 26409 - AbstractFilter incorrectly implements isFilterProperty
Summary: AbstractFilter incorrectly implements isFilterProperty
Status: RESOLVED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 2.1   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 2.1 M4   Edit
Assignee: Dani Megert CLA
QA Contact:
URL:
Whiteboard:
Keywords: performance
Depends on:
Blocks:
 
Reported: 2002-11-14 14:53 EST by Nick Edgar CLA
Modified: 2002-11-18 08:33 EST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Nick Edgar CLA 2002-11-14 14:53:28 EST
build I20021114

AbstractFilter.isFilterProperty returns true for the text and image properties.
This is incorrect and results in unnecessary refreshes in the Package Explorer.

isFilterProperty should only return true for properties that can affect the 
filtering result if their value changes.  That is, it should correspond to the 
properties used in the select method.  
(Likewise for ViewerSorter.isSorterProperty.)

Here is a stack trace of an unnecessary full refresh caused by 
EmptyInnerPackageFilter.isFilterProperty returning true for the image property:

Thread [main] (Suspended)
	org.eclipse.jdt.internal.ui.packageview.PackageExplorerPart$4
(org.eclipse.jface.viewers.StructuredViewer).refresh() line: 704
	org.eclipse.jdt.internal.ui.packageview.PackageExplorerPart$4
(org.eclipse.jface.viewers.StructuredViewer).update(java.lang.Object, 
java.lang.String[]) line: 1099
	org.eclipse.jdt.internal.ui.packageview.PackageExplorerContentProvider$2
.run() line: 365
	org.eclipse.swt.widgets.RunnableLock.run() line: 31
	org.eclipse.ui.internal.UISynchronizer
(org.eclipse.swt.widgets.Synchronizer).runAsyncMessages() line: 94
	org.eclipse.swt.widgets.Display.runAsyncMessages() line: 1669
	org.eclipse.swt.widgets.Display.readAndDispatch() line: 1414
	org.eclipse.ui.internal.Workbench.runEventLoop() line: 1435
	org.eclipse.ui.internal.Workbench.run(java.lang.Object) line: 1418
	org.eclipse.core.internal.boot.InternalBootLoader.run(java.lang.String, 
java.net.URL, java.lang.String, java.lang.String[], java.lang.Runnable) line: 
831
	org.eclipse.core.boot.BootLoader.run(java.lang.String, java.net.URL, 
java.lang.String, java.lang.String[]) line: 432
	EclipseRuntimeLauncher.main(java.lang.String[]) line: 24

The steps that caused this can be found in comment #13 of bug 3840 (I was 
deleting Class 1), leaving an empty default package.
Comment 1 Nick Edgar CLA 2002-11-14 14:53:45 EST
The extra refreshes are a performance hit.
Comment 2 Nick Edgar CLA 2002-11-14 14:55:05 EST
The call to update in the stack above is in 
PackageExplorerContentProvider.postUpdateIcon.
Comment 3 Nick Edgar CLA 2002-11-14 15:01:49 EST
This is being called by processDelta, which also tries to handle the switch to 
an empty package (after attempting to update the icon).  
The icon will be updated by the call to refresh the parent anyway.

(I also noticed that this calls element.getParent() in one place and 
internalGetParent(parent) elsewhere, that internalGetParent(parent) is called 
twice here, and that the call to isPackageFragmentEmpty is outside the 
instanceof IPackageFragment check.  Not sure if any of these are real problems.)




Comment 4 Erich Gamma CLA 2002-11-16 16:35:20 EST
analysis is correct filters should no never depend on the label or the image.

I've removed the override and left the base class in for now. 

The calls of getParent vs. getInternalParent are OK. The reason for this 
complexity is caused by the Java Model's representations of the project's 
package fragment root that we have to filter out in the content provider.
Comment 5 Dani Megert CLA 2002-11-18 08:33:41 EST
Cleaned up code; removed AbstractFilter