Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Plugin Development Environment (PDE) » Adding menu item in contextmenu to appear in both Project Explorer and CEditor ?
Adding menu item in contextmenu to appear in both Project Explorer and CEditor ? [message #974849] Wed, 07 November 2012 11:29
RajuBabu Gurram is currently offline RajuBabu GurramFriend
Messages: 1
Registered: September 2012
Junior Member
Hi,

I'm new to plug-in development in Eclipse.I am trying to add a menu item "compile" to popup menu in Project Explorer and C Editor area in Helios. And it should visible only when if the resource is .c or .cpp file. I'm doing it as follow

<extension point="org.eclipse.ui.commands">
<command description="Compile sigle file"
id="com.abc.xyz.compilesinglefile"
name="Compile">
</command>
</extension>
<extension point="org.eclipse.core.expressions.definitions">
<definition id="com.abc.xyz.compiledefid">
<adapt type="org.eclipse.core.resources.IResource">
<or>
<test property="org.eclipse.core.resources.name" value="*.c"/>
<test property="org.eclipse.core.resources.name" value="*.cpp"/>
</or>
</adapt>
</definition>
</extension>
<extension point="org.eclipse.ui.menus">
<menuContribution locationURI="popup:org.eclipse.ui.popup.any?after=additions">
<command commandId="com.abc.xyz.compilesinglefile" style="push">
<visibleWhen>
<or>
<with variable="activeEditorInput">
<reference definitionId="com.abc.xyz.compiledefid"/>
</with>
<with variable="selection">
<iterate ifEmpty="false">
<reference definitionId="com.abc.xyz.compiledefid"/>
</iterate>
</with>
</or>
</visibleWhen>
</command>
</menuContribution>

It is working partially correct but behaves strangely.

1) First, if I click on files that are my type in Project Explorer, its working good and "Compile" is visible. Clicking on other files and folders the command is not visible, it is correct.

2) But, if I click on files that are my type in Editor Area, command visible. Then I tried to go back to Project Explorer and clicking on files and folders that are NOT my type, shows the command "Compile" in popup menu. In other cases working good except this case.

What is wrong with the code here?
Please help me on this.
Thanks in advance!!

Previous Topic:Possible bug in Target Platform handling
Next Topic:Target Editor often fails to update locations
Goto Forum:
  


Current Time: Fri Apr 19 23:20:18 GMT 2024

Powered by FUDForum. Page generated in 0.02270 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top