{"id":77,"date":"2008-08-04T15:45:17","date_gmt":"2008-08-04T13:45:17","guid":{"rendered":"http:\/\/andi-smirre.ath.cx\/blog\/?p=77"},"modified":"2008-08-29T22:54:56","modified_gmt":"2008-08-29T20:54:56","slug":"tutorial-eclipse-dynamic-popup-menus","status":"publish","type":"post","link":"https:\/\/www.andismirre.de\/blog\/?p=77","title":{"rendered":"Tutorial: Eclipse dynamic popup menus"},"content":{"rendered":"<div class=\"pdfprnt-buttons pdfprnt-buttons-post pdfprnt-top-right\"><a href=\"https:\/\/www.andismirre.de\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fposts%2F77&print=pdf\" class=\"pdfprnt-button pdfprnt-button-pdf\" target=\"_blank\" ><img decoding=\"async\" src=\"http:\/\/www.andismirre.de\/blog\/wp-content\/plugins\/pdf-print\/images\/pdf.png\" alt=\"image_pdf\" title=\"View PDF\" \/><\/a><a href=\"https:\/\/www.andismirre.de\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fposts%2F77&print=print\" class=\"pdfprnt-button pdfprnt-button-print\" target=\"_blank\" ><img decoding=\"async\" src=\"http:\/\/www.andismirre.de\/blog\/wp-content\/plugins\/pdf-print\/images\/print.png\" alt=\"image_print\" title=\"Print Content\" \/><\/a><\/div><p>This tutorial describes how to create dynamic popup menus in Eclipse using extension-point &#8220;org.eclipse.ui.popupMenus&#8221;.<\/p>\n<p>Some applications require dynamic menus for dynamic contents. Sometimes there is no benefit to declare all possible actions in the plugin manifest as there is no way to know all possibilities. In those cases dynamic menus are required when the menu structure depends on the selection context of the workbench. This tutorial will show you how to create a dynamic menu during runtime contributed on any view where a IFile resource is selected without a declaration of the menu inside the plugin manifest.<\/p>\n<ul>\n<li>First of all, you have to create a plugin project using the extension point &#8220;org.eclipse.ui.popupMenus&#8221;.<\/li>\n<\/ul>\n<p align=\"center\"><img loading=\"lazy\" decoding=\"async\" width=\"500\" height=\"500\" id=\"image74\" style=\"width: 500px; height: 500px\" alt=\"create new popup-menu extension\" src=\"http:\/\/andi-smirre.ath.cx\/blog\/wp-content\/uploads\/2008\/08\/create_extension.jpg\" \/><\/p>\n<ul>\n<li>\n<div align=\"left\">Configure your new extension with your own values<\/div>\n<\/li>\n<\/ul>\n<p><img decoding=\"async\" id=\"image75\" style=\"width: 500px; height: 500px\" alt=\"configure extension\" src=\"http:\/\/andi-smirre.ath.cx\/blog\/wp-content\/uploads\/2008\/08\/configure_extension.jpg\" \/><\/p>\n<ul>\n<li>\n<div align=\"left\">Remove all content of the run method, as our action will not perform anything and will just be the root container of our submenu.<\/div>\n<\/li>\n<\/ul>\n<p><img decoding=\"async\" id=\"image76\" style=\"width: 320px; height: 180px\" alt=\"empty run method\" src=\"http:\/\/andi-smirre.ath.cx\/blog\/wp-content\/uploads\/2008\/08\/erase-run-method.jpg\" \/><\/p>\n<ul>\n<li>\n<div align=\"left\">On each selection change event, ensure that our action has an appropriate menu creator to build the items of our submenu or to build other submenus.<\/div>\n<\/li>\n<\/ul>\n<p><img decoding=\"async\" id=\"image78\" style=\"width: 560px; height: 370px\" alt=\"set a menu creator to the action\" src=\"http:\/\/andi-smirre.ath.cx\/blog\/wp-content\/uploads\/2008\/08\/selectionchanged.jpg\" \/><\/p>\n<ul>\n<li>\n<div align=\"left\">Now at the end, set our action to be a pulldown command. Therefore open the plugin manifest editor of our project and select the action style to &#8220;pulldown&#8221;.<\/div>\n<\/li>\n<\/ul>\n<p><img decoding=\"async\" id=\"image84\" style=\"width: 300px; height: 200px\" alt=\"category where to select pulldown style\" src=\"http:\/\/andi-smirre.ath.cx\/blog\/wp-content\/uploads\/2008\/08\/pulldown_category.jpg\" \/><\/p>\n<p><img decoding=\"async\" id=\"image85\" style=\"width: 300px; height: 130px\" alt=\"the pulldown selection\" src=\"http:\/\/andi-smirre.ath.cx\/blog\/wp-content\/uploads\/2008\/08\/pulldown_selection.jpg\" \/><\/p>\n<ul>\n<li>\n<div align=\"left\">To test our new menu, just start a Eclipse workbench using our plugin and after that you can see something like the following.<\/div>\n<\/li>\n<\/ul>\n<p><img decoding=\"async\" id=\"image82\" style=\"width: 470px; height: 100px\" alt=\"voilla, it works\" src=\"http:\/\/andi-smirre.ath.cx\/blog\/wp-content\/uploads\/2008\/08\/voilla1.jpg\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>This tutorial describes how to create dynamic popup menus in Eclipse using extension-point &#8220;org.eclipse.ui.popupMenus&#8221;. Some applications require dynamic menus for dynamic contents. Sometimes there is no benefit to declare all possible actions in the plugin manifest as there is no way to know all possibilities. In those cases dynamic menus are required when the menu [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-77","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/www.andismirre.de\/blog\/index.php?rest_route=\/wp\/v2\/posts\/77","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.andismirre.de\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.andismirre.de\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.andismirre.de\/blog\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.andismirre.de\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=77"}],"version-history":[{"count":14,"href":"https:\/\/www.andismirre.de\/blog\/index.php?rest_route=\/wp\/v2\/posts\/77\/revisions"}],"predecessor-version":[{"id":102,"href":"https:\/\/www.andismirre.de\/blog\/index.php?rest_route=\/wp\/v2\/posts\/77\/revisions\/102"}],"wp:attachment":[{"href":"https:\/\/www.andismirre.de\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=77"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.andismirre.de\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=77"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.andismirre.de\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=77"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}