Bug 338953 [Compatibility] 'Close All' should always be enabled when editors are open
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/CloseAllHandler.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/CloseAllHandler.java
index b83436b..fe3207f 100644
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/CloseAllHandler.java
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/CloseAllHandler.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2007 IBM Corporation and others.
+ * Copyright (c) 2007, 2011 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
@@ -18,7 +18,7 @@
 import org.eclipse.core.expressions.ExpressionInfo;
 import org.eclipse.core.expressions.IEvaluationContext;
 import org.eclipse.core.runtime.CoreException;
-import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IEditorReference;
 import org.eclipse.ui.ISources;
 import org.eclipse.ui.IWorkbenchPage;
 import org.eclipse.ui.IWorkbenchWindow;
@@ -61,11 +61,15 @@
 			enabledWhen = new Expression() {
 				public EvaluationResult evaluate(IEvaluationContext context)
 						throws CoreException {
-					IEditorPart part = InternalHandlerUtil
-							.getActiveEditor(context);
-					if (part != null) {
-						return EvaluationResult.TRUE;
-
+					IWorkbenchWindow window = InternalHandlerUtil.getActiveWorkbenchWindow(context);
+					if (window != null) {
+						IWorkbenchPage page = window.getActivePage();
+						if (page != null) {
+							IEditorReference[] refArray = page.getEditorReferences();
+							if (refArray != null && refArray.length > 0) {
+								return EvaluationResult.TRUE;
+							}
+						}
 					}
 					return EvaluationResult.FALSE;
 				}
@@ -76,7 +80,7 @@
 				 * @see org.eclipse.core.expressions.Expression#collectExpressionInfo(org.eclipse.core.expressions.ExpressionInfo)
 				 */
 				public void collectExpressionInfo(ExpressionInfo info) {
-					info.addVariableNameAccess(ISources.ACTIVE_EDITOR_NAME);
+					info.addVariableNameAccess(ISources.ACTIVE_WORKBENCH_WINDOW_NAME);
 				}
 			};
 		}