Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.
Hi all, please see this major site announcement: https://www.boards.ie/discussion/2058427594/boards-ie-2026

Eclipse popup menu item enablement

  • 06-12-2011 10:52AM
    #1
    Registered Users, Registered Users 2 Posts: 28


    Hi,

    I am fairly new to eclipse plugin development and want to disable an eclipse popup menu item base on a particular property value of the selected object. The property is private so I need to use a getter method to access the property.

    Is this possible using the enablement tags in the plugin XML? I.e. can I call the getter method from there to check if the return value is false?

    E.g. Can I do something like this in my plugin.xml
    <extension point="org.eclipse.ui.popupMenus">
             <objectContribution id="com.somedomain.MyPlugin.theId" >
             <enablement>
                        <and>
                            <objectClass name ="com.somedomain.SelectedObject"/>
                            <objectState name="com.somedomain.SelectedObject.getPropertyValue()" value="false"/>
                        </and>
             </enablement>      
          
          </objectContribution>
    


Comments

  • Registered Users, Registered Users 2 Posts: 5,015 ✭✭✭Ludo


    Why not just add the menu for all relevant object types in the plugin.xml file and then in the menu handlers isEnabled() method, decide whether it is enabled or not for each particular case?


  • Registered Users, Registered Users 2 Posts: 28 harry1


    Thanks for the reply!

    I figured it out anyway. I just added the enablements to my actions instead of the object contribution and used the getter method of the object class for the variable I am interested in.


Advertisement
Advertisement