Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Scout » Dynamically generating menus
Dynamically generating menus [message #1128050] Mon, 07 October 2013 09:27 Go to next message
Alex Schroeder is currently offline Alex SchroederFriend
Messages: 38
Registered: February 2010
Location: Zürich, Switzerland
Member

I would like to create a dynamic number of menus based on the result of a lookup call.

In the example below, getTable().setMenus doesn't exist.

The alternative which I had thought possible was to use getMenus and and setMenus on the page instead of its table (and there, setMenus does exist) but it doesn't seem to have an effect. Any idea why this is not straight forward?

  @Override
  protected void execInitPage() throws ProcessingException {

    ArrayList<IMenu> menus = new ArrayList<>();
    menus.addAll(Arrays.asList(getTable().getMenus()));

    SomeLookupCall call = new SomeLookupCall();
    call.setText("A7* - ");
    LookupRow[] rows = null;
    try {
      rows = call.getDataByText();
    }
    catch (ProcessingException e) {
      // do nothing
    }
    if (rows != null) {
      for (LookupRow row : rows) {
        final String s = row.getText();
        IMenu menu = new AbstractMenu() {
          @Override
          public String getText() {
            return s;
          }
          @Override
          protected void execAction() throws ProcessingException {
            doSomethingAwesomeWith(s);
          }
        };
        menus.add(menu);
      }
      getTable().setMenus(menus.toArray(new IMenu[0]));
    }
  }

Re: Dynamically generating menus [message #1128407 is a reply to message #1128050] Mon, 07 October 2013 17:05 Go to previous messageGo to next message
Chris Monty is currently offline Chris MontyFriend
Messages: 26
Registered: July 2013
Junior Member
You can do this by overriding the
protected void injectActionNodesInternal(List<IMenu> nodeList)
method. Just add the menus you want into the nodeList.

Re: Dynamically generating menus [message #1129299 is a reply to message #1128407] Tue, 08 October 2013 13:49 Go to previous messageGo to next message
Alex Schroeder is currently offline Alex SchroederFriend
Messages: 38
Registered: February 2010
Location: Zürich, Switzerland
Member

This is great, thanks.
Re: Dynamically generating menus [message #1545849 is a reply to message #1129299] Sun, 04 January 2015 15:23 Go to previous message
Chris Monty is currently offline Chris MontyFriend
Messages: 8
Registered: January 2015
Junior Member
I just discovered that for the Luna release, any dynamically generated sub-menus should override getConfiguredMenuTypes() and specify the same values as the container menu they are being added to.

e.g. You have a multi-select menu called "Send to ->" which contains a list of recipients loaded from a favourite contacts table page.
Send to -> Harry
           Joe
           Fred
Because the "Send to" menu's getConfiguredMenuTypes() includes TreeMenuType.MultiSelection, so must all sub-menus being added to it. If not, they will simply not appear, and nor will the parent menu. This is somewhat tricky to debug.
Previous Topic:fine-grained access control
Next Topic:Mars version: Make 'bean based TableData' the new default for table fields.
Goto Forum:
  


Current Time: Sat Nov 09 01:29:49 GMT 2024

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

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

Back to the top