Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » scout » Dynamically generating menus
Dynamically generating menus [message #1128050] Mon, 07 October 2013 05:27 Go to next message
Alex Schroeder is currently offline Alex Schroeder
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 13:05 Go to previous messageGo to next message
Chris Monty is currently offline Chris Monty
Messages: 24
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 09:49 Go to previous message
Alex Schroeder is currently offline Alex Schroeder
Messages: 38
Registered: February 2010
Location: Zürich, Switzerland
Member

This is great, thanks.
Previous Topic:How to find resource files in server?
Next Topic:Question to Bug 414535
Goto Forum:
  


Current Time: Thu Jul 31 07:38:26 EDT 2014

Powered by FUDForum. Page generated in 0.02262 seconds