Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Scout » AbstractPageWithNodes with default page
AbstractPageWithNodes with default page [message #1738844] Mon, 25 July 2016 12:16 Go to next message
Andreas Christ is currently offline Andreas ChristFriend
Messages: 32
Registered: April 2016
Member
I have some AbstractPageWithNodes in the lefthand menu. And as soon as I click on an item, there will be a list of all child nodes in the main frame. (see screenshot)

Well, I'd like to have the first child of that list opened instead of that redundant child list - which will be displayed in the menu anyhow.

How can i tweak the menu to display the first child in the list?

index.php/fa/26563/0/

[Updated on: Mon, 25 July 2016 12:17]

Report message to a moderator

Re: AbstractPageWithNodes with default page [message #1739526 is a reply to message #1738844] Tue, 02 August 2016 16:46 Go to previous messageGo to next message
Beat Schwarzentrub is currently offline Beat SchwarzentrubFriend
Messages: 205
Registered: November 2010
Senior Member
What you describe is the default behavior of Scout. Each node in the outline tree on the left is linked to a specific content on the right. A page with sub-nodes does not display any content of the sub-nodes by default, because it usually is not semantically appropriate. It is also not easy to tell which is the "first" node, because the child nodes might be ordered or filtered in a special way. For example, when you have a "Persons" folder with "Alice", "Bob" and "Charlie" as child nodes, you don't see Alice's data when you click on "Persons". Instead you see a list of persons, possibly with a search form.

What exactly is your intention? When you select "Baubarkeit", would you like to see the content of "Baubarkeit modifizieren"? Is the number of child nodes of "Baubarkeit" dynamic? Can you have more than one? If you just want to switch between a "view mode" and an "edit mode" of an item, the usual pattern would be to have a detail form with a "read only" form handler on the node page, including an "edit" menu that opens the same form again with a "modify" form handler.

Another possibility is that you want to automatically select the "Baubarkeit modifizieren" node as soon as the user selects "Baubarkeit". This could be achieved by overriding "execPageActivated()" in your node page and programmatically changing the selected node in the outline tree.

If you need further assistance, I suggest that you elaborate the goal you are trying to achieve, and maybe post some code.

Regards,
Beat
Re: AbstractPageWithNodes with default page [message #1739886 is a reply to message #1739526] Fri, 05 August 2016 12:22 Go to previous messageGo to next message
Andreas Christ is currently offline Andreas ChristFriend
Messages: 32
Registered: April 2016
Member
The outline tree works for us as a menu, where users can open "Baubarkeit" and select one of the items below. Here's only one item "Baubarkeit modifizieren". So our idea is, that on click on "Baubarkeit" the menu opens (with "B.M.") AND at the same time the "B. M." page opens. It's just one click less for the user.

Now the user has to click twice, first on "B." and second on "B.M." Well, the menu is almost static, there's no dynamic data loading. So we never have "Alice", "Bob" or "Charlie" in the Menu as child nodes. To prevent any data added to the menu we added
	@Override
	protected boolean getConfiguredLeaf() {
		return true;
	}

to our node pages.

execPageActivated is the correct entry point, but I'm still unable to "start" (display) any page while clicking on the Node. There's no page.startView() method... page.initPage() is not enough.

Do you have an idea?
Re: AbstractPageWithNodes with default page [message #1739936 is a reply to message #1739886] Fri, 05 August 2016 18:23 Go to previous messageGo to next message
Beat Schwarzentrub is currently offline Beat SchwarzentrubFriend
Messages: 205
Registered: November 2010
Senior Member
Andreas,

I'm not quite sure if I understood your intentions. I have made an example of what I think you are trying to achieve:

public class BaubarkeitForm extends AbstractForm {

  public GroupBox getGroupBox() {
    return getFieldByClass(GroupBox.class);
  }

  public class MainBox extends AbstractGroupBox {

    @Order(1000)
    @ClassId("f8727d17-a92c-4a48-ac66-e9c198578a67")
    public class GroupBox extends AbstractGroupBox {

      // ...
    }
  }

  public void startView() {
    startInternal(new ViewHandler());
  }

  public void startModify() {
    startInternal(new ModifyHandler());
  }

  public class ViewHandler extends AbstractFormHandler {

    @Override
    protected void execLoad() {
      getGroupBox().setLabel("View data");
    }
  }

  public class ModifyHandler extends AbstractFormHandler {

    @Override
    protected void execLoad() {
      getGroupBox().setLabel("Modify data");
    }
  }
}


public class BaubarkeitPage extends AbstractPageWithNodes {

  @Override
  protected String getConfiguredTitle() {
    return "Baubarkeit";
  }

// *** Not necessary if child page is activated automatically: ***
//
//  @Override
//  protected Class<? extends IForm> getConfiguredDetailForm() {
//    return BaubarkeitForm.class;
//  }
//
//  @Override
//  protected void startDetailForm() {
//    ((BaubarkeitForm) getDetailForm()).startView();
//  }

  @Override
  protected void execCreateChildPages(List<IPage<?>> pageList) {
    pageList.add(new BaubarkeitModifyPage());
  }

  @Override
  protected void execPageActivated() {
    setExpanded(true);
    // Schedule automatic child selection to allow the current selection to be fully completed
    ModelJobs.schedule(new IRunnable() {
      @Override
      public void run() {
        getTree().selectNode(getChildNode(0));
      }
    }, ModelJobs.newInput(ClientRunContexts.copyCurrent()));
  }
}


public class BaubarkeitModifyPage extends AbstractPageWithNodes {

  @Override
  protected String getConfiguredTitle() {
    return "Baubarkeit modifizieren";
  }

  @Override
  protected boolean getConfiguredLeaf() {
    return true;
  }

  @Override
  protected Class<? extends IForm> getConfiguredDetailForm() {
    return BaubarkeitForm.class;
  }

  @Override
  protected void startDetailForm() {
    ((BaubarkeitForm) getDetailForm()).startModify();
  }
}


When I tried this example I found that changing the tree selection during execPageActivated() does not work. The reason is that the selection of the "Baubarkeit" node has not been fully completed. execPageActivated() is in fact called before the corresponding selection event is fired. Because of that odd behavior, the new selection is always overwritten. I will investigate this issue further and probably make a bug report.

As a workaround, I wrapped the selection code inside a new "model job". This construct is similar to JavaScript's setTimeout() and schedules the inner code for execution as soon as the current action has been fully completed.

I hope that helps.

Regards,
Beat
Re: AbstractPageWithNodes with default page [message #1740010 is a reply to message #1739936] Mon, 08 August 2016 07:14 Go to previous message
Andreas Christ is currently offline Andreas ChristFriend
Messages: 32
Registered: April 2016
Member
YES, this is exactly what we're intended to do: open first child on click on the "parent" node!
Thank you!

This is the code we're searching for:
	@Override
	protected void execPageActivated() {
		setExpanded(true);
		// Schedule automatic child selection to allow the current selection to
		// be fully completed
		ModelJobs.schedule(() -> getTree().selectNode(getChildNode(0)),
				ModelJobs.newInput(ClientRunContexts.copyCurrent()));
	}


Great!
Previous Topic:[neon] Build custom UI element
Next Topic:Multiple instances found error..
Goto Forum:
  


Current Time: Thu Apr 25 18:55:43 GMT 2024

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

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

Back to the top