How to control whether the action in the eclipse view is displayed (or available)

Source: Internet
Author: User

During Eclipse plug-in development, we sometimes have the following requirement: we need to add popupmeun to the view. If we want only the corresponding action of the leaf node,

 

 

 

Instead of leaf nodes or empty rows, the system does not respond to the action. For example, the following figure does not show:

 

 


You can rewritefillContextMenu(ImenumanagerMenu) method, simplified code:

 

public void fillContextMenu(final IMenuManager menu) {final MenuManager menuManager = (MenuManager) menu;menu.setRemoveAllWhenShown(true);menu.addMenuListener(new IMenuListener(){public void menuAboutToShow(IMenuManager manager) {if(){//if the select item is empty.do nothing              }else{//if the select item isn't ScanPatternEntity,availablemenuManager.add(new NewExpainAction());}}});}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.