Bug 527686 - Pull-out common master-detail code
Summary: Pull-out common master-detail code
Status: CLOSED FIXED
Alias: None
Product: ECP
Classification: Modeling
Component: EMF Forms (show other bugs)
Version: 1.15.0   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: 1.22.0   Edit
Assignee: Christian Damus CLA
QA Contact: Eugen Neufeld CLA
URL:
Whiteboard:
Keywords: test
Depends on:
Blocks:
 
Reported: 2017-11-23 10:01 EST by Mat Hansen CLA
Modified: 2019-07-17 19:23 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mat Hansen CLA 2017-11-23 10:01:17 EST
We currently have at least three implementations of a master-detail renderer (SWTTable, GridTable and TreeMasterDetail). 

They all consist of the same core features:
- create a master/detail composite, defining where the master and detail parts should be rendered
- add some listeners to the master object to update the detail part accordingly
- some housekeeping code (i.e. disposal of expired detail parts) 

This effectively results in a lot of duplicated code as those implementations share the same functionality. I suggest to pull-out the master-detail code into a stand-alone/common bundle and only leave the creation of the composite to the actual renderer implementations.
Comment 1 Eclipse Genie CLA 2017-11-29 09:39:37 EST
New Gerrit change created: https://git.eclipse.org/r/112566
Comment 2 Eclipse Genie CLA 2017-11-29 09:39:42 EST
New Gerrit change created: https://git.eclipse.org/r/112566
Comment 3 Mat Hansen CLA 2018-04-11 10:02:57 EDT
Technically, this also affects the category renderer.
Comment 4 Mat Hansen CLA 2018-04-11 10:06:05 EDT
With this refactoring, we should also homogenize the detail view selection. In case of the tree master-detail, we already support a "detail" key which marks a view applicable to detail parts only. This functionality is missing i.e. for the table master-detail, where it is plausible that the user wants to display a modified view as part of the detail compared to the "default" view for the same type.
Comment 5 Mat Hansen CLA 2018-04-11 10:40:41 EDT
Also note, that master-detail can also be used recursively. 

Consider the following control hierarchy: Tree (view) -> Table (view) -> View (arbitrary)

In this case, there is a master-detail relation between the tree view and the table view (tree master-detail). At the same time, the table view acts as the master component for its detail view (table master-detail). The table (view) therefore acts as a detail component and as a master component at the same time, bound by the selection.
Comment 6 Eclipse Genie CLA 2019-05-23 13:59:39 EDT
New Gerrit change created: https://git.eclipse.org/r/142690
Comment 7 Eclipse Genie CLA 2019-05-24 13:58:31 EDT
New Gerrit change created: https://git.eclipse.org/r/142764
Comment 10 Christian Damus CLA 2019-06-05 07:27:13 EDT
The scope of this activity is reduced to factoring out the code that handles rendering of detail views with optional caching.  The layout relationship between the master and detail panes is maintained in each renderer.

## TESTING INFORMATION
### Summary of the critical part of the change

New API is provided in the org.eclipse.emf.ecp.ui.view.swt bundle for rendering of details in a master-detail UI:

- DetailViewManager handles rendering and reuse of cached detail panes
- DetailViewCache and BasicDetailViewCache provide caching strategies

The TreeMasterDetailComposite, TreeMasterDetailSWTRenderer, TableControlSWTRenderer, and GridControlSWTRenderer all employ this new API to render their details and offer optional caching as specified either directly (in the case of the composite) or via a property in the view-model context (in the case of the renderers).

The EcoreEditor that uses the TreeMasterDetailComposite now configures it for caching details.

### Potential regressions

The new detail rendering implementation utilizes an in situ page-book (stacked layout) instead of re-parenting widgets into a hidden shell for management of multiple reusable detail renderings.  So, complex layouts that embed the details composite (e.g. scroll composites) may see different behaviour in the sizing preferences of the details.

