Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 150011 Details for
Bug 193600
[Commands] org.eclipse.ui.menus/menuContribution locationURI query placement "endof=..." not implemented?
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
endof v01
endof-v01.txt (text/plain), 14.18 KB, created by
Paul Webster
on 2009-10-20 14:05:18 EDT
(
hide
)
Description:
endof v01
Filename:
MIME Type:
Creator:
Paul Webster
Created:
2009-10-20 14:05:18 EDT
Size:
14.18 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.ui.tests >Index: Eclipse UI Tests/org/eclipse/ui/tests/menus/MenuPopulationTest.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/menus/MenuPopulationTest.java,v >retrieving revision 1.10 >diff -u -r1.10 MenuPopulationTest.java >--- Eclipse UI Tests/org/eclipse/ui/tests/menus/MenuPopulationTest.java 24 Mar 2008 19:13:47 -0000 1.10 >+++ Eclipse UI Tests/org/eclipse/ui/tests/menus/MenuPopulationTest.java 20 Oct 2009 18:07:39 -0000 >@@ -14,14 +14,17 @@ > import java.lang.reflect.Field; > > import org.eclipse.jface.action.Action; >+import org.eclipse.jface.action.GroupMarker; > import org.eclipse.jface.action.IContributionItem; > import org.eclipse.jface.action.MenuManager; > import org.eclipse.jface.action.ToolBarManager; > import org.eclipse.jface.resource.ImageDescriptor; > import org.eclipse.ui.IPageLayout; > import org.eclipse.ui.IViewPart; >+import org.eclipse.ui.IWorkbenchCommandConstants; > import org.eclipse.ui.menus.AbstractContributionFactory; > import org.eclipse.ui.menus.CommandContributionItem; >+import org.eclipse.ui.menus.CommandContributionItemParameter; > import org.eclipse.ui.menus.IContributionRoot; > import org.eclipse.ui.menus.IMenuService; > import org.eclipse.ui.services.IServiceLocator; >@@ -41,6 +44,10 @@ > public static final String ID_DEFAULT = "org.eclipse.ui.tests.menus.iconsDefault"; > public static final String ID_ALL = "org.eclipse.ui.tests.menus.iconsAll"; > public static final String ID_TOOLBAR = "org.eclipse.ui.tests.menus.iconsToolbarOnly"; >+ private AbstractContributionFactory afterOne; >+ private AbstractContributionFactory beforeOne; >+ private AbstractContributionFactory endofOne; >+ private CommandContributionItem usefulContribution; > > /** > * @param testName >@@ -161,7 +168,8 @@ > > public void testFactoryScopePopulation() throws Exception { > AbstractContributionFactory factory = new AbstractContributionFactory( >- "menu:the.population.menu?after=additions", "org.eclipse.ui.tests") { >+ "menu:the.population.menu?after=additions", >+ "org.eclipse.ui.tests") { > > public void createContributionItems(IServiceLocator serviceLocator, > IContributionRoot additions) { >@@ -178,7 +186,8 @@ > assertNotNull(view); > IMenuService service = (IMenuService) view.getSite().getService( > IMenuService.class); >- service.populateContributionManager(testManager, "menu:the.population.menu"); >+ service.populateContributionManager(testManager, >+ "menu:the.population.menu"); > assertEquals(0, testManager.getSize()); > service.addContributionFactory(factory); > assertEquals(1, testManager.getSize()); >@@ -186,4 +195,176 @@ > processEvents(); > assertEquals(0, testManager.getSize()); > } >+ >+ public void testAfterQueryInvalid() throws Exception { >+ MenuManager manager = new MenuManager(); >+ menuService.populateContributionManager(manager, "menu:after.menu"); >+ assertEquals(0, manager.getSize()); >+ } >+ >+ public void testAfterQueryOneGroup() throws Exception { >+ MenuManager manager = new MenuManager(); >+ manager.add(new GroupMarker("after.one")); >+ assertEquals(1, manager.getSize()); >+ menuService.populateContributionManager(manager, "menu:after.menu"); >+ assertEquals(2, manager.getSize()); >+ assertEquals("after.insert", manager.getItems()[1].getId()); >+ } >+ >+ public void testAfterQueryTwoGroups() throws Exception { >+ MenuManager manager = new MenuManager(); >+ manager.add(new GroupMarker("after.one")); >+ manager.add(new GroupMarker("after.two")); >+ assertEquals(2, manager.getSize()); >+ menuService.populateContributionManager(manager, "menu:after.menu"); >+ assertEquals(3, manager.getSize()); >+ assertEquals("after.insert", manager.getItems()[1].getId()); >+ } >+ >+ public void testBeforeQueryInvalid() throws Exception { >+ MenuManager manager = new MenuManager(); >+ menuService.populateContributionManager(manager, "menu:before.menu"); >+ assertEquals(0, manager.getSize()); >+ } >+ >+ public void testBeforeQueryOneGroup() throws Exception { >+ MenuManager manager = new MenuManager(); >+ manager.add(new GroupMarker("before.one")); >+ assertEquals(1, manager.getSize()); >+ menuService.populateContributionManager(manager, "menu:before.menu"); >+ assertEquals(2, manager.getSize()); >+ assertEquals("before.insert", manager.getItems()[0].getId()); >+ } >+ >+ public void testBeforeQueryTwoGroups() throws Exception { >+ MenuManager manager = new MenuManager(); >+ manager.add(new GroupMarker("before.one")); >+ manager.add(new GroupMarker("before.two")); >+ assertEquals(2, manager.getSize()); >+ menuService.populateContributionManager(manager, "menu:before.menu"); >+ assertEquals(3, manager.getSize()); >+ assertEquals("before.insert", manager.getItems()[0].getId()); >+ } >+ >+ public void testBeforeQueryTwoGroups2() throws Exception { >+ MenuManager manager = new MenuManager(); >+ manager.add(new GroupMarker("before.two")); >+ manager.add(new GroupMarker("before.one")); >+ assertEquals(2, manager.getSize()); >+ menuService.populateContributionManager(manager, "menu:before.menu"); >+ assertEquals(3, manager.getSize()); >+ assertEquals("before.insert", manager.getItems()[1].getId()); >+ } >+ >+ public void testEndofQueryInvalid() throws Exception { >+ MenuManager manager = new MenuManager(); >+ menuService.populateContributionManager(manager, "menu:endof.menu"); >+ assertEquals(0, manager.getSize()); >+ } >+ >+ public void testEndofQueryOneGroup() throws Exception { >+ MenuManager manager = new MenuManager(); >+ manager.add(new GroupMarker("endof.one")); >+ assertEquals(1, manager.getSize()); >+ menuService.populateContributionManager(manager, "menu:endof.menu"); >+ assertEquals(2, manager.getSize()); >+ assertEquals("endof.insert", manager.getItems()[1].getId()); >+ } >+ >+ public void testEndofQueryTwoGroups() throws Exception { >+ MenuManager manager = new MenuManager(); >+ manager.add(new GroupMarker("endof.one")); >+ manager.add(new GroupMarker("endof.two")); >+ assertEquals(2, manager.getSize()); >+ menuService.populateContributionManager(manager, "menu:endof.menu"); >+ assertEquals(3, manager.getSize()); >+ assertEquals("endof.insert", manager.getItems()[1].getId()); >+ } >+ >+ public void testEndofQueryTwoGroups2() throws Exception { >+ MenuManager manager = new MenuManager(); >+ manager.add(new GroupMarker("endof.one")); >+ manager.add(usefulContribution); >+ manager.add(new GroupMarker("endof.two")); >+ assertEquals(3, manager.getSize()); >+ menuService.populateContributionManager(manager, "menu:endof.menu"); >+ assertEquals(4, manager.getSize()); >+ assertEquals("endof.insert", manager.getItems()[2].getId()); >+ } >+ >+ public void testEndofQueryTwoGroups3() throws Exception { >+ MenuManager manager = new MenuManager(); >+ manager.add(new GroupMarker("endof.two")); >+ manager.add(new GroupMarker("endof.one")); >+ assertEquals(2, manager.getSize()); >+ menuService.populateContributionManager(manager, "menu:endof.menu"); >+ assertEquals(3, manager.getSize()); >+ assertEquals("endof.insert", manager.getItems()[2].getId()); >+ } >+ >+ public void testEndofQueryTwoGroups4() throws Exception { >+ MenuManager manager = new MenuManager(); >+ manager.add(new GroupMarker("endof.two")); >+ manager.add(new GroupMarker("endof.one")); >+ manager.add(usefulContribution); >+ assertEquals(3, manager.getSize()); >+ menuService.populateContributionManager(manager, "menu:endof.menu"); >+ assertEquals(4, manager.getSize()); >+ assertEquals("endof.insert", manager.getItems()[3].getId()); >+ } >+ >+ /* >+ * (non-Javadoc) >+ * >+ * @see org.eclipse.ui.tests.menus.MenuTestCase#doSetUp() >+ */ >+ protected void doSetUp() throws Exception { >+ super.doSetUp(); >+ afterOne = new AbstractContributionFactory( >+ "menu:after.menu?after=after.one", "org.eclipse.ui.tests") { >+ public void createContributionItems(IServiceLocator serviceLocator, >+ IContributionRoot additions) { >+ additions.addContributionItem(new GroupMarker("after.insert"), >+ null); >+ } >+ }; >+ menuService.addContributionFactory(afterOne); >+ >+ beforeOne = new AbstractContributionFactory( >+ "menu:before.menu?before=before.one", "org.eclipse.ui.tests") { >+ public void createContributionItems(IServiceLocator serviceLocator, >+ IContributionRoot additions) { >+ additions.addContributionItem(new GroupMarker("before.insert"), >+ null); >+ } >+ }; >+ menuService.addContributionFactory(beforeOne); >+ >+ endofOne = new AbstractContributionFactory( >+ "menu:endof.menu?endof=endof.one", "org.eclipse.ui.tests") { >+ public void createContributionItems(IServiceLocator serviceLocator, >+ IContributionRoot additions) { >+ additions.addContributionItem(new GroupMarker("endof.insert"), >+ null); >+ } >+ }; >+ menuService.addContributionFactory(endofOne); >+ usefulContribution = new CommandContributionItem( >+ new CommandContributionItemParameter(window, null, >+ IWorkbenchCommandConstants.HELP_ABOUT, 0)); >+ } >+ >+ /* >+ * (non-Javadoc) >+ * >+ * @see org.eclipse.ui.tests.menus.MenuTestCase#doTearDown() >+ */ >+ protected void doTearDown() throws Exception { >+ menuService.removeContributionFactory(afterOne); >+ menuService.removeContributionFactory(beforeOne); >+ menuService.removeContributionFactory(endofOne); >+ usefulContribution.dispose(); >+ usefulContribution = null; >+ super.doTearDown(); >+ } > } >#P org.eclipse.ui.workbench >Index: Eclipse UI/org/eclipse/ui/internal/menus/WorkbenchMenuService.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/menus/WorkbenchMenuService.java,v >retrieving revision 1.64 >diff -u -r1.64 WorkbenchMenuService.java >--- Eclipse UI/org/eclipse/ui/internal/menus/WorkbenchMenuService.java 2 Sep 2009 14:35:58 -0000 1.64 >+++ Eclipse UI/org/eclipse/ui/internal/menus/WorkbenchMenuService.java 20 Oct 2009 18:07:40 -0000 >@@ -19,7 +19,6 @@ > import java.util.List; > import java.util.Map; > import java.util.Set; >- > import org.eclipse.core.expressions.Expression; > import org.eclipse.core.expressions.IEvaluationContext; > import org.eclipse.core.runtime.IConfigurationElement; >@@ -48,6 +47,7 @@ > import org.eclipse.swt.widgets.Control; > import org.eclipse.swt.widgets.Display; > import org.eclipse.ui.ISourceProvider; >+import org.eclipse.ui.IWorkbenchActionConstants; > import org.eclipse.ui.IWorkbenchWindow; > import org.eclipse.ui.PlatformUI; > import org.eclipse.ui.activities.ActivityManagerEvent; >@@ -73,6 +73,7 @@ > import org.eclipse.ui.internal.util.Util; > import org.eclipse.ui.keys.IBindingService; > import org.eclipse.ui.menus.AbstractContributionFactory; >+import org.eclipse.ui.menus.MenuUtil; > import org.eclipse.ui.services.IEvaluationReference; > import org.eclipse.ui.services.IEvaluationService; > import org.eclipse.ui.services.IServiceLocator; >@@ -91,6 +92,8 @@ > */ > public final class WorkbenchMenuService extends InternalMenuService { > >+ private static final String INDEX_AFTER_ADDITIONS = "after=additions"; //$NON-NLS-1$ >+ > /** > * A combined property and activity listener that updates the visibility of > * contribution items in the new menu system. >@@ -736,11 +739,6 @@ > } > } > >- /** >- * @param mgr >- * @param uri >- * @return >- */ > private int getInsertionIndex(ContributionManager mgr, String location) { > MenuLocationURI uri = new MenuLocationURI(location); > String query = uri.getQuery(); >@@ -749,19 +747,36 @@ > > // No Query means 'after=additions' (if ther) or > // the end of the menu >- if (query.length() == 0 || query.equals("after=additions")) { //$NON-NLS-1$ >- additionsIndex = mgr.indexOf("additions"); //$NON-NLS-1$ >+ if (query.length() == 0 || query.equals(INDEX_AFTER_ADDITIONS)) { >+ additionsIndex = mgr >+ .indexOf(IWorkbenchActionConstants.MB_ADDITIONS); > if (additionsIndex == -1) > additionsIndex = mgr.getItems().length; > else > ++additionsIndex; > } else { >- // Should be in the form "[before|after]=id" >+ // Should be in the form "[before|after|endof]=id" > String[] queryParts = Util.split(query, '='); > if (queryParts.length>1 && queryParts[1].length() > 0) { >- additionsIndex = mgr.indexOf(queryParts[1]); >- if (additionsIndex != -1 && queryParts[0].equals("after")) //$NON-NLS-1$ >- additionsIndex++; >+ String modifier = queryParts[0]; >+ String id = queryParts[1]; >+ additionsIndex = mgr.indexOf(id); >+ if (additionsIndex != -1) { >+ if (MenuUtil.QUERY_BEFORE.equals(modifier)) { >+ // this is OK, the additionsIndex will either be correct >+ // or -1 (which is a no-op) >+ } else if (MenuUtil.QUERY_AFTER.equals(modifier)) { >+ additionsIndex++; >+ } else if (MenuUtil.QUERY_ENDOF.equals(modifier)) { >+ // OK, this one is exciting >+ IContributionItem[] items = mgr.getItems(); >+ for (additionsIndex++; additionsIndex < items.length; additionsIndex++) { >+ if (items[additionsIndex].isGroupMarker()) { >+ break; >+ } >+ } >+ } >+ } > } > } > >Index: Eclipse UI/org/eclipse/ui/menus/MenuUtil.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/menus/MenuUtil.java,v >retrieving revision 1.7 >diff -u -r1.7 MenuUtil.java >--- Eclipse UI/org/eclipse/ui/menus/MenuUtil.java 20 Oct 2009 14:26:26 -0000 1.7 >+++ Eclipse UI/org/eclipse/ui/menus/MenuUtil.java 20 Oct 2009 18:07:40 -0000 >@@ -39,6 +39,33 @@ > public final static String TRIM_STATUS = "toolbar:org.eclipse.ui.trim.status"; //$NON-NLS-1$ > > /** >+ * Valid query attribute. Usage <b>menu:menu.id?before=contribution.id</b>. >+ * >+ * @since 3.6 >+ */ >+ public final static String QUERY_BEFORE = "before"; //$NON-NLS-1$ >+ >+ /** >+ * Valid query attribute. Usage <b>menu:menu.id?after=contribution.id</b>. >+ * >+ * @since 3.6 >+ */ >+ public final static String QUERY_AFTER = "after"; //$NON-NLS-1$ >+ >+ /** >+ * Valid query attribute. Usage <b>menu:menu.id?endof=contribution.id</b>. >+ * <p> >+ * This menu contribution will be placed at the end of the group defined by >+ * <b>contribution.id</b> (usually right in front of the next group marker >+ * or separator). Further contribution processing can still place other >+ * contributions after this one. >+ * </p> >+ * >+ * @since 3.6 >+ */ >+ public final static String QUERY_ENDOF = "endof"; //$NON-NLS-1$ >+ >+ /** > * Contributions of targets to this location will be included with the show > * in menu. > *
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 193600
:
150011
|
150013