eclipse - How do I hide Menu whose children are hidden? -
i have menus on main menu in eclipse 4 application project children contributed of fragments different plugins. have applied permissions on sub-menus according logged in user. problem after no sub-menu of menu has permission , none of them visible still menu visible. want hide menu. suggestions.
update: class model processor , plugin.xml
public class menuprocessor { public menuprocessor(){} @execute public void execute(@named("application_luna.menu.contract(fo)") mmenu menu) { if(menu.getchildren().isempty()) menu.setvisible(false); } }
<extension id="com.swte.approval.ui.fragment" point="org.eclipse.e4.workbench.model"> <fragment uri="fragment.e4xmi"> </fragment> <processor apply="always" beforefragment="false" class="com.swte.approval.ui.menuprocessor1"> <element id="application_luna.menu.contract(fo)"> </element> </processor>
`
you processor on menu.
you declare processor in plugin.xml part of 'org.eclipse.e4.workbench.model' extension point.
<extension id="playerfragment" point="org.eclipse.e4.workbench.model"> ... other elmeents <processor beforefragment="false" class="package.menuprocessor"> <element id="menu.id"> </element> </processor> </extension>
the declaration names class run , model element applies to.
the processor code inject named menu , make invisible if there no children. (not tested):
public class menuprocessor { @inject @named("menu.id") private mmenu menu; @execute public void execute() { if (menu.getchildren().isempty()) menu.setvisible(false); }
note: must inject menu element field in class, specifying parameter on execute
method not work. because element available injection when class constructed.
Comments
Post a Comment