Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » scout » child page do not decorate untll it's been clicked in an outline based application
child page do not decorate untll it's been clicked in an outline based application [message #1007620] Wed, 06 February 2013 18:24 Go to next message
Boy D'Poy is currently offline Boy D'PoyFriend
Messages: 56
Registered: October 2011
Member
Let suppose that I have these two classes in an outline based application.


public class MyNodePage extends AbstractPageWithNodes {

...

private String id;

...

// @FormData get/setId ...


@Override
protected void execDecorateCell(final Cell cell) {

// some decoration code
}

...
}



public class MyTablePage extends AbstractPageWithTable<MyTablePage.Table> {

...

@Override
protected IPage execCreateChildPage(final ITableRow row) throws ProcessingException {

final MyNodePage childPage = new MyNodePage();

...

childPage.setId((String) row.getCell(this.getTable().getIDColumn()).getValue());

...

return childPage;
}
}


when running my application, everything runs fine and cool, except that I have to click the child node before I get the decoration portion of code being executed, otherwise, the node is labelled as the first column of the TablePage.


what dit I miss, and how ist it possible to get the children nodes automatically decorated once the parent node is expanded?


[System : scout 3.8.1]


thank you!



Once You Go Scout, You Never Come Out!
Re: child page do not decorate untll it's been clicked in an outline based application [message #1007703 is a reply to message #1007620] Thu, 07 February 2013 08:13 Go to previous messageGo to next message
Jeremie Bresson is currently offline Jeremie BressonFriend
Messages: 790
Registered: October 2011
Senior Member
This is a (not so well documented) desired behavior:

When the nodes representing the pages are created in the main windows, a "virtual Page" is created. This virtual page is like a proxy. On click on this virtual page, the corresponding real child page is instantiated (meaning loaded and decorated).
You can influence the virtual page decoration: have a look at execCreateVirtualChildPage(ITableRow) in AbstractPageWithTable.

The virtual page mechanism was added some years ago, because we had performance problem (in case it is expensive to load the child page). I am not sure it is possible to bypass the mechanism.
Re: child page do not decorate untll it's been clicked in an outline based application [message #1007725 is a reply to message #1007703] Thu, 07 February 2013 10:24 Go to previous messageGo to next message
Boy D'Poy is currently offline Boy D'PoyFriend
Messages: 56
Registered: October 2011
Member
OK, I just changed:

@Override
protected IPage execCreateChildPage(final ITableRow row) throws ProcessingException {

final MyNodePage childPage = new MyNodePage();

...

childPage.setId((String) row.getCell(this.getTable().getIDColumn()).getValue());

...

return childPage;
}

into

@Override
protected IPage execCreateVirtualChildPage(final ITableRow row) throws ProcessingException {

final MyNodePage childPage = new MyNodePage();

...

childPage.setId((String) row.getCell(this.getTable().getIDColumn()).getValue());

...

return childPage;
}

and it worked fine!


Once You Go Scout, You Never Come Out!
Re: child page do not decorate untll it's been clicked in an outline based application [message #1007761 is a reply to message #1007725] Thu, 07 February 2013 12:36 Go to previous messageGo to next message
Jeremie Bresson is currently offline Jeremie BressonFriend
Messages: 790
Registered: October 2011
Senior Member
I my opinion this is a misusage of the Virtual pages... I do not know what you do in your "MyNodePage" class and how setting the String Id coming from the IDColumn affects the decoration of the node page.

We have always managed to compute the virtual child page from the Table information (with a hidden summary column and/or with some special logic decorating the virtual page). Just after the user click on the Page, the virtual page is resolved (the real page is instantiated). Because the decoration of the virtual and the real page is the same, the user doesn't see the difference.
Re: child page do not decorate untll it's been clicked in an outline based application [message #1007890 is a reply to message #1007761] Fri, 08 February 2013 00:19 Go to previous messageGo to next message
Boy D'Poy is currently offline Boy D'PoyFriend
Messages: 56
Registered: October 2011
Member
OK,

I've uploaded an eclipse-ready-to-import sample scout project for you to have a full running code.

I've also uploaded the application's behaviour screenshots for the two cases:

the recommended one; overriding execCreateChildPage witch doesn't match my expected behaviour: I have to click the child node before they decorate.

