• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

Menu and menuitem dynamically using rich client platform(RCP)

 
Greenhorn
Posts: 12
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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="popup:org.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...

 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!