Bug 44413 [misc] Exception while deleting a project
20031008 smoke After the smoke, I wanted to remove the project but this failed: The project was not removed. Java Model Exception: Java Model Status [junit.tests [in <project root> [in JUnit]] does not exist.] at org.eclipse.jdt.internal.core.JavaElement.newNotPresentException (JavaElement.java:476) at org.eclipse.jdt.internal.core.PackageFragment.buildStructure (PackageFragment.java:61) at org.eclipse.jdt.internal.core.Openable.generateInfos (Openable.java:200) at org.eclipse.jdt.internal.core.JavaElement.openWhenClosed (JavaElement.java:487) at org.eclipse.jdt.internal.core.JavaElement.getElementInfo (JavaElement.java:278) at org.eclipse.jdt.internal.core.JavaElement.getElementInfo (JavaElement.java:264) at org.eclipse.jdt.internal.core.JavaElement.getChildren (JavaElement.java:219) at org.eclipse.jdt.internal.core.Openable.hasChildren(Openable.java:302) at org.eclipse.jdt.ui.StandardJavaElementContentProvider.isPackageFragmentEmpty (StandardJavaElementContentProvider.java:370) at org.eclipse.jdt.internal.ui.packageview.PackageExplorerContentProvider.processDe lta(PackageExplorerContentProvider.java:314) at org.eclipse.jdt.internal.ui.packageview.PackageExplorerContentProvider.processAf fectedChildren(PackageExplorerContentProvider.java:416) at org.eclipse.jdt.internal.ui.packageview.PackageExplorerContentProvider.handleAff ectedChildren(PackageExplorerContentProvider.java:411) at org.eclipse.jdt.internal.ui.packageview.PackageExplorerContentProvider.processDe lta(PackageExplorerContentProvider.java:379) at org.eclipse.jdt.internal.ui.packageview.PackageExplorerContentProvider.processAf fectedChildren(PackageExplorerContentProvider.java:416) at org.eclipse.jdt.internal.ui.packageview.PackageExplorerContentProvider.handleAff ectedChildren(PackageExplorerContentProvider.java:411) at org.eclipse.jdt.internal.ui.packageview.PackageExplorerContentProvider.processDe lta(PackageExplorerContentProvider.java:379) at org.eclipse.jdt.internal.ui.packageview.PackageExplorerContentProvider.processAf fectedChildren(PackageExplorerContentProvider.java:416) at org.eclipse.jdt.internal.ui.packageview.PackageExplorerContentProvider.handleAff ectedChildren(PackageExplorerContentProvider.java:411) at org.eclipse.jdt.internal.ui.packageview.PackageExplorerContentProvider.processDe lta(PackageExplorerContentProvider.java:379) at org.eclipse.jdt.internal.ui.packageview.PackageExplorerContentProvider.processAf fectedChildren(PackageExplorerContentProvider.java:416) at org.eclipse.jdt.internal.ui.packageview.PackageExplorerContentProvider.handleAff ectedChildren(PackageExplorerContentProvider.java:411) at org.eclipse.jdt.internal.ui.packageview.PackageExplorerContentProvider.processDe lta(PackageExplorerContentProvider.java:379) at org.eclipse.jdt.internal.ui.packageview.PackageExplorerContentProvider.elementCh anged(PackageExplorerContentProvider.java:75) at org.eclipse.jdt.internal.core.DeltaProcessor$2.run (DeltaProcessor.java:1387) at org.eclipse.core.internal.runtime.InternalPlatform.run (InternalPlatform.java:1034) at org.eclipse.core.runtime.Platform.run(Platform.java:432) at org.eclipse.jdt.internal.core.DeltaProcessor.notifyListeners (DeltaProcessor.java:1382) at org.eclipse.jdt.internal.core.DeltaProcessor.firePostChangeDelta (DeltaProcessor.java:1226) at org.eclipse.jdt.internal.core.DeltaProcessor.fire (DeltaProcessor.java:1201) at org.eclipse.jdt.internal.core.JavaModelOperation.run (JavaModelOperation.java:725) at org.eclipse.jdt.internal.core.JavaElement.runOperation (JavaElement.java:523) at org.eclipse.jdt.internal.core.CompilationUnit.discardWorkingCopy (CompilationUnit.java:375) at org.eclipse.jdt.internal.ui.javaeditor.filebuffers.CompilationUnitDocumentProvid er2.disposeFileInfo(CompilationUnitDocumentProvider2.java:794) at org.eclipse.ui.editors.text.TextFileDocumentProvider.disconnect (TextFileDocumentProvider.java:435) at org.eclipse.ui.texteditor.AbstractTextEditor.dispose (AbstractTextEditor.java:2636) at org.eclipse.ui.texteditor.ExtendedTextEditor.dispose (ExtendedTextEditor.java:177) at org.eclipse.jdt.internal.ui.javaeditor.JavaEditor.dispose (JavaEditor.java:2139) at org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitEditor.dispose (CompilationUnitEditor.java:1065) at org.eclipse.ui.internal.WorkbenchPartReference.dispose (WorkbenchPartReference.java:160) at org.eclipse.ui.internal.EditorManager$Editor.dispose (EditorManager.java:1322) at org.eclipse.ui.internal.WorkbenchPage$5.run(WorkbenchPage.java:1046) at org.eclipse.core.internal.runtime.InternalPlatform.run (InternalPlatform.java:1034) at org.eclipse.core.runtime.Platform.run(Platform.java:432) at org.eclipse.ui.internal.WorkbenchPage.disposePart (WorkbenchPage.java:1044) at org.eclipse.ui.internal.WorkbenchPage.closeEditor (WorkbenchPage.java:850) at org.eclipse.ui.texteditor.AbstractTextEditor$15.run (AbstractTextEditor.java:2539) at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35) at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages (Synchronizer.java:102) at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:2150) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:1867) at org.eclipse.jface.operation.ModalContext$ModalContextThread.block (ModalContext.java:136) at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:261) at org.eclipse.jface.dialogs.ProgressMonitorDialog.run (ProgressMonitorDialog.java:386) at org.eclipse.ui.actions.DeleteResourceAction.run (DeleteResourceAction.java:388) at org.eclipse.jdt.internal.ui.refactoring.reorg.DeleteAction.run (DeleteAction.java:87) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.dispatchRun (SelectionDispatchAction.java:194) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.run (SelectionDispatchAction.java:172) at org.eclipse.jdt.internal.ui.packageview.PackageExplorerActionGroup.handleKeyEven t(PackageExplorerActionGroup.java:332) at org.eclipse.jdt.internal.ui.packageview.PackageExplorerPart$9.keyReleased (PackageExplorerPart.java:923) at org.eclipse.swt.widgets.TypedListener.handleEvent (TypedListener.java:124) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:847) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:871) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:856) at org.eclipse.swt.widgets.Control.sendKeyEvent(Control.java:1689) at org.eclipse.swt.widgets.Control.sendKeyEvent(Control.java:1685) at org.eclipse.swt.widgets.Control.WM_KEYUP(Control.java:3514) at org.eclipse.swt.widgets.Control.windowProc(Control.java:2916) at org.eclipse.swt.widgets.Display.windowProc(Display.java:2698) at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method) at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:1345) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:1861) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2315) at org.eclipse.ui.internal.Workbench.run(Workbench.java:2298) at org.eclipse.core.internal.boot.InternalBootLoader.run (InternalBootLoader.java:858) at org.eclipse.core.boot.BootLoader.run(BootLoader.java:461) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:324) at org.eclipse.core.launcher.Main.basicRun(Main.java:298) at org.eclipse.core.launcher.Main.run(Main.java:764) at org.eclipse.core.launcher.Main.main(Main.java:598)
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/packageview/PackageExplorerContentProvider.java
addPendingChange();
			try {
				ctrl.getDisplay().asyncExec(trackedRunnable); 
			} catch (RuntimeException e) {
				removePendingChange();
				throw e;
			} catch (Error e) {
				removePendingChange();
				throw e; 
			}
		}
	}
	
	
	public synchronized boolean hasPendingChanges() {
		return fPendingChanges > 0;  
	}
	
	private synchronized void addPendingChange() {
		fPendingChanges++;
		
	}
	private synchronized void removePendingChange() {
		fPendingChanges--;
		if (fPendingChanges < 0)
			fPendingChanges= 0;
		
	}
}