-- and --

the misusage; overriding execCreateVirtualChildPage witch gives me what I want: nodes are automatically decorated (and displayed as leaves).

I'll be very pleased to have, the suitable solution: correct coding meeting desired bahaviour.

Thank you!


Once You Go Scout, You Never Come Out!
Summary Cell [message #1007940 is a reply to message #1007890] Fri, 08 February 2013 10:54 Go to previous messageGo to next message
Jeremie Bresson is currently offline Jeremie BressonFriend
Messages: 790
Registered: October 2011
Senior Member
Thanks a lot for your example!

This is a (not so well documented) desired behavior:

When the nodes representing the pages are created in the main windows, a "virtual Page" is created. This virtual page is like a proxy. On click on this virtual page, the corresponding real child page is instantiated (meaning loaded and decorated).
You can influence the virtual page decoration: have a look at execCreateVirtualChildPage(ITableRow) in AbstractPageWithTable.

The virtual page mechanism was added some years ago, because we had performance problem (in case it is expensive to load the child page). I am not sure it is possible to bypass the mechanism.

I my opinion this is a misusage of the Virtual pages... I do not know what you do in your "MyNodePage" class and how setting the String Id coming from the IDColumn affects the IDColumn.

We have always managed to compute the virtual child page from the Table information (with a hidden summary column and/or with some special logic decorating the virtual page). Just after the user click on the Page, the virtual page is resolved (the real page is instantiated). Because the decoration of the virtual and the real page is the same, the user doesn't see the difference.


childPage.setId((String) row.getCell(this.getTable().getIDColumn()).getValue());

It will allow me to explain another mechanism:

When the TablePage loads its child pages, it creates a list of virtual pages. The cell used in the node tree to represent the child is derived from the "row summary cell".

A row summary cell is derived from the columns defined as summary. In your example, if I add the summary property to the NameColumn:
		@Order(20.0)
		public class NameColumn extends AbstractStringColumn {
			
			@Override
			protected String getConfiguredHeaderText() {
			
				return TEXTS.get("Name0");
			}

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


I will get:
index.php/fa/13348/0/

(Since I use execCreateChildPage and not execCreateVirtualChildPage, I still have the label change on click)

It is possible to define more than one column as summary column. I can set the summary == true on the IDColumn.
For the summary cell, the labels of the summary columns are collected and (there is a String concatenation with a space between the texts).

I get:
index.php/fa/13349/0/

Something I often do is to add an additional hidden summary column:

With execDecorateCell() in the column, I can control the text.
		@Order(1000.0)
		public class SummaryColumn extends AbstractStringColumn {
			
			@Override
			protected boolean getConfiguredDisplayable() {
				return false;
			}
			
			@Override
			@ConfigOperation
			@Order(40.0)
			protected void execDecorateCell(Cell cell, ITableRow row) throws ProcessingException {
				final StringBuilder sb = new StringBuilder();
				sb.append('[');
				sb.append(getIDColumn().getValue(row));
				sb.append(']');
				sb.append('[');
				sb.append(getNameColumn().getValue(row));
				sb.append(']');
				sb.append('[');
				sb.append(getNotesColumn().getValue(row));
				sb.append(']');
				cell.setText(sb.toString());
			}
			
			@Override
			protected boolean getConfiguredSummary() {
				return true;
			}
		}

I could also set an IconId on the cell.

index.php/fa/13350/0/

Another approach could be to override getSummaryCell(row) in your column, but I am not sure if the Scout API encourage this. (There is no execComputeSummaryCell(row) method).

Side note: If you do it with the summary cells, I think that you can remove "getConfiguredTitle" and "execDecorateCell" from MyNodePage.


I think this post should be merged in the wiki at:
Table > Summary Cell

[Updated on: Fri, 08 February 2013 13:56]

Report message to a moderator

Re: child page do not decorate untll it's been clicked in an outline based application [message #1007943 is a reply to message #1007890] Fri, 08 February 2013 11:11 Go to previous messageGo to next message
Jeremie Bresson is currently offline Jeremie BressonFriend
Messages: 790
Registered: October 2011
Senior Member
When I had a look at the example, I figured out it would be good if the Virtual Page already knows it is a leaf:

I imagined something like this:
	 @Override
	 protected IPage execCreateVirtualChildPage(final ITableRow row) throws ProcessingException {
		 IPage page = super.execCreateVirtualChildPage(row);
		 page.setLeaf(true);
		 return page;
	 }

But this is not working because the virtual page doesn't support setLeaf(): the implementation is empty. In my opinion a bug is needed to support the leaf property in VirtualTreeNode.

As workaround extended the VirtualPage like this:
package zzz.zzz.zzz.client.ui.desktop.outlines.pages;

import org.eclipse.scout.rt.client.ui.desktop.outline.pages.VirtualPage;

/**
 * Add the leaf behavior to virtual Pages.
 */
public class VirtualPageEx extends VirtualPage {
	  private boolean m_leaf;

	@Override
	  public boolean isLeaf() {
	    return m_leaf;
	  }

	  /**
	   * do not use this method directly use ITree.setNodeLeaf(node,b)
	   */
	  @Override
	  public void setLeafInternal(boolean b) {
	    m_leaf = b;
	  }

	  @Override
	  public void setLeaf(boolean b) {
	    if (getTree() != null) {
	      getTree().setNodeLeaf(this, b);
	    }
	    else {
	      setLeafInternal(b);
	    }
	  }
}


And I used:
	 @Override
	 protected IPage execCreateVirtualChildPage(final ITableRow row) throws ProcessingException {
		 IPage page = super.execCreateVirtualChildPage(row);
		 page.setLeaf(true);
		 return page;
	 }


This provides the expected result (if you use the summary cell).
Re: child page do not decorate untll it's been clicked in an outline based application [message #1007945 is a reply to message #1007943] Fri, 08 February 2013 11:18 Go to previous messageGo to next message
Jeremie Bresson is currently offline Jeremie BressonFriend
Messages: 790
Registered: October 2011
Senior Member
I just reviewed an other part of your code:

Instead of:
 @Override
 protected IPage execCreateChildPage(final ITableRow row) throws ProcessingException {
	 final MyNodePage childPage = new MyNodePage();
	 childPage.setId((String) row.getCell(this.getTable().getIDColumn()).getValue());
	 childPage.setName((String) row.getCell(this.getTable().getNameColumn()).getValue());
	 childPage.setComment((String) row.getCell(this.getTable().getNotesColumn()).getValue());
	 return childPage;
 }


Just write:
 @Override
 protected IPage execCreateChildPage(final ITableRow row) throws ProcessingException {
	 final MyNodePage childPage = new MyNodePage();
	 childPage.setId(getTable().getIDColumn().getValue(row));
	 childPage.setName(getTable().getNameColumn().getValue(row));
	 childPage.setComment(getTable().getNotesColumn().getValue(row));
	 return childPage;
 }


This way you do not have to cast the value (the typed column and the java compiler check this for you).
Re: child page do not decorate untll it's been clicked in an outline based application [message #1008063 is a reply to message #1007945] Fri, 08 February 2013 17:20 Go to previous messageGo to next message
Jeremie Bresson is currently offline Jeremie BressonFriend
Messages: 790
Registered: October 2011
Senior Member
I have tried to merge the content of this post to the wiki:

=> http://wiki.eclipse.org/Scout/Concepts/TablePage (including VirtualPage vs RealPage, and the child-pages in the tree using the summary cell)
=> http://wiki.eclipse.org/Scout/Concepts/Column (summary property is mentioned)

I want to populate the "summary cell" section:
=> http://wiki.eclipse.org/Scout/Concepts/Table#Summary_Cell

Feel free to review / improve it. It is a wiki.

[Updated on: Fri, 08 February 2013 17:23]

Report message to a moderator

Re: child page do not decorate untll it's been clicked in an outline based application [message #1008351 is a reply to message #1008063] Tue, 12 February 2013 06:57 Go to previous message
Boy D'Poy is currently offline Boy D'PoyFriend
Messages: 56
Registered: October 2011
Member
OKKKKKKKKK!
Right
Thank you for all these clarifications, I followed your answer and everything works FINE!


Once You Go Scout, You Never Come Out!
Previous Topic:Export fails on Mac OS X Java 7
Next Topic:Limiting input in FormFields
Goto Forum:
  


Current Time: Sun Nov 23 14:47:35 GMT 2014

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

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