Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 4 » menu and submenu item dynamically generate using rich client platform(RCP)
menu and submenu item dynamically generate using rich client platform(RCP) [message #1694561] Wed, 06 May 2015 10:16
Lalit Solanki is currently offline Lalit SolankiFriend
Messages: 135
Registered: April 2015
Senior Member
Hi friend,

I am create one rich client platform application now i am trying to menu and submenu dynamically set menu and subitem.

code in plugin.xml file...

<extension point="org.eclipse.ui.menus">
<menuContribution locationURI="popuprg.eclipse.ui.navigator.ProjectExplorer#PopupMenu?after=additions">
<dynamic
class="com.sigasi.MydynamicMenu"
id="com.sigasi.myDynamicMenu">
</dynamic>
</menuContribution>
</extension>


MyDynamicMenu .java
--------------------------------------------
import java.util.Date;

import org.eclipse.jface.action.ContributionItem;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.MenuItem;

public class MyDynamicMenu extends ContributionItem {

public MyDynamicMenu() {
}

public MyDynamicMenu(String id) {
super(id);
}

@Override
public void fill(Menu menu, int index) {
//Here you could get selection and decide what to do
//You can also simply return if you do not want to show a menu

//create the menu item
MenuItem menuItem = new MenuItem(menu, SWT.CHECK, index);
menuItem.setText("My menu item (" + new Date() + ")");
menuItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
//what to do when menu is subsequently selected.
System.err.println("Dynamic menu selected");
}
});
}
}

please help me friend how to create more menu and submenu item dynamically ...


Lalit
Previous Topic:Closed view displayed again after restarting application
Next Topic:InjectionException on E4 app w/ CompatibilityView
Goto Forum:
  


Current Time: Mon Dec 18 16:55:32 GMT 2017

Powered by FUDForum. Page generated in 0.01480 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software