Skip to main content



      Home
Home » Eclipse Projects » Plugin Development Environment (PDE) » Pop-up context menus in different views
Pop-up context menus in different views [message #1772954] Tue, 19 September 2017 08:23
Eclipse UserFriend
Hi,

I'm quite new to teh Eclipse plugin architecture and I'm having difficulty figuring out how to use the extensions for creating context-sensitive menus in various eclipse views.

I used the "custom template -> hello world command contribution" example project as a starting point, and then looked at Vogella: http://www.vogella.com/tutorials/EclipseCommands/article.html#tutorial-commands-and-menus

So I have something which sort of works; but the problem is it only works in the "Project Explorer" view. I want the same context menu to be available in other views (say the "Package Explorer" for example). What is the best way to achieve this?

I also want to filter out (make the context menu not visible) anything but directories named "Steps", again this works in the project explorer, but I don't undestand the syntax used to do this. Can anybody explain how the filter is working (i.e. the "iterate", "adapt", "test" elements).

My current plugin.xml looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>

   <extension
         point="org.eclipse.ui.commands">
      <category
            name="Sample Category"
            id="TestPopUpMenu.commands.category">
      </category>
      <command
            name="Sample Command"
            categoryId="TestPopUpMenu.commands.category"
            id="TestPopUpMenu.commands.sampleCommand">
      </command>
   </extension>
   <extension
         point="org.eclipse.ui.handlers">
      <handler
            commandId="TestPopUpMenu.commands.sampleCommand"
            class="testpopupmenu.handlers.SampleHandler">
      </handler>
   </extension>
   <extension
         point="org.eclipse.ui.bindings">
      <key
            commandId="TestPopUpMenu.commands.sampleCommand"
            contextId="org.eclipse.ui.contexts.window"
            sequence="M1+6"
            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration">
      </key>
   </extension>
   <extension
         point="org.eclipse.ui.menus">
      <menuContribution
            allPopups="false"
            locationURI="popup:org.eclipse.ui.popup.any">
         <menu
               id="TestPopUpMenu.menus.sampleMenu"
               label="Sample Menu"
               mnemonic="m">
            <command
                  commandId="TestPopUpMenu.commands.sampleCommand"
                  id="TestPopUpMenu.menus.sampleCommand"
                  mnemonic="S">
               <visibleWhen
                     checkEnabled="false">
                  <iterate>
                     <adapt
                           type="org.eclipse.core.resources.IResource">
                        <test
                              property="org.eclipse.core.resources.name"
                              value="Steps">
                        </test>
                     </adapt>
                  </iterate>
               </visibleWhen>
            </command>
         </menu>
      </menuContribution>
   </extension>

</plugin>


Thanks in advance :)
Previous Topic:How to Activate a Plugin when leaving the "New Project" Wizard
Next Topic:IDE contribution in PDE Built
Goto Forum:
  


Current Time: Mon Jul 07 11:19:35 EDT 2025

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

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

Back to the top