hallvard/plantuml

Menu contributions to PlantUML view no longer possible

steghoja opened this issue · 6 comments

In previous versions of PlantUML, it was possible to extend the menu in the action bar like this:

<extension
         point="org.eclipse.ui.menus">
      <menuContribution
            locationURI="menu:net.sourceforge.plantuml.eclipse.views.PlantUmlView?after=additions">
...

The changes introduced in 94a1291 prevent this since menu.setRemoveAllWhenShown(true); is set in PlantUmlView.java, line 265. This means that the menu contributions disappear.

Suggested solution:
An alternative solution is to define the action bar menu contributions of the PlantUmlView in the plugin.xml. This way, additions by others are maintained.

I didn't consider that possibility, I'm sorry! It may be possible to add such contributions programmatically, below the diagram items, e.g. using techniques exemplified here: https://wiki.eclipse.org/Menu_Contributions/Problems_View_Example. Alternatively, I could move the diagram items to a toolbar dropdown.

I experimented with this a bit and in particular with the solution provided at: https://www.vogella.com/tutorials/EclipseCommandsAdvanced/article.html#defining-commands-at-runtime

Unfortunately, this did not work. It seems like the menu ID I am using is incorrect. I used to be able to add contributions for menu:net.sourceforge.plantuml.eclipse.views.PlantUmlView but that locationURI is no longer working. If I look at the MenuManager that is returned by getViewSite().getActionBars().getMenuManager(), it's ID is null.

By the way, while I see the little triangle that indicates that there should be an action bar menu, clicking on this does not show a menu, even in the vanilla PlantUML view.

The menu is (supposed to be) cleared and (re)populated with the diagrams found in the current editor when you click it (given that the editor supports iterating over alle diagrams). If no diagrams are provided, the menu is empty.

Right, I figured that out now after stepping through the execution. The problem remains that adding new menu contributions, regardless of how is being undone due to menu.setRemoveAllWhenShown(true);. I have found a workaround for this and will send a pull request shortly.

Close, should be fixed in release 1.1.23