[cleanup] Combine nested 'if' within 'else' block to 'else if'

Cleanup performed on bundles
- org.eclipse.e4.ui.workbench.renderers.swt
- org.eclipse.e4.ui.workbench.swt

Signed-off-by: Karsten Thoms <karsten.thoms@karakun.com>
Change-Id: I95ed00b8fca59dbd78c2741bc57fe8bb7d8a35e5
Reviewed-on: https://git.eclipse.org/r/c/platform/eclipse.platform.ui/+/172226
Tested-by: Platform Bot <platform-bot@eclipse.org>
Reviewed-by: Alexander Kurtakov <akurtako@redhat.com>
diff --git a/bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/workbench/renderers/swt/CTabRendering.java b/bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/workbench/renderers/swt/CTabRendering.java
index c909e6e..0b0f985 100644
--- a/bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/workbench/renderers/swt/CTabRendering.java
+++ b/bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/workbench/renderers/swt/CTabRendering.java
@@ -611,10 +611,8 @@
 			} else {
 				gc.drawPolyline(shape);
 			}
-		} else {
-			if (!onBottom) {
-				gc.drawLine(startX, 0, endX, 0);
-			}
+		} else if (!onBottom) {
+			gc.drawLine(startX, 0, endX, 0);
 		}
 
 		if (selectedTabHighlightColor != null) {
@@ -1266,12 +1264,10 @@
 					}
 				}
 			}
-		} else {
-			// draw a solid background using default background in shape
-			if ((parent.getStyle() & SWT.NO_BACKGROUND) != 0 || !defaultBackground.equals(parent.getBackground())) {
-				gc.setBackground(defaultBackground);
-				gc.fillRectangle(x, y, width, height);
-			}
+		} else // draw a solid background using default background in shape
+		if ((parent.getStyle() & SWT.NO_BACKGROUND) != 0 || !defaultBackground.equals(parent.getBackground())) {
+			gc.setBackground(defaultBackground);
+			gc.fillRectangle(x, y, width, height);
 		}
 	}
 
diff --git a/bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/workbench/renderers/swt/ElementReferenceRenderer.java b/bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/workbench/renderers/swt/ElementReferenceRenderer.java
index 35b0a18..907a91e 100644
--- a/bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/workbench/renderers/swt/ElementReferenceRenderer.java
+++ b/bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/workbench/renderers/swt/ElementReferenceRenderer.java
@@ -72,10 +72,8 @@
 				ref.setToBeRendered(true);
 				refWidget = (Control) renderingEngine.createGui(ref, newComp,
 						getContextForParent(ref));
