Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » Adding a poup menu contribution to a JDT editor
Adding a poup menu contribution to a JDT editor [message #637392] Fri, 05 November 2010 10:52 Go to next message
Chris  is currently offline Chris Friend
Messages: 5
Registered: October 2010
Junior Member
Hello,

I have the following extension menu contribution:

 <menuContribution
            locationURI="popup:org.eclipse.ui.popup.any?after=additions">
         <command
               commandId="uk.ac.aber.dcs.softwarefmea.plugin.traceFaultPropagation"
               icon="icons/sample.gif"
               style="push">
         </command>
      </menuContribution>


This allows me to display my command on every popup menu. However, I want to restrict this in several ways:

o To only display in JDT editor windows and
o Only display for selected IField and ILocalVariable elements

I've tried various combinations of selectors, but can't seem to get it right. Should I be adding to a JDT menu popup? Any help here would be appreciated

Thanks
Re: Adding a poup menu contribution to a JDT editor [message #637404 is a reply to message #637392] Fri, 05 November 2010 12:02 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

Chris wrote:
>
> This allows me to display my command on every popup menu. However, I
> want to restrict this in several ways:
>
> o To only display in JDT editor windows and

You can use a specific popup id if you can find it, like
"popup:#CompilationUnitEditorContext?after=additions" (Java editor) or
you can specify editorIds in your visibleWhen:
<with variable="activeEditorId">
<equals value="org.eclipse.jdt.ui.CompilationUnitEditor"/>
</with>

> o Only display for selected IField and ILocalVariable elements

<with variable="activeMenuSelection">
<count value="1"/>
<iterate ifEmpty="false">
<!-- your check goes here -->
</iterate>
</with>

If activeMenuSelection is an ITextSelection, you would have to write a
property tester so you could convert it to the appropriate AST element.

PW

--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Platform_Expression_Framework
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
http://help.eclipse.org/galileo/index.jsp?topic=/org.eclipse .platform.doc.isv/guide/workbench.htm


Re: Adding a poup menu contribution to a JDT editor [message #637464 is a reply to message #637392] Fri, 05 November 2010 16:07 Go to previous message
Chris  is currently offline Chris Friend
Messages: 5
Registered: October 2010
Junior Member
Thanks Paul, that was really helpful. Problem solved.
Chris
Previous Topic:How to show // TODO marked files in project explorer?
Next Topic:The project: xxxxxxx which is referenced by the classpath, does not exist.
Goto Forum:
  


Current Time: Fri Mar 29 09:50:00 GMT 2024

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

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

Back to the top