aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemy Suen2012-12-06 11:37:05 (EST)
committerPaul Webster2012-12-06 11:37:05 (EST)
commit2510931a531dcb420af22ba5b99a2694feab8ddf (patch)
treed528d499c401b1cd6b2b990b3e9f330612ebddff
parentf58eeeba9a8cb3c7a1352091b0d4cefe365b7ba1 (diff)
downloadeclipse.platform.ui-2510931a531dcb420af22ba5b99a2694feab8ddf.zip
eclipse.platform.ui-2510931a531dcb420af22ba5b99a2694feab8ddf.tar.gz
eclipse.platform.ui-2510931a531dcb420af22ba5b99a2694feab8ddf.tar.bz2
Bug 379849 - MultiPageEditors need a better way to get popup menu'sv20121206-163705
contexts correct Directly specify the parent context when creating a PopupMenuExtender. This allows the MPESite to specify a useful context.
-rw-r--r--bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/workbench/renderers/swt/MenuManagerRendererFilter.java5
-rw-r--r--bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/workbench/swt/modeling/MenuService.java19
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/EditorSite.java6
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/PartSite.java14
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/PopupMenuExtender.java28
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/part/MultiPageEditorSite.java11
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/part/PageSite.java6
-rw-r--r--tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/dynamicplugins/ObjectContributionTests.java3
-rw-r--r--tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/menus/Bug264804Test.java3
-rw-r--r--tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/menus/MenuPopulationTest.java10
-rw-r--r--tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/menus/ObjectContributionTest.java3
11 files changed, 58 insertions, 50 deletions
diff --git a/bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/workbench/renderers/swt/MenuManagerRendererFilter.java b/bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/workbench/renderers/swt/MenuManagerRendererFilter.java
index a186d7f..6855518 100644
--- a/bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/workbench/renderers/swt/MenuManagerRendererFilter.java
+++ b/bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/workbench/renderers/swt/MenuManagerRendererFilter.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010, 2011 IBM Corporation and others.
+ * Copyright (c) 2010, 2012 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
@@ -133,7 +133,8 @@ public class MenuManagerRendererFilter implements Listener {
.getContainer(popupMenu);
if (container instanceof MPart) {
MenuService.registerMenu(menuManager.getMenu()
- .getParent(), popupMenu, (MPart) container);
+ .getParent(), popupMenu,
+ ((MPart) container).getContext());
}
}
}
diff --git a/bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/workbench/swt/modeling/MenuService.java b/bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/workbench/swt/modeling/MenuService.java
index 97598c0..6e1ce94 100644
--- a/bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/workbench/swt/modeling/MenuService.java
+++ b/bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/workbench/swt/modeling/MenuService.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010 IBM Corporation and others.
+ * Copyright (c) 2010, 2012 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
@@ -35,7 +35,7 @@ public class MenuService implements EMenuService {
if (menuId.equals(mmenu.getElementId())
&& mmenu instanceof MPopupMenu) {
Menu menu = registerMenu(parentControl, (MPopupMenu) mmenu,
- myPart);
+ myPart.getContext());
if (menu != null) {
parentControl.setMenu(menu);
return (MPopupMenu) mmenu;
@@ -48,26 +48,17 @@ public class MenuService implements EMenuService {
}
public static Menu registerMenu(final Control parentControl,
- final MPopupMenu mmenu, final MPart part) {
+ final MPopupMenu mmenu, IEclipseContext context) {
if (mmenu.getWidget() != null) {
return (Menu) mmenu.getWidget();
}
// we need to delegate to the renderer so that it "processes" the
// MenuManager correctly
- IRendererFactory rendererFactory = part.getContext().get(
- IRendererFactory.class);
+ IRendererFactory rendererFactory = context.get(IRendererFactory.class);
AbstractPartRenderer renderer = rendererFactory.getRenderer(mmenu,
parentControl);
- // Check whether the part's is a multi-page editor, if so use its
- // context instead
- IEclipseContext parentContext = part.getContext();
- if (parentContext.get("MultiPageEditorSite") instanceof IEclipseContext) {
- parentContext = (IEclipseContext) parentContext
- .get("MultiPageEditorSite");
- }
-
- IEclipseContext popupContext = parentContext.createChild("popup:"
+ IEclipseContext popupContext = context.createChild("popup:"
+ mmenu.getElementId());
mmenu.setContext(popupContext);
Object widget = renderer.createWidget(mmenu, parentControl);
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/EditorSite.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/EditorSite.java
index 9bf896c..a0d7aea 100644
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/EditorSite.java
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/EditorSite.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2010 IBM Corporation and others.
+ * Copyright (c) 2000, 2012 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
@@ -148,7 +148,7 @@ public class EditorSite extends PartSite implements IEditorSite {
menuExtenders = new ArrayList(1);
}
- PartSite.registerContextMenu(menuId, menuManager, selectionProvider,
- includeEditorInput, getPart(), menuExtenders);
+ PartSite.registerContextMenu(menuId, menuManager, selectionProvider, includeEditorInput,
+ getPart(), getModel().getContext(), menuExtenders);
}
}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/PartSite.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/PartSite.java
index ee64706..f3fa8ec 100644
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/PartSite.java
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/PartSite.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2011 IBM Corporation and others.
+ * Copyright (c) 2000, 2012 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
@@ -104,9 +104,8 @@ public abstract class PartSite implements IWorkbenchPartSite {
* ISelectionProvider)
*/
public static final void registerContextMenu(final String menuId,
- final MenuManager menuManager,
- final ISelectionProvider selectionProvider,
- final boolean includeEditorInput, final IWorkbenchPart part,
+ final MenuManager menuManager, final ISelectionProvider selectionProvider,
+ final boolean includeEditorInput, final IWorkbenchPart part, IEclipseContext context,
final Collection menuExtenders) {
/*
* Check to see if the same menu manager and selection provider have
@@ -126,8 +125,8 @@ public abstract class PartSite implements IWorkbenchPartSite {
}
if (!foundMatch) {
- menuExtenders.add(new PopupMenuExtender(menuId, menuManager,
- selectionProvider, part, includeEditorInput));
+ menuExtenders.add(new PopupMenuExtender(menuId, menuManager, selectionProvider, part,
+ context, includeEditorInput));
}
}
@@ -491,8 +490,7 @@ public abstract class PartSite implements IWorkbenchPartSite {
menuExtenders = new ArrayList(1);
}
- registerContextMenu(menuID, menuMgr, selProvider, true, getPart(),
- menuExtenders);
+ registerContextMenu(menuID, menuMgr, selProvider, true, getPart(), e4Context, menuExtenders);
}
/**
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/PopupMenuExtender.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/PopupMenuExtender.java
index f4c6ec6..76f7972 100644
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/PopupMenuExtender.java
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/PopupMenuExtender.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2011 IBM Corporation and others.
+ * Copyright (c) 2000, 2012 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
@@ -96,6 +96,11 @@ public class PopupMenuExtender implements IMenuListener2,
private MPart modelPart;
+ /**
+ * The context that will be used to create the popup menu's context under.
+ */
+ private IEclipseContext context;
+
/**
* Construct a new menu extender.
*
@@ -107,11 +112,13 @@ public class PopupMenuExtender implements IMenuListener2,
* the selection provider
* @param part
* the part to extend
+ * @param context
+ * the context to create the child popup menu context under
*/
- public PopupMenuExtender(String id, MenuManager menu,
- ISelectionProvider prov, IWorkbenchPart part) {
- this(id, menu, prov, part, true);
- }
+ public PopupMenuExtender(String id, MenuManager menu, ISelectionProvider prov,
+ IWorkbenchPart part, IEclipseContext context) {
+ this(id, menu, prov, part, context, true);
+ }
/**
* Construct a new menu extender.
@@ -124,17 +131,20 @@ public class PopupMenuExtender implements IMenuListener2,
* the selection provider
* @param part
* the part to extend
+ * @param context
+ * the context to create the child popup menu context under
* @param includeEditorInput
* Whether the editor input should be included when adding object
* contributions to this context menu.
*/
- public PopupMenuExtender(final String id, final MenuManager menu,
- final ISelectionProvider prov, final IWorkbenchPart part,
- final boolean includeEditorInput) {
+ public PopupMenuExtender(final String id, final MenuManager menu,
+ final ISelectionProvider prov, final IWorkbenchPart part, IEclipseContext context,
+ final boolean includeEditorInput) {
super();
this.menu = menu;
this.selProvider = prov;
this.part = part;
+ this.context = context;
this.modelPart = (MPart) part.getSite().getService(MPart.class);
if (includeEditorInput) {
bitSet |= INCLUDE_EDITOR_INPUT;
@@ -179,7 +189,7 @@ public class PopupMenuExtender implements IMenuListener2,
private void registerE4Support() {
if (menuModel.getWidget() == null && menu.getMenu() != null) {
- MenuService.registerMenu(menu.getMenu().getParent(), menuModel, modelPart);
+ MenuService.registerMenu(menu.getMenu().getParent(), menuModel, context);
}
}
// getMenuId() added by Dan Rubel (dan_rubel@instantiations.com)
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/part/MultiPageEditorSite.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/part/MultiPageEditorSite.java
index 18ecd41..9b4aa1a 100644
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/part/MultiPageEditorSite.java
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/part/MultiPageEditorSite.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2011 IBM Corporation and others.
+ * Copyright (c) 2000, 2012 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
@@ -138,7 +138,6 @@ public class MultiPageEditorSite implements IEditorSite, INestable {
getMultiPageEditor().close();
}
}, context);
- site.getModel().getContext().set("MultiPageEditorSite", context); //$NON-NLS-1$
initializeDefaultServices();
}
@@ -547,8 +546,8 @@ public class MultiPageEditorSite implements IEditorSite, INestable {
if (menuExtenders == null) {
menuExtenders = new ArrayList(1);
}
- PartSite.registerContextMenu(menuID, menuMgr, selProvider, true,
- editor, menuExtenders);
+ PartSite.registerContextMenu(menuID, menuMgr, selProvider, true, editor, context,
+ menuExtenders);
}
public final void registerContextMenu(final String menuId,
@@ -558,8 +557,8 @@ public class MultiPageEditorSite implements IEditorSite, INestable {
if (menuExtenders == null) {
menuExtenders = new ArrayList(1);
}
- PartSite.registerContextMenu(menuId, menuManager, selectionProvider,
- includeEditorInput, editor, menuExtenders);
+ PartSite.registerContextMenu(menuId, menuManager, selectionProvider, includeEditorInput,
+ editor, context, menuExtenders);
}
/**
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/part/PageSite.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/part/PageSite.java
index c93ec1f..5e1914e 100644
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/part/PageSite.java
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/part/PageSite.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2011 IBM Corporation and others.
+ * Copyright (c) 2000, 2012 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
@@ -240,8 +240,8 @@ public class PageSite implements IPageSite, INestable {
if (menuExtenders == null) {
menuExtenders = new ArrayList(1);
}
- PartSite.registerContextMenu(menuID, menuMgr, selProvider, false,
- parentSite.getPart(), menuExtenders);
+ PartSite.registerContextMenu(menuID, menuMgr, selProvider, false, parentSite.getPart(),
+ e4Context, menuExtenders);
}
/*
diff --git a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/dynamicplugins/ObjectContributionTests.java b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/dynamicplugins/ObjectContributionTests.java
index 3891b9e..0bbddb0 100644
--- a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/dynamicplugins/ObjectContributionTests.java
+++ b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/dynamicplugins/ObjectContributionTests.java
@@ -26,6 +26,7 @@ import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.ide.IDE;
import org.eclipse.ui.internal.ObjectActionContributorManager;
+import org.eclipse.ui.internal.PartSite;
import org.eclipse.ui.internal.PopupMenuExtender;
import org.eclipse.ui.internal.registry.IWorkbenchRegistryConstants;
@@ -93,7 +94,7 @@ public class ObjectContributionTests extends DynamicTestCase {
};
- PopupMenuExtender extender = new PopupMenuExtender(GROUP_ID, menu, provider, part);
+ PopupMenuExtender extender = new PopupMenuExtender(GROUP_ID, menu, provider, part, ((PartSite)part.getSite()).getContext());
extender.menuAboutToShow(menu);
assertNull(menu.find(VIEWER_ACTION_ID));
diff --git a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/menus/Bug264804Test.java b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/menus/Bug264804Test.java
index 5ce65a5..92edd26 100644
--- a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/menus/Bug264804Test.java
+++ b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/menus/Bug264804Test.java
@@ -19,6 +19,7 @@ import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.internal.PartSite;
import org.eclipse.ui.internal.PopupMenuExtender;
import org.eclipse.ui.tests.api.ListElement;
import org.eclipse.ui.tests.api.ListView;
@@ -56,7 +57,7 @@ public class Bug264804Test extends UITestCase {
try {
popupMenuExtender = new PopupMenuExtender(
"org.eclipse.ui.tests.Bug264804", manager, prov, part,
- false);
+ ((PartSite)part.getSite()).getContext(), false);
Menu contextMenu = manager.createContextMenu(window.getShell());
// contextMenu.setVisible(true);
diff --git a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/menus/MenuPopulationTest.java b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/menus/MenuPopulationTest.java
index 5525194..a179e70 100644
--- a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/menus/MenuPopulationTest.java
+++ b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/menus/MenuPopulationTest.java
@@ -34,6 +34,7 @@ import org.eclipse.ui.IWorkbenchActionConstants;
import org.eclipse.ui.IWorkbenchCommandConstants;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.internal.PartSite;
import org.eclipse.ui.internal.PopupMenuExtender;
import org.eclipse.ui.internal.WorkbenchWindow;
import org.eclipse.ui.menus.AbstractContributionFactory;
@@ -99,7 +100,10 @@ public class MenuPopulationTest extends MenuTestCase {
manager.setRemoveAllWhenShown(true);
Menu contextMenu = manager.createContextMenu(problemsView.getSite().getShell());
- popupMenuExtender = new PopupMenuExtender(IPageLayout.ID_PROBLEM_VIEW, manager, problemsView.getSite().getSelectionProvider(), problemsView, false);
+ popupMenuExtender = new PopupMenuExtender(
+ IPageLayout.ID_PROBLEM_VIEW, manager, problemsView
+ .getSite().getSelectionProvider(), problemsView,
+ ((PartSite) problemsView.getSite()).getContext(), false);
popupMenuExtender.addMenuId(MarkerSupportRegistry.MARKERS_ID);
contextMenu.notifyListeners(SWT.Show, new Event());
@@ -606,7 +610,9 @@ public class MenuPopulationTest extends MenuTestCase {
manager = new MenuManager();
manager.setRemoveAllWhenShown(true);
- popupMenuExtender = new PopupMenuExtender(activePart.getSite().getId(), manager, null, activePart);
+ popupMenuExtender = new PopupMenuExtender(activePart.getSite()
+ .getId(), manager, null, activePart,
+ ((PartSite) activePart.getSite()).getContext());
Shell windowShell = window.getShell();
contextMenu = manager.createContextMenu(windowShell);
diff --git a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/menus/ObjectContributionTest.java b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/menus/ObjectContributionTest.java
index f68509b..57f5947 100644
--- a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/menus/ObjectContributionTest.java
+++ b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/menus/ObjectContributionTest.java
@@ -41,6 +41,7 @@ import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.internal.PartSite;
import org.eclipse.ui.internal.PluginActionContributionItem;
import org.eclipse.ui.internal.PopupMenuExtender;
import org.eclipse.ui.internal.WorkbenchWindow;
@@ -331,7 +332,7 @@ public final class ObjectContributionTest extends UITestCase {
fakeMenuManager.add(new GroupMarker(
org.eclipse.ui.IWorkbenchActionConstants.MB_ADDITIONS));
final PopupMenuExtender extender = new PopupMenuExtender(null,
- fakeMenuManager, selectionProvider, part);
+ fakeMenuManager, selectionProvider, part, ((PartSite)part.getSite()).getContext());
/*
* Pretend to show the pop-up menu -- looking to motivate the extender