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"

(Merge forum http://www.eclipse.org/forums/index.php/t/452690/)
(Replaced content with "The Scout documentation has been moved to https://eclipsescout.github.io/.")
 
(2 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{ScoutPage|cat=Component Model}}
+
The Scout documentation has been moved to https://eclipsescout.github.io/.
 
+
Table-oriented {{ScoutLink|Concepts|Page|page}}
+
 
+
* implements: {{ScoutJavadoc|IPageWithTable|I}}
+
* extends: {{ScoutJavadoc|AbstractPageWithTable|C}}
+
 
+
 
+
== Description ==
+
{{note|TODO|Add a description}}
+
* {{ScoutLink|Concepts|Table|Table}}
+
 
+
[[Image:HG_TablePage.png]]
+
 
+
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 ==
+
[[Image:ScoutScreenshotTablePage.png]]
+
 
+
 
+
== Properties ==
+
''Defined with {{ScoutLink|Concepts|GetConfigured Methods|getConfiguredXxxxxx()}} methods''.
+
 
+
{{note|TODO|Add a description of the more important properties (ore the properties specific to this element)}}
+
 
+
 
+
== Events ==
+
''Defined with {{ScoutLink|Concepts|Exec_Methods|execXxxxxx()}} methods''.
+
 
+
=== child page and virtual child page ===
+
{{ScoutEvent|CreateChildPage}} 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.
+
 
+
<source lang="java">
+
@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;
+
}
+
</source>
+
 
+
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}}.
+
 
+
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):
+
 
+
[[Image:Scout_Folder_Outline.png]]
+
 
+
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 ===
+
{{note|TODO|Add a description of the more important event and a list of the other events (grouped by type)}}
+
 
+
== See Also ==
+
* {{ScoutLink|Concepts|Table|Table}}
+
* {{ScoutLink|Concepts|Page|Page}}
+
* {{ScoutLink|Concepts|NodePage|Node Page}}
+
* {{ScoutLink|Concepts|Outline|Outline}}
+

Latest revision as of 05:24, 14 March 2024

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

Back to the top