hallvard / plantuml

Embed UML diagrams in files and view them in Eclipse
http://plantuml.sourceforge.net/
212 stars 58 forks source link

Menu contributions to PlantUML view no longer possible #87

Closed steghoja closed 5 years ago

steghoja commented 5 years ago

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 94a1291f 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.

hallvard commented 5 years ago

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.

hallvard commented 5 years ago

Perhaps the IMenuService can be used: https://help.eclipse.org/luna/index.jsp?topic=%2Forg.eclipse.platform.doc.isv%2Freference%2Fapi%2Forg%2Feclipse%2Fui%2Fmenus%2FIMenuService.html

steghoja commented 5 years ago

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.

hallvard commented 5 years ago

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.

steghoja commented 5 years ago

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.

hallvard commented 5 years ago

Close, should be fixed in release 1.1.23