Menu contribution problem in project Explorer [message #1213816] |
Wed, 27 November 2013 07:03  |
Eclipse User |
|
|
|
Dear all,
I have developed an Acceleo generator plugin able to generate WordML documentation from UML models. My UML editor is papyrus 0.10.0.
I would like to execute a command from a popup menu (right click) when I select the UML file of the Papyrus model. I have tested the commands and they work fine.
However, in the project explorer of papyrus, my popup doesn't appear. When I'm a regular project with an classic UML file, I see my popup. Here is my plugin.xml:
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
<extension
point="org.eclipse.ui.menus">
<menuContribution
locationURI="popup:org.eclipse.ui.navigator.ProjectExplorer#PopupMenu?after=additions">
<menu
icon="icons/document.gif"
id="doc_generators"
label="Generate documents"
tooltip="Utilities able to generate documentation">
</menu>
</menuContribution>
<menuContribution
locationURI="popup:doc_generators?after=additions">
<command
commandId="com.spacebel.acceleo.uml.to.wordml.ui.generateADD"
label="Generate ADD (WordML)"
mode="FORCE_TEXT"
style="push"
tooltip="Generation of the ADD document in WordML">
<visibleWhen>
<with
variable="selection">
<iterate
ifEmpty="false">
<instanceof
value="org.eclipse.core.resources.IResource">
</instanceof>
<test
property="org.eclipse.core.resources.name"
value="*.uml">
</test>
</iterate>
</with>
</visibleWhen>
</command>
<command
commandId="com.spacebel.acceleo.uml.to.wordml.ui.generateSRD"
label="Generate SRD (WordML)"
mode="FORCE_TEXT"
style="push"
tooltip="Generation of the SRD document in WordML">
<visibleWhen>
<with
variable="selection">
<iterate
ifEmpty="false">
<test
property="org.eclipse.core.resources.name"
value="*.uml">
</test>
<instanceof
value="org.eclipse.core.resources.IResource">
</instanceof>
</iterate>
</with>
</visibleWhen>
</command>
</menuContribution>
</extension>
<extension
point="org.eclipse.ui.commands">
<command
id="com.spacebel.acceleo.uml.to.wordml.ui.generateADD"
name="Generate ADD (WordML)">
</command>
<command
id="com.spacebel.acceleo.uml.to.wordml.ui.generateSRD"
name="Generate SRD (WordML)">
</command>
</extension>
<extension
point="org.eclipse.ui.handlers">
<handler
class="com.spacebel.acceleo.uml.to.wordml.ui.GenerateSRDHandler"
commandId="com.spacebel.acceleo.uml.to.wordml.ui.generateSRD">
</handler>
<handler
class="com.spacebel.acceleo.uml.to.wordml.ui.GenerateADDHandler"
commandId="com.spacebel.acceleo.uml.to.wordml.ui.generateADD">
</handler>
</extension>
</plugin>
Does anyone have an idea ? I guess that the instanceOf in my test or the URI is not correct ...
In advance, thanks for your help.
Regards;
|
|
|
|
|
Re: Menu contribution problem in project Explorer [message #1216485 is a reply to message #1216030] |
Thu, 28 November 2013 08:53   |
Eclipse User |
|
|
|
Hi Johan,
I'm using this piece of code right now, so, it definitely works. There should not be a "ClassCastException", because "Adapt" is not a Cast (Unless there is another piece of code/extension, elsewhere, which tries to cast the SubResourceFile to an IFile instead of Adapting it).
You should try to define your menu first, and, once it appears correctly, add the command/handler, and see at which point it actually fails.
Regards,
Camille
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.29371 seconds