Skip to content

Commit

Permalink
Fix links and formating issues in Populating_a_dynamic_submenu.md and
Browse files Browse the repository at this point in the history
Problems_View_Example.md
  • Loading branch information
jnerlich authored and vogella committed Feb 8, 2024
1 parent db4bdb4 commit f61769f
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 14 deletions.
11 changes: 6 additions & 5 deletions docs/Menu_Contributions/Populating_a_dynamic_submenu.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ Menu Contributions/Populating a dynamic submenu
Add a dynamic submenu to the ProblemView menu
=============================================

In [Menu Contributions/Problems View Example](./Menu_Contributions/Problems_View_Example.md "Menu Contributions/Problems View Example") we added 2 dynamic menus. You then have to extend the abstract [CompoundContributionItem](http://help.eclipse.org/latest/nftopic/org.eclipse.platform.doc.isv/reference/api/org/eclipse/ui/actions/CompoundContributionItem.html) class in your provided class.
In [Menu Contributions/Problems View Example](./Problems_View_Example.md "Menu Contributions/Problems View Example") we added 2 dynamic menus.
You then have to extend the abstract [CompoundContributionItem](http://help.eclipse.org/latest/nftopic/org.eclipse.platform.doc.isv/reference/api/org/eclipse/ui/actions/CompoundContributionItem.html) class in your provided class.

<menu id="org.eclipse.ui.views.problems.groupBy.menu"
label="%ProblemView.GroupBy.label"
Expand All @@ -15,18 +16,18 @@ In [Menu Contributions/Problems View Example](./Menu_Contributions/Problems_View

When your menu is populated, you'll have your getContributionItems() method called:

protected IContributionItem\[\] getContributionItems() {
IContributionItem\[\] list = new IContributionItem\[2\];
protected IContributionItem[] getContributionItems() {
IContributionItem[] list = new IContributionItem[2];
Map parms = new HashMap();
parms.put("groupBy", "Severity");
list\[0\] = new CommandContributionItem(null,
list[0] = new CommandContributionItem(null,
"org.eclipse.ui.views.problems.grouping",
parms, null, null, null, "Severity", null,
null, CommandContributionItem.STYLE_PUSH);
 
parms = new HashMap();
parms.put("groupBy", "None");
list\[1\] = new CommandContributionItem(null,
list[1] = new CommandContributionItem(null,
"org.eclipse.ui.views.problems.grouping",
parms, null, null, null, "None", null, null,
CommandContributionItem.STYLE_PUSH);
Expand Down
27 changes: 18 additions & 9 deletions docs/Menu_Contributions/Problems_View_Example.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,15 @@ Contents
Add ProblemView menus
=====================

Add the Problems view menus. The Problems view has one toolbar action and in the view menu, 3 actions and 2 dynamic submenus. It also has a dynamic menu and another bunch of actions in its context menu.
Add the Problems view menus.
The Problems view has one toolbar action and in the view menu, 3 actions and 2 dynamic submenus.
It also has a dynamic menu and another bunch of actions in its context menu.

Commands
--------

First define commands that are specific to the view. Since these are view commands, we can specify a default handler ... we're unlikely to replace it.
First define commands that are specific to the view.
Since these are view commands, we can specify a default handler ... we're unlikely to replace it.

<extension point="org.eclipse.ui.commands">
<category id="org.eclipse.ui.views.problems"
Expand Down Expand Up @@ -60,7 +63,9 @@ First define commands that are specific to the view. Since these are view comman
Handlers
--------

We can also use a number of global commands, like copy, paste, delete, quick fix, and properties. For these, we just need to define our handlers. We need to add them with <activeWhen/> clauses to restrict them to being active when the view is active.
We can also use a number of global commands, like copy, paste, delete, quick fix, and properties.
For these, we just need to define our handlers.
We need to add them with `<activeWhen/>` clauses to restrict them to being active when the view is active.

<extension point="org.eclipse.ui.handlers">
<handler commandId="org.eclipse.ui.edit.copy"
Expand Down Expand Up @@ -145,16 +150,19 @@ We can also use a number of global commands, like copy, paste, delete, quick fix

Or we can programmatically activate them through the IHandlerService which we would retrieve from the ProblemView site.

IHandlerService handlerServ = (IHandlerService)getSite().getService(IHandlerService.class);
CopyMarkerHandler copy = new CopyMarkerHandler();
handlerServ.activateHandler("org.eclipse.ui.edit.copy", copy);
IHandlerService handlerServ = (IHandlerService)getSite().getService(IHandlerService.class);
CopyMarkerHandler copy = new CopyMarkerHandler();
handlerServ.activateHandler("org.eclipse.ui.edit.copy", copy);

Using the ProblemView site to access the IHandlerService handles the <activeWhen/> clause for us, and our programmatic handler would manage its own enablement state.
Using the ProblemView site to access the IHandlerService handles the `<activeWhen/>` clause for us, and our programmatic handler would manage its own enablement state.

Menus
-----

Then we would define the ProblemView menu structures. We are using 3 **roots**: the view menu, the view toolbar, and the view context menu. This is an example of an "in-place" menu definition. The <menuContribution/> location attribute is a URI that defines the starting point for inserting the menu elements. The XML hierarchy mirrors the menu hierarchy, in that you can define items and menus within the body of other menus.
Then we would define the ProblemView menu structures.
We are using 3 **roots**: the view menu, the view toolbar, and the view context menu.
This is an example of an "in-place" menu definition. The `<menuContribution/>` location attribute is a URI that defines the starting point for inserting the menu elements.
The XML hierarchy mirrors the menu hierarchy, in that you can define items and menus within the body of other menus.

<extension point="org.eclipse.ui.menus">
<menuContribution locationURI="menu:org.eclipse.ui.views.ProblemView">
Expand Down Expand Up @@ -349,5 +357,6 @@ The above example can be done for the view menus:
menuService.addContributionFactory(viewMenuAddition);
}

The `AbstractContributionFactory` creates new contribution items every time `createContributionItems(List)` is called. The factory location tells the framework where to insert the contributions when populating `ContributionManager`s.
The `AbstractContributionFactory` creates new contribution items every time `createContributionItems(List)` is called.
The factory location tells the framework where to insert the contributions when populating `ContributionManager`s.

0 comments on commit f61769f

Please sign in to comment.