Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8204835
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T08:01:06+00:00 2026-06-07T08:01:06+00:00

In my plugin, I have a pop up menu with menu item ‘X’ and

  • 0

In my plugin, I have a pop up menu with menu item ‘X’ and I want to add submenu to this menu item

and the number and labels of menu items in the submenu and their action will change.

I think I can’;t do this from plugin.xml, so how to do this programatically?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T08:01:08+00:00Added an answer on June 7, 2026 at 8:01 am

    In your plugin.xml, under org.eclipse.ui.menus, add a menuContribution that refers to the id of your “root” menu, i.e. the menu that you want to have your submenus attached to (in this case, menu:myDynamicMenuRoot):

    <menuContribution
        allPopups="true"
        class="com.myCode.menus.MyDynamicMenuContributions"
        locationURI="menu:myDynamicMenuRoot">
    </menuContribution>
    

    Note that allPopups=”true” ensures that your submenus will be added to any menu with the id myDynamicMenuRoot that you add anywhere in your application.

    Finally, create a class extending ExtensionContributionFactory, whose job it will be to create your dynamic submenu items. Here I add items based on commands I have defined in my plugin.xml:

    public class MyDynamicMenuContributions extends ExtensionContributionFactory {
        private static final ImageDescriptor GREEN_STAR = Plugin.getImageDescriptor("icons/green_star.png");
    
        @Override
        public void createContributionItems(IServiceLocator serviceLocator, IContributionRoot additions) {
            // build a couple of command-based contribution parameters
            CommandContributionItemParameter pAA = new CommandContributionItemParameter(
                serviceLocator,
                "Submenu_CommandAA",
                "my.package.command.myCommandAA",
                SWT.PUSH);
            pAA.icon = GREEN_STAR;
            pAA.label = "Command AA";
    
            CommandContributionItemParameter pBB = new CommandContributionItemParameter(
                serviceLocator,
                "Submenu_CommandBB",
                "my.package.command.myCommandBB",
                SWT.PUSH);
            pBB.icon = GREEN_STAR;
            pBB.label = "Command BB";
    
            // create actual contribution items and add them to the given additions reference
            CommandContributionItem itemAA = new CommandContributionItem(pAA);
            itemAA.setVisible(true);
            additions.addContributionItem(itemAA, null);
    
            CommandContributionItem itemBB = new CommandContributionItem(pBB);
            itemBB.setVisible(true);
            additions.addContributionItem(itemBB, null);
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In eclipse's plugin extentions we can have pop up menus applicable for particular item
I use plugin wp-type, there I can make costum pages, this plugin have function
I've created a firebreath plugin on mac os which HAVE TO pop up a
I wrote a plugin in Firebreath, and I have a msi written. I want
I am using a javascript plugin called pop (http://pop.seaofclouds.com/) to have a drop down
Does jQuery validation plugin have some dependencies? For example, I saw blogposts that said
I am building a plugin and have certain methods in the Model of the
Attempting to build a C# NPAPI plugin I have found a tutorial which describes
I'm writing a WP plugin and have an issue. In the pludin's settings area,
I am using Metafizzy's Isotope plugin and have it set up to filter using

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.