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

Difference between revisions of "Scout/Concepts/TablePage"

(Description)
(Merge forum http://www.eclipse.org/forums/index.php/t/452690/)
Line 13: Line 13:
 
[[Image:HG_TablePage.png]]
 
[[Image:HG_TablePage.png]]
  
The child-pages are represented a tree nodes. The cell of this node is defined by the {{ScoutLink|Concepts|Table#Summary_Cell|summary cell}} of the table.
+
In {{ScoutLink|Concepts|Outline_based_application|outline based application}}, the child-pages are represented a nodes in the page tree. The cell of this node is defined by the {{ScoutLink|Concepts|Table#Summary_Cell|summary cell}} of the table.
 +
 
 +
Here an example with only the Name column as summary column:
 +
 
 +
[[Image:Scout summary cell name.png]]
 +
 
 +
Here an example with Id and Name column as summary column:
 +
 
 +
[[Image:Scout summary cell id and name.png]]
 +
 
 +
In case of multiple summary column, the texts are concatenated (with a space as separator).
  
 
== Screenshot ==
 
== Screenshot ==
Line 45: Line 55:
 
For performance reason, because sometimes instantiating a page can be expansive, the concept of virtual page was introduced. Virtual pages are created by {{ScoutEvent|CreateVirtualChildPage}}. Virtual pages act like a proxy: only when they are activated the real corresponding page is instanciated with the corresponding call to {{ScoutEvent|CreateChildPage}}.
 
For performance reason, because sometimes instantiating a page can be expansive, the concept of virtual page was introduced. Virtual pages are created by {{ScoutEvent|CreateVirtualChildPage}}. Virtual pages act like a proxy: only when they are activated the real corresponding page is instanciated with the corresponding call to {{ScoutEvent|CreateChildPage}}.
  
{{note|TODO|If virtual page are not handled properly you can see two kinds of bugs:
+
It is possible to have child pages only for some of the rows. Imagine a Table Page representing some files (like in a file system):
* Label of the node change (see [http://www.eclipse.org/forums/index.php/t/452690/ child page do not decorate untll it's been clicked in an outline based application])
+
 
* Pages disappears (occurs when {{ScoutEvent|CreateChildPage}} returns null -> a virtual child page is created and it desapears when its clicked).
+
[[Image:Scout_Folder_Outline.png]]
TODO: Document these cases here.
+
 
}}
+
The implementation is simple: if it should be no child page, {{ScoutEvent|CreateChildPage}} should return null.
 +
 
 +
<source lang="java">
 +
@Override
 +
protected IPage execCreateChildPage(ITableRow row) throws ProcessingException {
 +
  if (CompareUtility.equals(FileTypeCodeType.FolderCode.ID, getTable().getTypeColumn().getValue(row))) {
 +
    FolderTablePage page = new FolderTablePage();
 +
    page.setParentId(getTable().getIDColumn().getValue(row));
 +
    return page;
 +
  }
 +
  else {
 +
    return null;
 +
  }
 +
}
 +
</source>
 +
 
 +
 
 +
Because of the Virtual pages mechanism, this will not work as expected. One virtual page for each rows of the table (folder and file). On clic on a child page representing a file, the node will disappear. This is because on clic on the virtual page, the real page will be instantiated (by calling {{ScoutEvent|CreateChildPage}} for the corresponding row). The method will return null, meaning no child page for this row.
 +
 
 +
[[Image:Scout_Folder_Outline_Bug.png]]
 +
 
 +
It is important to implement {{ScoutEvent|CreateVirtualChildPage}} with according to {{ScoutEvent|CreateChildPage}}: if {{ScoutEvent|CreateChildPage}} returns null, {{ScoutEvent|CreateVirtualChildPage}} should also return null.
 +
 
 +
An implementation could be:
 +
<source lang="java">
 +
@Override
 +
protected IPage execCreateVirtualChildPage(ITableRow row) throws ProcessingException {
 +
  if (isFolder(row)) {
 +
    return super.execCreateVirtualChildPage(row);
 +
  }
 +
  else {
 +
    return null;
 +
  }
 +
}
 +
 
 +
@Override
 +
protected IPage execCreateChildPage(ITableRow row) throws ProcessingException {
 +
  if (isFolder(row)) {
 +
    FolderTablePage page = new FolderTablePage();
 +
    page.setParentId(getTable().getIDColumn().getValue(row));
 +
    return page;
 +
  }
 +
  else {
 +
    return null;
 +
  }
 +
}
 +
 
 +
private boolean isFolder(ITableRow row) {
 +
  return CompareUtility.equals(FileTypeCodeType.FolderCode.ID, getTable().getTypeColumn().getValue(row));
 +
}
 +
</source>
 +
 
 +
A related topic is child page decoration:
 +
If some decoration occurs on the child page, the page will be decorated only after a user clic:
 +
 
 +
[[Image:Scout_Decorate_Child_Page_Bug.png]]
 +
 
 +
This is again because of the virtual page. The virtual page has no idea of the decoration of the real page it represent. The virtual page only display information of the summary cell of the row.
 +
 
 +
Often the table contains enough information to compute the decoration of the child page. A solution is to compute the cell decoration in the table (as summary cell) instead of in the child page. A possible solution is to add an invisible column (displayable == false). This column is defined as summary column (summary == true).
 +
 
 +
<source lang="java">
 +
@Order(1000.0)
 +
public class SummaryColumn extends AbstractStringColumn {
 +
 
 +
  @Override
 +
  protected boolean getConfiguredDisplayable() {
 +
    return false;
 +
  }
 +
 
 +
  @Override
 +
  protected boolean getConfiguredSummary() {
 +
    return true;
 +
  }
 +
 
 +
  @Override
 +
  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());
 +
  }
 +
}
 +
</source>
 +
 
 +
There is no need to decorate the child page, because the summary cell will be used on both the virtual and the "real" child page.
 +
 
  
 
=== Other events ===
 
=== Other events ===

Revision as of 13:17, 8 February 2013

The Scout documentation has been moved to https://eclipsescout.github.io/.

Table-oriented The Scout documentation has been moved to https://eclipsescout.github.io/.


Description

Note.png
TODO
Add a description

HG TablePage.png

In The Scout documentation has been moved to https://eclipsescout.github.io/., the child-pages are represented a nodes in the page tree. The cell of this node is defined by the The Scout documentation has been moved to https://eclipsescout.github.io/. of the table.

Here an example with only the Name column as summary column:

Scout summary cell name.png

Here an example with Id and Name column as summary column:

Scout summary cell id and name.png

In case of multiple summary column, the texts are concatenated (with a space as separator).

Screenshot

ScoutScreenshotTablePage.png


Properties

Defined with The Scout documentation has been moved to https://eclipsescout.github.io/. methods.

Note.png
TODO
Add a description of the more important properties (ore the properties specific to this element)


Events

Defined with The Scout documentation has been moved to https://eclipsescout.github.io/. methods.

child page and virtual child page

The Scout documentation has been moved to https://eclipsescout.github.io/. is triggered for each row of the table (the corresponding row is given as parameter). It is possible to get some of the values in the table to pass them to the chid page.

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

For performance reason, because sometimes instantiating a page can be expansive, the concept of virtual page was introduced. Virtual pages are created by The Scout documentation has been moved to https://eclipsescout.github.io/.. Virtual pages act like a proxy: only when they are activated the real corresponding page is instanciated with the corresponding call to The Scout documentation has been moved to https://eclipsescout.github.io/..

It is possible to have child pages only for some of the rows. Imagine a Table Page representing some files (like in a file system):

Scout Folder Outline.png

The implementation is simple: if it should be no child page, The Scout documentation has been moved to https://eclipsescout.github.io/. should return null.

@Override
protected IPage execCreateChildPage(ITableRow row) throws ProcessingException {
  if (CompareUtility.equals(FileTypeCodeType.FolderCode.ID, getTable().getTypeColumn().getValue(row))) {
    FolderTablePage page = new FolderTablePage();
    page.setParentId(getTable().getIDColumn().getValue(row));
    return page;
  }
  else {
    return null;
  }
}


Because of the Virtual pages mechanism, this will not work as expected. One virtual page for each rows of the table (folder and file). On clic on a child page representing a file, the node will disappear. This is because on clic on the virtual page, the real page will be instantiated (by calling The Scout documentation has been moved to https://eclipsescout.github.io/. for the corresponding row). The method will return null, meaning no child page for this row.

Scout Folder Outline Bug.png

It is important to implement The Scout documentation has been moved to https://eclipsescout.github.io/. with according to The Scout documentation has been moved to https://eclipsescout.github.io/.: if The Scout documentation has been moved to https://eclipsescout.github.io/. returns null, The Scout documentation has been moved to https://eclipsescout.github.io/. should also return null.

An implementation could be:

@Override
protected IPage execCreateVirtualChildPage(ITableRow row) throws ProcessingException {
  if (isFolder(row)) {
    return super.execCreateVirtualChildPage(row);
  }
  else {
    return null;
  }
}
 
@Override
protected IPage execCreateChildPage(ITableRow row) throws ProcessingException {
  if (isFolder(row)) {
    FolderTablePage page = new FolderTablePage();
    page.setParentId(getTable().getIDColumn().getValue(row));
    return page;
  }
  else {
    return null;
  }
}
 
private boolean isFolder(ITableRow row) {
  return CompareUtility.equals(FileTypeCodeType.FolderCode.ID, getTable().getTypeColumn().getValue(row));
}

A related topic is child page decoration: If some decoration occurs on the child page, the page will be decorated only after a user clic:

Scout Decorate Child Page Bug.png

This is again because of the virtual page. The virtual page has no idea of the decoration of the real page it represent. The virtual page only display information of the summary cell of the row.

Often the table contains enough information to compute the decoration of the child page. A solution is to compute the cell decoration in the table (as summary cell) instead of in the child page. A possible solution is to add an invisible column (displayable == false). This column is defined as summary column (summary == true).

@Order(1000.0)
public class SummaryColumn extends AbstractStringColumn {
 
  @Override
  protected boolean getConfiguredDisplayable() {
    return false;
  }
 
  @Override
  protected boolean getConfiguredSummary() {
    return true;
  }
 
  @Override
  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());
  }
}

There is no need to decorate the child page, because the summary cell will be used on both the virtual and the "real" child page.


Other events

Note.png
TODO
Add a description of the more important event and a list of the other events (grouped by type)


See Also

Copyright © Eclipse Foundation, Inc. All Rights Reserved.