-			} else {
-				if (refWidget.getParent() != newComp) {
-					refWidget.setParent(newComp);
-				}
+			} else if (refWidget.getParent() != newComp) {
+				refWidget.setParent(newComp);
 			}
 
 			if (ref instanceof MContext) {
@@ -114,72 +112,70 @@
 
 			renderingEngine.removeGui(refElement);
 			renderedMap.remove(refElement);
-		} else {
-			// Ensure that the dispose of the element reference doesn't cascade
-			// to dispose the 'real' part
-			if (refCtrl != null && !refCtrl.isDisposed()) {
-				MPlaceholder currentRef = refElement.getCurSharedRef();
-				if (currentRef == ph) {
-					// Find another *rendered* ref to pass the part on to
-					for (MPlaceholder aPH : refs) {
-						Composite phComp = (Composite) aPH.getWidget();
-						if (phComp == null || phComp.isDisposed())
-							continue;
-
-						// Reparent the context(s) (if any)
-						IEclipseContext newParentContext = modelService
-								.getContainingContext(aPH);
-						List<MContext> allContexts = modelService.findElements(refElement, null, MContext.class);
-						for (MContext ctxtElement : allContexts) {
-							IEclipseContext theContext = ctxtElement
-									.getContext();
-							// this may be null if it hasn't been rendered yet
-							if (theContext != null) {
-								if (theContext.getParent() == curContext) {
-									// about to reparent the context, if we're
-									// the active child of the current parent,
-									// deactivate ourselves first
-									if (curContext.getActiveChild() == theContext) {
-										theContext.deactivate();
-									}
-									theContext.setParent(newParentContext);
-								}
-							}
-						}
-
-						// reset the 'cur' ref
-						refElement.setCurSharedRef(aPH);
-
-						// Reparent the widget
-						refCtrl.setParent(phComp);
-						break;
-					}
-				} else if (currentRef != null) {
-					Composite phComp = (Composite) currentRef.getWidget();
-					if (phComp == null || phComp.isDisposed()) {
-						super.disposeWidget(element);
-						return;
-					}
+		} else // Ensure that the dispose of the element reference doesn't cascade
+		// to dispose the 'real' part
+		if (refCtrl != null && !refCtrl.isDisposed()) {
+			MPlaceholder currentRef = refElement.getCurSharedRef();
+			if (currentRef == ph) {
+				// Find another *rendered* ref to pass the part on to
+				for (MPlaceholder aPH : refs) {
+					Composite phComp = (Composite) aPH.getWidget();
+					if (phComp == null || phComp.isDisposed())
+						continue;
 
 					// Reparent the context(s) (if any)
 					IEclipseContext newParentContext = modelService
-							.getContainingContext(currentRef);
-					List<MContext> allContexts = modelService.findElements(
-							refElement, null, MContext.class);
+							.getContainingContext(aPH);
+					List<MContext> allContexts = modelService.findElements(refElement, null, MContext.class);
 					for (MContext ctxtElement : allContexts) {
-						IEclipseContext theContext = ctxtElement.getContext();
+						IEclipseContext theContext = ctxtElement
+								.getContext();
 						// this may be null if it hasn't been rendered yet
-						if (theContext != null
-								&& theContext.getParent() == curContext) {
-							// about to reparent the context, if we're the
-							// active child of the current parent, deactivate
-							// ourselves first
-							if (curContext.getActiveChild() == theContext) {
-								theContext.deactivate();
+						if (theContext != null) {
+							if (theContext.getParent() == curContext) {
+								// about to reparent the context, if we're
+								// the active child of the current parent,
+								// deactivate ourselves first
+								if (curContext.getActiveChild() == theContext) {
+									theContext.deactivate();
+								}
+								theContext.setParent(newParentContext);
 							}
-							theContext.setParent(newParentContext);
 						}
 					}
+
+					// reset the 'cur' ref
+					refElement.setCurSharedRef(aPH);
+
+					// Reparent the widget
+					refCtrl.setParent(phComp);
+					break;
+				}
+			} else if (currentRef != null) {
+				Composite phComp = (Composite) currentRef.getWidget();
+				if (phComp == null || phComp.isDisposed()) {
+					super.disposeWidget(element);
+					return;
+				}
+
+				// Reparent the context(s) (if any)
+				IEclipseContext newParentContext = modelService
+						.getContainingContext(currentRef);
+				List<MContext> allContexts = modelService.findElements(
+						refElement, null, MContext.class);
+				for (MContext ctxtElement : allContexts) {
+					IEclipseContext theContext = ctxtElement.getContext();
+					// this may be null if it hasn't been rendered yet
+					if (theContext != null
+							&& theContext.getParent() == curContext) {
+						// about to reparent the context, if we're the
+						// active child of the current parent, deactivate
+						// ourselves first
+						if (curContext.getActiveChild() == theContext) {
+							theContext.deactivate();
+						}
+						theContext.setParent(newParentContext);
+					}
 				}
 			}
 		}
diff --git a/bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/workbench/renderers/swt/SWTPartRenderer.java b/bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/workbench/renderers/swt/SWTPartRenderer.java
index cd2e387..5fb5e3f 100644
--- a/bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/workbench/renderers/swt/SWTPartRenderer.java
+++ b/bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/workbench/renderers/swt/SWTPartRenderer.java
@@ -369,11 +369,9 @@
 							"Trying to force focus for disposed control: " + element, new IllegalStateException()); //$NON-NLS-1$
 				}
 			}
-		} else {
-			if (Policy.DEBUG_FOCUS) {
-				WorkbenchSWTActivator.trace(Policy.DEBUG_FOCUS_FLAG,
-						"Trying to force focus for non-control element: " + element, new IllegalStateException()); //$NON-NLS-1$
-			}
+		} else if (Policy.DEBUG_FOCUS) {
+			WorkbenchSWTActivator.trace(Policy.DEBUG_FOCUS_FLAG,
+					"Trying to force focus for non-control element: " + element, new IllegalStateException()); //$NON-NLS-1$
 		}
 	}
 
