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 8983827
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T20:56:17+00:00 2026-06-15T20:56:17+00:00

In eclipse I have commands defined for buttons in the main button toolbar they

  • 0

In eclipse I have commands defined for buttons in the main button toolbar they have. I have one command/button in there that’s set as a pulldown button and I’d like to programmatically add options to it. Kinda like how you can hit the little drop down button on the play button in eclipse and see different run scenarios. I want to be able to add options like that to my pulldown menu. I can’t do it through the plugin editor because I need to generate the menu options dynamically.

So say I have the following pulldown button defined in my plugin.xml file. How do I add options to the pull down programmatically?

 <menuContribution
        allPopups="false"
        locationURI="toolbar:org.eclipse.ui.main.toolbar">
     <toolbar
           id="com.company.gui.base.toolBarMain">
        <command
              commandId="com.company.gui.base.command1"
              icon="icons/magnifier.png"
              id="com.company.gui.base.toolBarMain.monitor"
              label="Im a pulldown menu"
              style="pulldown">
        </command>
     </toolbar>
  </menuContribution>
  • 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-15T20:56:18+00:00Added an answer on June 15, 2026 at 8:56 pm

    Please find the below code.

    private void addContextMenu(SampleContributionFactory fac) {
         final IMenuService menuService = (IMenuService) PlatformUI.getWorkbench().getService (IMenuService.class);
         menuService.addContributionFactory(fac);
    }
    
    class SampleContributionFactory extends AbstractContributionFactory{
    
        SampleContributionFactory(final String menuID) {
            super("menu:" + menuID, null);
        }
    
        @Override
        public void createContributionItems(IServiceLocator serviceLocator,
                IContributionRoot additions) {      
            // add Command Contribution item
            additions.addContributionItem(<YOUR CONTRIBUTION ITEM>, null);
        // add one more Command Contribution item
        ....
        } 
    }
    

    Now create an object of SampleContributionFactory as below.

      SampleContributionFactory fac = new SampleContributionFactory ("com.company.gui.base.toolBarMain.monitor");
    

    and call the method

    addContextMenu(fac);
    

    TODO : add command contribution items in the SampleContributionFactory as required by you.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have eclipse 3.7.2 to work on PHP projects that are on remote Linux
I have Eclipse set up fairly nicely to run the G++ compiler through Cygwin.
In Eclipse I have two projects with the same package structure. In one of
I mostly use Eclipse but have mentionned Netbeans on my cv. Are there any
I would like to add a gap between two buttons on an Eclipse toolbar.
Does eclipse have the ability to load external file that contains thousands of lines
I have one parent parent maven project that defines dependencies. Then I have my
I have multiple projects but only one with a Main class. The one with
I have a type that extends DeleteResourceAction . Eclipse gives me following warning: An
Does Eclipse have an analog to Visual Studio's Immediate Window, a window where I

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.