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 150013 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 v02
endof-v02.txt (text/plain), 19.07 KB, created by
Paul Webster
on 2009-10-20 14:52:50 EDT
(
hide
)
Description:
endof v02
Filename:
MIME Type:
Creator:
Paul Webster
Created:
2009-10-20 14:52:50 EDT
Size:
19.07 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.ui >Index: schema/menus.exsd >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui/schema/menus.exsd,v >retrieving revision 1.64 >diff -u -r1.64 menus.exsd >--- schema/menus.exsd 24 Apr 2009 18:39:41 -0000 1.64 >+++ schema/menus.exsd 20 Oct 2009 18:54:04 -0000 >@@ -37,7 +37,7 @@ > <ul> > <li><b>Scheme</b> - The 'type' of the UI component into which the contributions will be added. It may be either "menu", "popup" or "toolbar". While 'popup' is indeed a form of menu it is provided to allow a distinction between a view's 'chevron' menu (for which we use the "menu" scheme) and its default context menu which, by convention, should be registered using the "popup" scheme.</li> > <li><b>ID</b> - This is the id of menu or toolbar into which the contributions should be added. By convention views should use their view id as the id of the root of their chevron and default popup menu. Note that there is no explicit distinction between contributions supporting editors and 'normal' contributions into the Menu Menu or Toolbar; both global contributions and editor contributions would use the "org.eclipse.ui.main.menu" id or "org.eclipse.ui.main.toolbar". A special id used with popup:, "org.eclipse.ui.popup.any", is reserved to handle contributions which are candidates to appear on any (top level) context menu. Note that these contributions are expected to implement a 'visibleWhen' expression sufficient to limit their visibility to appropriate menus</li> >-<li><b>Query</b> - This field allows fine-grained definition of the specific location <i>within</i> a given menu. It has the form "[placement]=[id]" where placement is one of "before" or "after" and the id is expected to be the id of some IContributionItem in the menu.</li> >+<li><b>Query</b> - This field allows fine-grained definition of the specific location <i>within</i> a given menu. It has the form "[placement]=[id]" where placement is one of "before", "after", or "endof" and the id is expected to be the id of some IContributionItem in the menu.</li> > </ul> > <p> > This will define the location at which the contributions will appear in the eclipse UI. Once the insertion point has been defined the rest of the contributions describe the UI elements that will be added at that location. Each element supports a 'visibleWhen' expression that determines at run time whether a particular item should appear in the menu based on the system's current state (selection, active view/editor, context...). See <code>org.eclipse.ui.ISources</code> for a list of currently >@@ -531,8 +531,8 @@ > Scheme: One of "menu", "popup" or "toolbar. Indicates the type of the manager used to handle the contributions > Id: This is either the id of an existing menu, a view id or the id of the editor 'type' > Query: The query format is &lt;placement&gt;=&lt;id&gt; where: >- &lt;placement&gt; is either "before" or "after" and >- &lt;id&gt; is the id of an existing menu item >+ &lt;placement&gt; is either "before", "after", or "endof" and >+ &lt;id&gt; is the id of an existing menu item. The placement modifier is executed when this contribution is processed. Following contributions may change the final shape of the menu when they are processed. > </documentation> > </annotation> > </attribute> >@@ -790,7 +790,7 @@ > <documentation> > The 'id' of this contribution. If defined then it can be used as a reference in the Query part of the location defining whether the additions are to go before or after this element (or at the end of the logical group containing this element using the 'endof' value). > <p> >-Separator contributions that have an id define the start of a logical group so the result of using the 'endof' value for placement is to search forward in the current menu to locate the next id'd separator and to place the inserted elements before that element. If no trailing separator is found then the items are placed at the end of the menu. >+Separator contributions that have an id define the start of a logical group so the result of using the 'endof' value for placement is to search forward in the current menu to locate the next separator and to place the inserted elements before that element. If no trailing separator is found then the items are placed at the end of the menu. > </p> > </documentation> > </annotation> >#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:54:05 -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:54:05 -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:54:05 -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