EcoreEditor caches details where it did not before.  If it depends on being able to render different instances of the same EClass in quite different ways, then that would be an issue.

The ViewModelContext implementation had numerous problems in the handling of the lifecycle of child contexts, especially in changing their domain models (which is required for the reuse of a context with a rendered detail UI).  Similarly the ValidationService and settings-to-control mapping service implementations.

All detail views now present a hint that there is no selection of there is no detail to show instead of just showing nothing when there is no selection or when the selected object has nothing to edit.  The TreeMasterDetailComposite customizes the message that is presented to match what it showed previously, but the message is no longer centred in the detail.

### Affected areas / use cases

Master-detail renderings of all kinds.
Validation decorations generally but especially in master-detail.

### Things that shall be tested

Editing and validation in Ecore editor, view model editor, and other presentations of master-detail UIs.  Especially for accurate updating of validation decorations both in the detail pane and also propagated into the master view (tree or table).  Be sure to test with and without caching configured in the view model context (except Ecore editor which configures caching for itself).

Also propagation of validation problems into the Categorization tree in which the new detail management framework is not used but which relies on the control mapping service that is changed by this feature.
Comment 11 Christian Damus CLA 2019-06-06 15:56:45 EDT
In further testing of my private client application, I found that when an editor showing a table with detail panel re-loaded with changes from disk (as when pulling from Git), an exception was thrown [1] that resulted in the table not updating the contents that it shows the details panel continuing to show details of a ghost object using a disposed child context.

[1] IllegalStateException "The ViewModelContext is already disposed."
Comment 12 Eclipse Genie CLA 2019-06-06 15:57:44 EDT
New Gerrit change created: https://git.eclipse.org/r/143468
Comment 14 Christian Damus CLA 2019-06-13 07:15:12 EDT
(In reply to Eclipse Genie from comment #13)
> Gerrit change https://git.eclipse.org/r/143468 was merged to [develop].
Comment 15 Eclipse Genie CLA 2019-06-14 16:21:00 EDT
New Gerrit change created: https://git.eclipse.org/r/144091
Comment 17 Christian Damus CLA 2019-06-18 10:11:12 EDT
The fix is published in 1.22 M1a.
Comment 18 Christian Damus CLA 2019-07-09 14:55:44 EDT
Git bisect shows that commit 21af120 for this enhancement causes a regression in the validation state of forms-based editors such as the View Model Editor (not the Viewmodel Editor that is based on the GenericEditor).

In the View Model Editor, the validation problem decorations shown in the tree for an element shown can disappear and reappear as the selection changes.  It isn't clear what the pattern is, although it does seem that the problem decoration in the tree is always shown when the object manifesting the problem(s) is selected in the tree, and its detail pane also shows the correct problem indications.
Comment 19 Christian Damus CLA 2019-07-09 16:36:16 EDT
(In reply to Christian Damus from comment #18)
> Git bisect shows that commit 21af120 for this enhancement causes a
> regression in the validation state of forms-based editors such as the View
> Model Editor (not the Viewmodel Editor that is based on the GenericEditor).

The problem is that prior to the introduction of rendered detail caching, the child contexts used to render details of the objects selected in the tree were never disposed.  They were created initially by the tree validation initiator and existed in perpetuity (or, at least, until their corresponding model elements were deleted).  This changed with the rendered detail caching, which (especially when caching is not enabled) will actually dispose these child contexts when the rendered detail SWT composites are disposed.
Comment 21 Christian Damus CLA 2019-07-10 17:31:07 EDT
(In reply to Eclipse Genie from comment #20)
> Gerrit change https://git.eclipse.org/r/145734 was merged to [develop].
Comment 22 Eclipse Genie CLA 2019-07-12 06:09:20 EDT
New Gerrit change created: https://git.eclipse.org/r/145973
Comment 24 Christian Damus CLA 2019-07-17 19:23:20 EDT
Fix published in 1.22 M2.