diff --git a/bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/workbench/renderers/swt/ToolBarManagerRenderer.java b/bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/workbench/renderers/swt/ToolBarManagerRenderer.java
index 73fb37f..14e5db9 100644
--- a/bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/workbench/renderers/swt/ToolBarManagerRenderer.java
+++ b/bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/workbench/renderers/swt/ToolBarManagerRenderer.java
@@ -304,12 +304,10 @@
 		Selector s;
 		if (v instanceof Selector) {
 			s = (Selector) v;
+		} else if (v == null || UIEvents.ALL_ELEMENT_ID.equals(v)) {
+			s = ALL_SELECTOR;
 		} else {
-			if (v == null || UIEvents.ALL_ELEMENT_ID.equals(v)) {
-				s = ALL_SELECTOR;
-			} else {
-				s = element -> v.equals(element.getElementId());
-			}
+			s = element -> v.equals(element.getElementId());
 		}
 
 		getUpdater().updateContributionItems(s);
@@ -735,10 +733,8 @@
 		if (itemModel.isVisible() && !itemModel.getTags().contains(MenuManagerRenderer.GROUP_MARKER)) {
 			marker = new Separator();
 			marker.setId(itemModel.getElementId());
-		} else {
-			if (itemModel.getElementId() != null) {
-				marker = new GroupMarker(itemModel.getElementId());
-			}
+		} else if (itemModel.getElementId() != null) {
+			marker = new GroupMarker(itemModel.getElementId());
 		}
 		if (marker != null) {
 			addToManager(parentManager, itemModel, marker);
diff --git a/bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/workbench/renderers/swt/WBWRenderer.java b/bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/workbench/renderers/swt/WBWRenderer.java
index a575241..76bdd5c 100644
--- a/bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/workbench/renderers/swt/WBWRenderer.java
+++ b/bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/workbench/renderers/swt/WBWRenderer.java
@@ -233,10 +233,8 @@
 				boundsJob = new WindowSizeUpdateJob();
 				boundsJob.windowsToUpdate.add(windowModel);
 				theShell.getDisplay().asyncExec(boundsJob);
-			} else {
-				if (!boundsJob.windowsToUpdate.contains(windowModel)) {
-					boundsJob.windowsToUpdate.add(windowModel);
-				}
+			} else if (!boundsJob.windowsToUpdate.contains(windowModel)) {
+				boundsJob.windowsToUpdate.add(windowModel);
 			}
 		}
 	}
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 a98df28..00ac679 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
@@ -316,10 +316,8 @@
 							ctrl.requestLayout();
 						}
 					}
-				} else {
-					if (renderer != null && added.isToBeRendered()) {
-						renderer.childRendered(changedElement, added);
-					}
+				} else if (renderer != null && added.isToBeRendered()) {
+					renderer.childRendered(changedElement, added);
 				}
 
 				// If the element being added is a placeholder, check to see if it's 'globally
@@ -685,15 +683,13 @@
 					parentRenderer.childRendered(parentElement, element);
 				}
 			}
-		} else {
-			// failed to create the widget, dispose its context if necessary
-			if (element instanceof MContext) {
-				MContext ctxt = (MContext) element;
-				IEclipseContext lclContext = ctxt.getContext();
-				if (lclContext != null) {
-					lclContext.dispose();
-					ctxt.setContext(null);
-				}
+		} else // failed to create the widget, dispose its context if necessary
+		if (element instanceof MContext) {
+			MContext ctxt = (MContext) element;
+			IEclipseContext lclContext = ctxt.getContext();
+			if (lclContext != null) {
+				lclContext.dispose();
+				ctxt.setContext(null);
 			}
 		}
 
@@ -795,10 +791,8 @@
 			if (returnValue == defaultValue) {
 				// No @Focus method, force the focus
 				renderer.forceFocus(element);
-			} else {
-				if (Policy.DEBUG_FOCUS) {
-					WorkbenchSWTActivator.trace(Policy.DEBUG_FOCUS_FLAG, "Focused GUI on element: " + element, null); //$NON-NLS-1$
-				}
+			} else if (Policy.DEBUG_FOCUS) {
+				WorkbenchSWTActivator.trace(Policy.DEBUG_FOCUS_FLAG, "Focused GUI on element: " + element, null); //$NON-NLS-1$
 			}
 		} catch (InjectionException e) {
 			log("Failed to grant focus to element", "Failed to grant focus to element ({0})", //$NON-NLS-1$ //$NON-NLS-2$
@@ -1131,10 +1125,8 @@
 							StatusReporter statusReporter = appContext.get(StatusReporter.class);
 							if (statusReporter != null) {
 								statusReporter.show(StatusReporter.ERROR, "Internal Error", exception);
-							} else {
-								if (logger != null) {
-									logger.error(exception);
-								}
+							} else if (logger != null) {
+								logger.error(exception);
 							}
 						}
 					};