Bug 543745 part listeners are unregistered for multi-page editors

Change-Id: I6dcd36afd6af8d9dc977c5772f7cffc0d7647ba0
Signed-off-by: Ralph Gerbig <ralph.gerbig@sap.com>
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/ObjectPluginAction.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/ObjectPluginAction.java
index e50d2f0..aed9a36 100644
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/ObjectPluginAction.java
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/ObjectPluginAction.java
@@ -18,11 +18,13 @@
 import org.eclipse.core.runtime.SafeRunner;
 import org.eclipse.jface.viewers.StructuredSelection;
 import org.eclipse.ui.IActionDelegate;
+import org.eclipse.ui.IEditorPart;
 import org.eclipse.ui.IObjectActionDelegate;
 import org.eclipse.ui.IPartListener2;
 import org.eclipse.ui.IWorkbenchPage;
 import org.eclipse.ui.IWorkbenchPart;
 import org.eclipse.ui.IWorkbenchPartReference;
+import org.eclipse.ui.part.MultiPageEditorPart;
 
 /**
  * An object action extension in a popup menu.
@@ -52,12 +54,27 @@
 
 	@Override
 	public void partClosed(IWorkbenchPartReference partRef) {
-		if (activePart != null && partRef.getPart(false) == activePart) {
-			selectionChanged(StructuredSelection.EMPTY);
-			stopPartListening();
-			disposeDelegate();
-			activePart = null;
+		IWorkbenchPart part = partRef.getPart(false);
+		// FIX 543745
+		if (part instanceof MultiPageEditorPart && activePart instanceof IEditorPart) {
+			MultiPageEditorPart mulitPageEditorPart = (MultiPageEditorPart) part;
+			IEditorPart[] editorsForActivePart = mulitPageEditorPart
+					.findEditors(((IEditorPart) activePart).getEditorInput());
+			if (editorsForActivePart != null && editorsForActivePart.length > 0) {
+				clearActivePart();
+				return;
+			}
 		}
+		if (activePart != null && part == activePart) {
+			clearActivePart();
+		}
+	}
+
+	private void clearActivePart() {
+		selectionChanged(StructuredSelection.EMPTY);
+		stopPartListening();
+		disposeDelegate();
+		activePart = null;
 	}
 
 	@Override