Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

CascadingMenu

HOw to show menu within menu in GMF?

To get nested menus while dragging a connection out from a node in GMF we need to make our own command that extends PopupMenuCommand.

The Steps will be -

1. Override the method doExecuteWithResult().
2. Inside the method we would need to call another method createPopupMenu().
3. To populate the contents of the popupmenu we need the connection and endMenu contents.
4. To get the endMenu Contents write a method similar to :-
protected List getEndMenuContent(Object connectionItem) {
  ModelingAssistantService mInstance = ModelingAssistantService.getInstance();
  if (connectionItem instanceof IElementType) {
  IElementType connectionType = (IElementType) connectionItem;
  List returneMe   = new ArrayList();
  List menuContent = mInstance.getTypesForTarget(getKnownEnd(),connectionType);
  for (int i = 0; i < menuContent.size(); i++) {
  if (menuContent.get(i) instanceof IElementType) {
  returneMe.add(menuContent.get(i));
  }else 
  {returneMe.add(new PopupMenu.CascadingMenu({name of the catrgory},
  new PopupMenu((List) (menuContent.get(i)),
  getConnectionAndEndLabelProvider(menuContent.get(i)))));
  }
  }
  returneMe.add(EXISTING_ELEMENT);
  return returneMe;
 }
 return Collections.EMPTY_LIST;
}

Once you are done with these stpes then go ahead with the normal procedure to call this command in the ContainerNodeEditPolicy of your projetct.

--arpit.the.star@gmail.com 01:36, 7 September 2007 (EDT)

Back to the top