saed991
saed991

Reputation: 21

eclipse plugin: how to add checkboxes dropdownlist

i need to add checkboxes dropdownlist to an eclipse plug-in , i want to add checkboxes dropdownlist that is the same as eclipse ide "customize perspective button " dropdownlist which it look like this http://s15.postimg.org/vwr4wk77f/dropdown.png

I have created my eclipse plugin using plugin.xml, I am really new to xml, so i have managed to create the plugin with a pulldown list,but i can't find an element in xml which can help me with the checkboxes

I have searched almost in every website for information or help, i haven't found anything that can help, so please guy I really appreciate if you give me advises about this

my plugin code look like this :

<plugin>


<extension point="org.eclipse.ui.menus">
    <menuContribution locationURI="toolbar:org.eclipse.ui.main.toolbar?after=additions">
        <toolbar id="my.Toolbar">
        </toolbar>
    </menuContribution>


      </extension>

   <extension point="org.eclipse.ui.commands">
      <category
            id="TRE.projects.commands.category"
            name="%category.name.0">
      </category>

      <category
            id="TRE.projects.commands.MultiCategory"
            name="MultiCategory">
      </category>

      <command
            name="Configuration1"
            categoryId="TRE.projects.commands.MultiCategory"
            id="my.command1">
      </command>

      <command
            name="Configuration2"
            categoryId="TRE.projects.commands.MultiCategory"
            id="my.command2">
      </command>

   </extension>

   <extension  point="org.eclipse.ui.handlers">


      <handler
            commandId="my.command1"
            class="TRE.projects.handlers.SampleHandler">
      </handler>

      <handler
            commandId="my.command2"
            class="TRE.projects.handlers.SampleHandler">
      </handler>


   </extension>




   <extension  point="org.eclipse.ui.menus">

    <menuContribution locationURI="toolbar:my.Toolbar?after=additions">
            <command
                  commandId="my.command1"
                  icon="icons/sample.gif"
                  id="my.Toolbar.command1"
                  style="pulldown"
                  tooltip="TRE Plugin">
            </command>
      </menuContribution>

      <menuContribution
            locationURI="menu:org.eclipse.ui.main.popup?after=additions">
         <menu
               id="TRE.projects.menus.sampleMenu"
               label="%menu.label.0"
               mnemonic="%menu.mnemonic.0">
            <command
                  commandId="TRE.projects.commands.sampleCommand"
                  id="TRE.projects.menus.sampleCommand"
                  mnemonic="%command.mnemonic.0"
                  style="toggle">
            </command>
         </menu>
      </menuContribution>

Upvotes: 1

Views: 1355

Answers (1)

greg-449
greg-449

Reputation: 111142

You need to add command elements to the menuContribution and use the style=toggle attribute.

<menuContribution
      locationURI="toolbar:org.eclipse.ui.main.toolbar?after=additions">
    <command
           commandId="my.command1"
           label="Simple Item"
           style="toggle">
     </command>
</menuContribution>

Upvotes: 3

Related Questions