Bug 395502 - Test failures in UIAllTests

Fix PartServiceImpl to mark EContextService as @Optional, introduced
as part of bug 390379.  Fix PartRenderingEngine to add missing
not-null test.
diff --git a/bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/internal/workbench/swt/PartRenderingEngine.java b/bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/internal/workbench/swt/PartRenderingEngine.java
index 9851458..d439b66 100644
--- a/bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/internal/workbench/swt/PartRenderingEngine.java
+++ b/bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/internal/workbench/swt/PartRenderingEngine.java
@@ -1014,10 +1014,9 @@
 					};
 				}
 				// Spin the event loop until someone disposes the display
-				while (((testShell != null && !testShell.isDisposed()) || (!theApp
-						.getChildren().isEmpty() && someAreVisible(theApp
-						.getChildren())))
-						&& !display.isDisposed()) {
+				while (((testShell != null && !testShell.isDisposed()) || (theApp != null
+						&& !theApp.getChildren().isEmpty() && someAreVisible(theApp
+							.getChildren()))) && !display.isDisposed()) {
 					try {
 						if (!display.readAndDispatch()) {
 							runContext.processWaiting();
diff --git a/bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/ui/internal/workbench/PartServiceImpl.java b/bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/ui/internal/workbench/PartServiceImpl.java
index 89df348..2a6159a 100644
--- a/bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/ui/internal/workbench/PartServiceImpl.java
+++ b/bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/ui/internal/workbench/PartServiceImpl.java
@@ -126,7 +126,9 @@
 	@Inject
 	private IEventBroker eventBroker;
 
+	// @Optional as the context service may not have been installed
 	@Inject
+	@Optional
 	private EContextService contextService;
 
 	private PartActivationHistory partActivationHistory;
@@ -548,7 +550,9 @@
 			UIEvents.publishEvent(UIEvents.UILifeCycle.ACTIVATE, part);
 			return;
 		}
-		contextService.deferUpdates(true);
+		if (contextService != null) {
+			contextService.deferUpdates(true);
+		}
 		try {
 			// record any sibling into the activation history if necessary, this will allow it to be
 			// reselected again in the future as it will be an activation candidate in the future,
@@ -578,7 +582,9 @@
 				}
 			}
 		} finally {
-			contextService.deferUpdates(false);
+			if (contextService != null) {
+				contextService.deferUpdates(false);
+			}
 		}
 	}