Bug 28250 opening a file calls getImage 2 times on packageExplorer's label provider [package explorer]
20021210 what is the reason for the package explorer to update its labels on opening/closing files? No resource has changed, nothing really happened - but stuff gets updated anyhow. it's called twice on opening and once on closing closing: Thread [main] (Suspended (breakpoint at line 67 in org.eclipse.jface.viewers.DecoratingLabelProvider)) org.eclipse.jface.viewers.DecoratingLabelProvider.getImage (java.lang.Object) line: 67 org.eclipse.jdt.internal.ui.packageview.PackageExplorerPart$4 (org.eclipse.jface.viewers.TreeViewer).doUpdateItem (org.eclipse.swt.widgets.Item, java.lang.Object) line: 83 org.eclipse.jdt.internal.ui.packageview.PackageExplorerPart$4 (org.eclipse.jface.viewers.AbstractTreeViewer).doUpdateItem (org.eclipse.swt.widgets.Widget, java.lang.Object, boolean) line: 363 org.eclipse.jdt.internal.ui.packageview.PackageExplorerPart$4 (org.eclipse.jface.viewers.StructuredViewer).updateItem (org.eclipse.swt.widgets.Widget, java.lang.Object) line: 1132 org.eclipse.jdt.internal.ui.packageview.PackageExplorerPart$4 (org.eclipse.jface.viewers.AbstractTreeViewer).internalRefresh (org.eclipse.swt.widgets.Widget, java.lang.Object, boolean) line: 843 org.eclipse.jdt.internal.ui.packageview.PackageExplorerPart$4 (org.eclipse.jface.viewers.AbstractTreeViewer).internalRefresh (java.lang.Object) line: 826 org.eclipse.jface.viewers.StructuredViewer$4.run() line: 744 org.eclipse.jdt.internal.ui.packageview.PackageExplorerPart$4 (org.eclipse.jface.viewers.StructuredViewer).preservingSelection (java.lang.Runnable) line: 684 org.eclipse.jdt.internal.ui.packageview.PackageExplorerPart$4 (org.eclipse.jface.viewers.StructuredViewer).refresh(java.lang.Object) line: 742 org.eclipse.jdt.internal.ui.packageview.PackageExplorerContentProvider$3 .run() line: 440 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: 1403 org.eclipse.ui.internal.Workbench.run(java.lang.Object) line: 1386 org.eclipse.core.internal.boot.InternalBootLoader.run(java.lang.String, java.net.URL, java.lang.String, java.lang.String[], java.lang.Runnable) line: 840 org.eclipse.core.boot.BootLoader.run(java.lang.String, java.net.URL, java.lang.String, java.lang.String[], java.lang.Runnable) line: 462 sun.reflect.NativeMethodAccessorImpl.invoke0(java.lang.reflect.Method, java.lang.Object, java.lang.Object[]) line: not available [native method] sun.reflect.NativeMethodAccessorImpl.invoke(java.lang.Object, java.lang.Object[]) line: 39 sun.reflect.DelegatingMethodAccessorImpl.invoke(java.lang.Object, java.lang.Object[]) line: 25 java.lang.reflect.Method.invoke(java.lang.Object, java.lang.Object[]) line: 324 org.eclipse.core.launcher.Main.basicRun(java.lang.String[]) line: 247 org.eclipse.core.launcher.Main.run(java.lang.String[]) line: 703 org.eclipse.core.launcher.Main.main(java.lang.String[]) line: 539 ---------------------------- opening 1 : Thread [main] (Suspended (breakpoint at line 67 in org.eclipse.jface.viewers.DecoratingLabelProvider)) org.eclipse.jface.viewers.DecoratingLabelProvider.getImage (java.lang.Object) line: 67 org.eclipse.jdt.internal.ui.packageview.PackageExplorerPart$4 (org.eclipse.jface.viewers.TreeViewer).doUpdateItem (org.eclipse.swt.widgets.Item, java.lang.Object) line: 83 org.eclipse.jdt.internal.ui.packageview.PackageExplorerPart$4 (org.eclipse.jface.viewers.AbstractTreeViewer).doUpdateItem (org.eclipse.swt.widgets.Widget, java.lang.Object, boolean) line: 363 org.eclipse.jdt.internal.ui.packageview.PackageExplorerPart$4 (org.eclipse.jface.viewers.StructuredViewer).updateItem (org.eclipse.swt.widgets.Widget, java.lang.Object) line: 1132 org.eclipse.jdt.internal.ui.packageview.PackageExplorerPart$4 (org.eclipse.jface.viewers.AbstractTreeViewer).internalRefresh (org.eclipse.swt.widgets.Widget, java.lang.Object, boolean) line: 843 org.eclipse.jdt.internal.ui.packageview.PackageExplorerPart$4 (org.eclipse.jface.viewers.AbstractTreeViewer).internalRefresh (java.lang.Object) line: 826 org.eclipse.jface.viewers.StructuredViewer$4.run() line: 744 org.eclipse.jdt.internal.ui.packageview.PackageExplorerPart$4 (org.eclipse.jface.viewers.StructuredViewer).preservingSelection (java.lang.Runnable) line: 684 org.eclipse.jdt.internal.ui.packageview.PackageExplorerPart$4 (org.eclipse.jface.viewers.StructuredViewer).refresh(java.lang.Object) line: 742 org.eclipse.jdt.internal.ui.packageview.PackageExplorerContentProvider$3 .run() line: 440 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.jface.operation.ModalContext$ModalContextThread.block() line: 130 org.eclipse.jface.operation.ModalContext.run (org.eclipse.jface.operation.IRunnableWithProgress, boolean, org.eclipse.core.runtime.IProgressMonitor, org.eclipse.swt.widgets.Display) line: 255 org.eclipse.jface.window.ApplicationWindow$1.run() line: 409 org.eclipse.swt.custom.BusyIndicator.showWhile (org.eclipse.swt.widgets.Display, java.lang.Runnable) line: 65 org.eclipse.ui.internal.WorkbenchWindow (org.eclipse.jface.window.ApplicationWindow).run(boolean, boolean, org.eclipse.jface.operation.IRunnableWithProgress) line: 406 org.eclipse.ui.internal.WorkbenchWindow.run(boolean, boolean, org.eclipse.jface.operation.IRunnableWithProgress) line: 1147 org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitEditor (org.eclipse.ui.texteditor.AbstractTextEditor).internalInit (org.eclipse.ui.IWorkbenchWindow, org.eclipse.ui.IEditorSite, org.eclipse.ui.IEditorInput) line: 1774 org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitEditor (org.eclipse.ui.texteditor.AbstractTextEditor).init(org.eclipse.ui.IEditorSite, org.eclipse.ui.IEditorInput) line: 1791 org.eclipse.ui.internal.EditorManager.createSite (org.eclipse.ui.IEditorPart, org.eclipse.ui.internal.registry.EditorDescriptor, org.eclipse.ui.IEditorInput) line: 571 org.eclipse.ui.internal.EditorManager.openInternalEditor (org.eclipse.ui.IEditorReference, org.eclipse.ui.internal.registry.EditorDescriptor, org.eclipse.ui.IEditorInput, boolean) line: 621 org.eclipse.ui.internal.EditorManager.openEditorFromDescriptor (org.eclipse.ui.IEditorReference, org.eclipse.ui.internal.registry.EditorDescriptor, org.eclipse.ui.IEditorInput, boolean) line: 429 org.eclipse.ui.internal.EditorManager.openEditorFromInput (org.eclipse.ui.IEditorReference, org.eclipse.ui.IEditorInput, boolean, boolean) line: 303 org.eclipse.ui.internal.EditorManager.openEditor(java.lang.String, org.eclipse.ui.IEditorInput, boolean, boolean) line: 394 org.eclipse.ui.internal.WorkbenchPage.openEditor (org.eclipse.ui.IEditorInput, java.lang.String, boolean, boolean, org.eclipse.core.resources.IFile, boolean) line: 1863 org.eclipse.ui.internal.WorkbenchPage.openEditor (org.eclipse.core.resources.IFile, java.lang.String, boolean) line: 1700 org.eclipse.jdt.internal.ui.javaeditor.EditorUtility.openInEditor (org.eclipse.core.resources.IFile, boolean) line: 129 org.eclipse.jdt.internal.ui.javaeditor.EditorUtility.openInEditor (java.lang.Object, boolean) line: 107 org.eclipse.jdt.internal.ui.actions.OpenActionUtil.open (java.lang.Object, boolean) line: 47 org.eclipse.jdt.ui.actions.OpenAction.run(java.lang.Object[]) line: 157 org.eclipse.jdt.ui.actions.OpenAction.run (org.eclipse.jface.viewers.IStructuredSelection) line: 146 org.eclipse.jdt.ui.actions.OpenAction (org.eclipse.jdt.ui.actions.SelectionDispatchAction).dispatchRun (org.eclipse.jface.viewers.ISelection) line: 191 org.eclipse.jdt.ui.actions.OpenAction (org.eclipse.jdt.ui.actions.SelectionDispatchAction).run() line: 169 org.eclipse.jdt.internal.ui.packageview.PackageExplorerActionGroup.handl eOpen(org.eclipse.jface.viewers.OpenEvent) line: 325 org.eclipse.jdt.internal.ui.packageview.PackageExplorerPart$3.open (org.eclipse.jface.viewers.OpenEvent) line: 298 org.eclipse.jdt.internal.ui.packageview.PackageExplorerPart$4 (org.eclipse.jface.viewers.StructuredViewer).fireOpen (org.eclipse.jface.viewers.OpenEvent) line: 316 org.eclipse.jdt.internal.ui.packageview.PackageExplorerPart$4 (org.eclipse.jface.viewers.StructuredViewer).handleOpen (org.eclipse.swt.events.SelectionEvent) line: 490 org.eclipse.jface.viewers.StructuredViewer$3.handleOpen (org.eclipse.swt.events.SelectionEvent) line: 577 org.eclipse.jface.util.OpenStrategy.fireOpenEvent (org.eclipse.swt.events.SelectionEvent) line: 203 org.eclipse.jface.util.OpenStrategy.access$2 (org.eclipse.jface.util.OpenStrategy, org.eclipse.swt.events.SelectionEvent) line: 198 org.eclipse.jface.util.OpenStrategy$1.handleEvent (org.eclipse.swt.widgets.Event) line: 227 org.eclipse.swt.widgets.EventTable.sendEvent (org.eclipse.swt.widgets.Event) line: 77 org.eclipse.swt.widgets.Tree(org.eclipse.swt.widgets.Widget).sendEvent (org.eclipse.swt.widgets.Event) line: 825 org.eclipse.swt.widgets.Display.runDeferredEvents() line: 1692 org.eclipse.swt.widgets.Display.readAndDispatch() line: 1410 org.eclipse.ui.internal.Workbench.runEventLoop() line: 1403 org.eclipse.ui.internal.Workbench.run(java.lang.Object) line: 1386 org.eclipse.core.internal.boot.InternalBootLoader.run(java.lang.String, java.net.URL, java.lang.String, java.lang.String[], java.lang.Runnable) line: 840 org.eclipse.core.boot.BootLoader.run(java.lang.String, java.net.URL, java.lang.String, java.lang.String[], java.lang.Runnable) line: 462 sun.reflect.NativeMethodAccessorImpl.invoke0(java.lang.reflect.Method, java.lang.Object, java.lang.Object[]) line: not available [native method] sun.reflect.NativeMethodAccessorImpl.invoke(java.lang.Object, java.lang.Object[]) line: 39 sun.reflect.DelegatingMethodAccessorImpl.invoke(java.lang.Object, java.lang.Object[]) line: 25 java.lang.reflect.Method.invoke(java.lang.Object, java.lang.Object[]) line: 324 org.eclipse.core.launcher.Main.basicRun(java.lang.String[]) line: 247 org.eclipse.core.launcher.Main.run(java.lang.String[]) line: 703 org.eclipse.core.launcher.Main.main(java.lang.String[]) line: 539 ------------------------ opening 2: Thread [main] (Suspended (breakpoint at line 67 in org.eclipse.jface.viewers.DecoratingLabelProvider)) org.eclipse.jface.viewers.DecoratingLabelProvider.getImage (java.lang.Object) line: 67 org.eclipse.jdt.internal.ui.viewsupport.ResourceToItemsMapper.updateItem (org.eclipse.swt.widgets.Item) line: 65 org.eclipse.jdt.internal.ui.viewsupport.ResourceToItemsMapper.resourceCh anged(org.eclipse.core.resources.IResource) line: 50 org.eclipse.jdt.internal.ui.packageview.PackageExplorerPart$4 (org.eclipse.jdt.internal.ui.viewsupport.ProblemTreeViewer).handleLabelProviderC hanged(org.eclipse.jface.viewers.LabelProviderChangedEvent) line: 120 org.eclipse.jface.viewers.ContentViewer$1.labelProviderChanged (org.eclipse.jface.viewers.LabelProviderChangedEvent) line: 68 org.eclipse.ui.internal.decorators.DecoratorManager.fireListeners (org.eclipse.jface.viewers.LabelProviderChangedEvent) line: 145 org.eclipse.ui.internal.decorators.DecoratorManager.labelProviderChanged (org.eclipse.jface.viewers.LabelProviderChangedEvent) line: 434 org.eclipse.jdt.ui.ProblemsLabelDecorator.fireProblemsChanged (org.eclipse.core.resources.IResource[], boolean) line: 338 org.eclipse.jdt.ui.ProblemsLabelDecorator.access$0 (org.eclipse.jdt.ui.ProblemsLabelDecorator, org.eclipse.core.resources.IResource [], boolean) line: 333 org.eclipse.jdt.ui.ProblemsLabelDecorator$1.problemsChanged (org.eclipse.core.resources.IResource[], boolean) line: 313 org.eclipse.jdt.internal.ui.viewsupport.ProblemMarkerManager$1.run() line: 177 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: 1403 org.eclipse.ui.internal.Workbench.run(java.lang.Object) line: 1386 org.eclipse.core.internal.boot.InternalBootLoader.run(java.lang.String, java.net.URL, java.lang.String, java.lang.String[], java.lang.Runnable) line: 840 org.eclipse.core.boot.BootLoader.run(java.lang.String, java.net.URL, java.lang.String, java.lang.String[], java.lang.Runnable) line: 462 sun.reflect.NativeMethodAccessorImpl.invoke0(java.lang.reflect.Method, java.lang.Object, java.lang.Object[]) line: not available [native method] sun.reflect.NativeMethodAccessorImpl.invoke(java.lang.Object, java.lang.Object[]) line: 39 sun.reflect.DelegatingMethodAccessorImpl.invoke(java.lang.Object, java.lang.Object[]) line: 25 java.lang.reflect.Method.invoke(java.lang.Object, java.lang.Object[]) line: 324 org.eclipse.core.launcher.Main.basicRun(java.lang.String[]) line: 247 org.eclipse.core.launcher.Main.run(java.lang.String[]) line: 703 org.eclipse.core.launcher.Main.main(java.lang.String[]) line: 539
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/packageview/PackageExplorerContentProvider.java
}
				return;
			}
			
			if (element instanceof IPackageFragmentRoot)
				postRefresh(skipProjectPackageFragmentRoot((IPackageFragmentRoot)element));
			else
				postRefresh(element);
			return;
		}
		processAffectedChildren(affectedChildren);
	}
	
	protected void processAffectedChildren(IJavaElementDelta[] affectedChildren) throws JavaModelException {
		for (int i= 0; i < affectedChildren.length; i++) {
			processDelta(affectedChildren[i]);
		}
	}
	private boolean isOnClassPath(ICompilationUnit element) throws JavaModelException {
		IJavaProject project= element.getJavaProject();
		if (project == null || !project.exists())
			return false;
		return project.isOnClasspath(element);
	}
	/**
	 * Updates the selection. It finds newly added elements
	 * and selects them.
	 */
	private void updateSelection(IJavaElementDelta delta) {
		final IJavaElement addedElement= findAddedElement(delta);