Merge "Bug 389426 - Add factory method for creating EMF workspace synchronizer delegate"
diff --git a/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/editor/DiagramEditor.java b/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/editor/DiagramEditor.java
index b0263d6..2a53f60 100644
--- a/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/editor/DiagramEditor.java
+++ b/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/editor/DiagramEditor.java
@@ -27,6 +27,7 @@
* mwenz - Bug 372753 - save shouldn't (necessarily) flush the command stack
* mwenz - Bug 376008 - Iterating through navigation history causes exceptions
* Felix Velasco - mwenz - Bug 379788 - Memory leak in DefaultMarkerBehavior
+ * mwenz - Bug 387971 - Features cant't be invoked from contextMenu
*
* </copyright>
*
@@ -1370,8 +1371,18 @@
selectPictogramElements(pes);
}
}
+ /*
+ * https://bugs.eclipse.org/bugs/show_bug.cgi?id=387971: When
+ * embedding a diagram editor inside a multi page editor the
+ * registered actions were not updated. The fix was simply not to
+ * delegate to super.selectionChange where a check for the editor
+ * being active only checks for the main editor (GEF editor is not
+ * embeddable inside another editor) but to trigger the action
+ * update ourself when our checks say the diagram editor is active.
+ */
+ updateActions(getSelectionActions());
}
- super.selectionChanged(part, selection);
+
}
/**
diff --git a/tests/org.eclipse.graphiti.testtool.sketch/src/org/eclipse/graphiti/testtool/sketch/editors/MultiPageEditor.java b/tests/org.eclipse.graphiti.testtool.sketch/src/org/eclipse/graphiti/testtool/sketch/editors/MultiPageEditor.java
index a8e7959..142833d 100644
--- a/tests/org.eclipse.graphiti.testtool.sketch/src/org/eclipse/graphiti/testtool/sketch/editors/MultiPageEditor.java
+++ b/tests/org.eclipse.graphiti.testtool.sketch/src/org/eclipse/graphiti/testtool/sketch/editors/MultiPageEditor.java
@@ -1,3 +1,19 @@
+/*******************************************************************************
+ * <copyright>
+ *
+ * Copyright (c) 2011, 2012 SAP AG.
+ * 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * SAP AG - initial API, implementation and documentation
+ * mwenz - Bug 387971 - Features cant't be invoked from contextMenu
+ *
+ * </copyright>
+ *
+ *******************************************************************************/
package org.eclipse.graphiti.testtool.sketch.editors;
@@ -8,19 +24,22 @@
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.graphiti.ui.editor.DiagramEditor;
import org.eclipse.jface.dialogs.ErrorDialog;
+import org.eclipse.jface.viewers.ISelection;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IEditorSite;
import org.eclipse.ui.IFileEditorInput;
+import org.eclipse.ui.ISelectionListener;
import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.editors.text.TextEditor;
import org.eclipse.ui.forms.editor.FormEditor;
import org.eclipse.ui.ide.IDE;
import org.eclipse.ui.part.FileEditorInput;
-public class MultiPageEditor extends FormEditor implements IResourceChangeListener {
+public class MultiPageEditor extends FormEditor implements IResourceChangeListener, ISelectionListener {
/** The text editor used in page 0. */
private DiagramEditor editor;
@@ -114,6 +133,10 @@
if (!(editorInput instanceof IFileEditorInput))
throw new PartInitException("Invalid Input: Must be IFileEditorInput");
super.init(site, editorInput);
+
+ // Register this editor to get informed about selection changes (also
+ // inside editor) to update e.g. the registered actions (see Bug 387971)
+ getSite().getWorkbenchWindow().getSelectionService().addSelectionListener(this);
}
/* (non-Javadoc)
* Method declared on IEditorPart.
@@ -146,4 +169,14 @@
}
}
+ public void selectionChanged(IWorkbenchPart part, ISelection selection) {
+ // Propagate the selection changed event to all sub editors
+ int pageCount = getPageCount();
+ for (int i = 0; i < pageCount; i++) {
+ IEditorPart editor = getEditor(i);
+ if (editor instanceof ISelectionListener) {
+ ((ISelectionListener) editor).selectionChanged(part, selection);
+ }
+ }
+ }
}