Bug 507404 - TrimBarLayout´s computeSize method may cause NPE due to
missing MTrimBar

Now the code is now more defensive as in case of missing MTrimBar there
will be no NPE. 

Change-Id: Icf0dd3a1955968bfa4869aad2420da37d564963b
Signed-off-by: Simon Scholz <simon.scholz@vogella.com>
Signed-off-by: Patrik Suzzi <psuzzi@gmail.com>
diff --git a/bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/workbench/renderers/swt/TrimBarLayout.java b/bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/workbench/renderers/swt/TrimBarLayout.java
index 1271727..c0d842e 100644
--- a/bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/workbench/renderers/swt/TrimBarLayout.java
+++ b/bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/workbench/renderers/swt/TrimBarLayout.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2011, 2015 IBM Corporation and others.
+ * Copyright (c) 2011, 2016 IBM Corporation and others.
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
  * which accompanies this distribution, and is available at
@@ -12,6 +12,7 @@
  *     Marc-Andre Laperle (Ericsson) - Bug 466233: Toolbar items are wrongly rendered into a "drop-down"
  *     Lars Vogel <Lars.Vogel@vogella.com> - Bug 472654
  *     Simon Scholz <simon.scholz@vogella.com> - Bug 476386
+ *     Patrik Suzzi <psuzzi@gmail.com> - Bug 507404
  *******************************************************************************/
 package org.eclipse.e4.ui.workbench.renderers.swt;
 
@@ -118,9 +119,9 @@
 		}
 
 		// First, hide any empty toolbars
-		MTrimBar bar = (MTrimBar) composite.getData(AbstractPartRenderer.OWNING_ME);
-		for (MTrimElement te : bar.getChildren()) {
-			hideManagedTB(te);
+		Object bar = composite.getData(AbstractPartRenderer.OWNING_ME);
+		if (bar instanceof MTrimBar) {
+			((MTrimBar) bar).getChildren().forEach(this::hideManagedTB);
 		}
 
 		int totalMajor = horizontal ? wHint - (marginLeft + marginRight) : hHint - (marginTop + marginBottom);