Bug 401043 - [Model] Replace container data with persistentData
Summary: [Model] Replace container data with persistentData
Status: REOPENED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 4.3   Edit
Hardware: PC All
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Platform-UI-Inbox CLA
QA Contact: Eric Moffatt CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-02-18 02:42 EST by Lars Vogel CLA
Modified: 2019-12-04 08:19 EST (History)
6 users (show)

See Also:


Attachments
using persisted state to set part size information (96.07 KB, image/png)
2014-09-12 11:08 EDT, Steven Spungin CLA
no flags Details
equivalant container data shortcut (32.40 KB, image/png)
2014-09-12 11:09 EDT, Steven Spungin CLA
no flags Details
perspective showing runtime values (440.13 KB, image/png)
2014-09-12 11:10 EDT, Steven Spungin CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Lars Vogel CLA 2013-02-18 02:42:35 EST
AFAIK container data must be a number, currently we accept all input, e.g. letters too. I suggest to restrict this to numbers. 

@Eric/ Tom: Are integers only ok?
Comment 1 Thomas Schindl CLA 2013-02-18 03:15:20 EST
Well if it is the child of a SashPart-Container your are right but it really depends on the container you are in. IMHO we should have made the ContainerData a Map with key-value pairs instead of a dumb-string, this would make it easier to spec min/max values in future.

If we would have a model upgrade story we could try to address this before we make the model API, not sure if the reason I give here are sufficient since this container-Data has been like this from the first day.

Eric, we should set it on our discussion list.
Comment 2 Nobody - feel free to take it CLA 2013-02-18 04:35:08 EST
I discussed this some time ago with Eric in bug 385371
Comment 3 Lars Vogel CLA 2013-02-18 08:53:27 EST
I agree with Tom that a map with key-value pairs would be helpful. I close this bug as INVALID. Tom, please open a new bug report for the map with key/value pairs.
Comment 4 Eric Moffatt CLA 2013-03-01 16:01:36 EST
We could also *remove* 'containerData' as a specific attribute now that we have the 'persistentData' map...the contract is totally at the discretion of the *owning* (i.e. parent) container how / what it wants to store to correctly handle its children...

The SashRenderer could just add a new key 'sashWeight' to the map and use it, making the current attribute unnecessary.
Comment 5 Lars Vogel CLA 2013-03-04 13:19:32 EST
+1 for removal of the container data. @Eric: Is this still an option for Eclipse 4.3?
Comment 6 Nobody - feel free to take it CLA 2013-04-12 05:28:05 EDT
Removing containerData must be discussed on P/UI.
Comment 7 Eric Moffatt CLA 2013-04-19 15:26:52 EDT
No, basically due to the fact that we would have to be able to handle reading / updating existing saved models. I've marked this for a look in Luna but this in one of those cases where backwards compatibility (even in 4.x...;-) may rule out doing it in Luna.

Eventually I know we're going to change the model in some breaking manner but we have nobody here that knows the right hoops to jump through to dynamically upgrade a model on 'read'...
Comment 8 Eric Moffatt CLA 2013-11-04 14:45:40 EST
I'm moving this off to the side for Luna...it's not causing any issues and nothing is preventing a renderer from skipping the use of this field and directly using keyed values in the persistentData map...
Comment 9 Eric Moffatt CLA 2013-11-25 15:31:46 EST
If I'm going to do anything here it'll most likely be to just mark the 'containerData' as deprecated and point towards the persistentData approach...

Does anybody want to make a strong case that the field *must* be removed ?
Comment 10 Paul Webster CLA 2014-02-04 16:43:39 EST
We should do something here or defer this until post-Luna.

If it effects API we would have to deprecate it and if we want to remove it, make that claim.

PW
Comment 11 Lars Vogel CLA 2014-03-12 11:45:08 EDT
(In reply to Eric Moffatt from comment #9)
> If I'm going to do anything here it'll most likely be to just mark the
> 'containerData' as deprecated and point towards the persistentData
> approach...
> 
> Does anybody want to make a strong case that the field *must* be removed ?

Eric did you manage to deprecate the fields and use persistentData?
Comment 12 Lars Vogel CLA 2014-05-14 18:26:44 EDT
I mark this as WONTFIX. No need to adjust the current implementation.
Comment 13 Lars Vogel CLA 2014-08-18 04:36:55 EDT
Steven started to work on this in Bug 361731. Reopening.
Comment 14 Lars Vogel CLA 2014-08-18 04:40:21 EDT
We should support the existing container data but deprecated it (issue a message if it is used) and replace it with persistent state.
Comment 15 Steven Spungin CLA 2014-08-18 08:41:01 EDT
(In reply to Lars Vogel from comment #14)
> We should support the existing container data but deprecated it (issue a
> message if it is used) and replace it with persistent state.

Is the SashLayout the only class using ContainerData.  Are their any non-SWT renderers or classes that use it?

How likely will a new model using persistentData instead be opened on an older build that is still looking for containerData?


The new patch allows for an integer or value such as (size:50%;min:20px;max:100px)  I could keep those values separate with persistentData, but it is trivial to parse the string, and simple to enter it into the UI. 

 If we are going to restrict or validate the input, it might make sense to just keep the containerData.  I think it is specialized enough to warrant its own setting on the main tab.

If we do remove containerData, I would suggest still having a separate text box in the editor that just modifies the relevant keys in the map;  I was going to put in a tooltip to describe the new ContainerData format.
Comment 16 Steven Spungin CLA 2014-08-18 21:36:11 EDT
Here is a reason we may want to keep ContainerData as a discrete attribute:

SashRenderer subscribes to changes:

eventBroker.subscribe(UIEvents.UIElement.TOPIC_CONTAINERDATA, sashWeightHandler);

Does EMF allow us to subscribe to a single key in the map?
Comment 17 Thomas Schindl CLA 2014-08-21 11:29:15 EDT
(In reply to Steven Spungin from comment #15)
> (In reply to Lars Vogel from comment #14)
> > We should support the existing container data but deprecated it (issue a
> > message if it is used) and replace it with persistent state.
> 
> Is the SashLayout the only class using ContainerData.  Are their any non-SWT
> renderers or classes that use it?
> 

e(fx)clipse JavaFX renderer use containerData as well as persistedState so we can already work with persitedState and track changes in there as well. If upstream changes to persistedState we are fine with that and will support it as well in our sash-renderer.
Comment 18 Lars Vogel CLA 2014-08-21 11:31:47 EDT
(In reply to Steven Spungin from comment #16)
> Here is a reason we may want to keep ContainerData as a discrete attribute:
> 
> SashRenderer subscribes to changes:
> 
> eventBroker.subscribe(UIEvents.UIElement.TOPIC_CONTAINERDATA,
> sashWeightHandler);
> 
> Does EMF allow us to subscribe to a single key in the map?

I think we can do it similar to the event handler in StackRenderer for transient data.
Comment 19 Steven Spungin CLA 2014-08-21 11:35:21 EDT
(In reply to Thomas Schindl from comment #17)

> e(fx)clipse JavaFX renderer use containerData as well as persistedState so
> we can already work with persitedState and track changes in there as well.
> If upstream changes to persistedState we are fine with that and will support
> it as well in our sash-renderer.

I would suggest refactoring the calculation logic out of the SWT renderer so both platforms can benefit.  Where would we put this shared code?
Comment 20 Thomas Schindl CLA 2014-08-21 11:35:32 EDT
(In reply to Steven Spungin from comment #16)
> Here is a reason we may want to keep ContainerData as a discrete attribute:
> 
> SashRenderer subscribes to changes:
> 
> eventBroker.subscribe(UIEvents.UIElement.TOPIC_CONTAINERDATA,
> sashWeightHandler);
> 
> Does EMF allow us to subscribe to a single key in the map?

Yes it allows you to listen do changes in a Map-Attribute what you get as an event has:

event.getProperty(UIEvents.EventTags.ATTNAME) == UIEvents.ApplicationElement.PERSISTEDSTATE;

java.util.Map.Entry<String,String> e = event.getProperty(UIEvents.EventTags.NEW_VALUE);
Comment 21 Thomas Schindl CLA 2014-08-21 11:39:51 EDT
(In reply to Steven Spungin from comment #19)
> (In reply to Thomas Schindl from comment #17)
> 
> > e(fx)clipse JavaFX renderer use containerData as well as persistedState so
> > we can already work with persitedState and track changes in there as well.
> > If upstream changes to persistedState we are fine with that and will support
> > it as well in our sash-renderer.
> 
> I would suggest refactoring the calculation logic out of the SWT renderer so
> both platforms can benefit.  Where would we put this shared code?

if there's code you want to share it would be somewhere in the ui.workbench at the same level where you have IPresentationEngine. The question is what you want to return from such a service. JavaFX SplitPane works completely different to e4-SWT-SashLayout so I don't think that makes a whole lot of sense.

Beside that e(fx)clipse renderers internally work completely different than the their SWT counter parts with respect to how informations are transfered into the rendering pipeline.
Comment 22 Steven Spungin CLA 2014-08-21 11:47:08 EDT
(In reply to Thomas Schindl from comment #21)

> if there's code you want to share it would be somewhere in the ui.workbench
> at the same level where you have IPresentationEngine. The question is what
> you want to return from such a service. JavaFX SplitPane works completely
> different to e4-SWT-SashLayout so I don't think that makes a whole lot of
> sense.

I am referring to code that calculates the current weights during layout and resizing based on min/max values and the other relative/absolute values in the container.  Also code that parses and regenerates the container data.  The current implementation has all that logic in the SWT renderer.  It makes sense to me that e(fx)clipse renderers (and other renderers) would not need to reinvent that stuff.
Comment 23 Steven Spungin CLA 2014-08-22 09:03:42 EDT
Another reason to keep ContainerData discrete.
 
Now that constraints and absolute sizes can be set, a part can declare its size.  It will be simple for users to set ContainerData vs needing to know the map key, etc.  It would also be nice if a part-stack without container data set would fall through and consider the container data in the parts it contains, if their data is set.

In addition, if we store this in the map, all other map listeners are going to receive MANY callbacks when the sash is resized if we can't subscribe to just one key.

If this values was not written to often, and did not have to do with size, I would be more convinced to migrate it to a map.
Comment 24 Steven Spungin CLA 2014-09-10 09:59:49 EDT
Many implementations (addons, etc) clone a part's ContainerData; storing discrete values would make it difficult to only copy those fields.

Could we deprecate containerData in favor of using PersistedData, and also add a new member to MUIElement.  This new member could be more focused as to the size/resize behavior of the element; It could either be a map<string,object> or have discreet members. (I suggest string,object because it would optimize calculations).
Comment 25 Lars Vogel CLA 2014-09-10 10:23:04 EDT
(In reply to Steven Spungin from comment #24)

> Could we deprecate containerData in favor of using PersistedData, and also
> add a new member to MUIElement.  This new member could be more focused as to
> the size/resize behavior of the element; It could either be a
> map<string,object> or have discreet members. (I suggest string,object
> because it would optimize calculations).

I think persistedData is the write place as we need to persist the data between application restarts. I think it is very important to keep the model as simple as possible and adding a persisted map<string,object> is not a good way. We could use transientData to store any calculated data. That is already map<string,object>.
Comment 26 Steven Spungin CLA 2014-09-10 10:44:23 EDT
(In reply to Lars Vogel from comment #25)
> (In reply to Steven Spungin from comment #24)
> 
> > Could we deprecate containerData in favor of using PersistedData, and also
> > add a new member to MUIElement.  This new member could be more focused as to
> > the size/resize behavior of the element; It could either be a
> > map<string,object> or have discreet members. (I suggest string,object
> > because it would optimize calculations).
> 
> I think persistedData is the write place as we need to persist the data
> between application restarts. I think it is very important to keep the model
> as simple as possible and adding a persisted map<string,object> is not a
> good way. We could use transientData to store any calculated data. That is
> already map<string,object>.

Questions:

1. So how does an addon that only wants to clone the size data get to just those items? Clone the transient data?  I guess we could we store an sizing object in transient data, and just clone that.

2. Where would the best place in the code to load/save the persistedData to transientData be?

3. Are we OK with these keys: <prefix>.resizeMode, <prefix>.size, and <prefix>.unit?  What prefix to use?

4. Can we add a new widget in on the main tab of the editor for these 3 values, right after the containerData?

5.  What's the strategy for legacy containerData values?
Comment 27 Lars Vogel CLA 2014-09-10 18:33:13 EDT
(In reply to Steven Spungin from comment #26)

> Questions:
> 
> 1. So how does an addon that only wants to clone the size data get to just
> those items? Clone the transient data?  I guess we could we store an sizing
> object in transient data, and just clone that.

The base data would be in persistedState and the converted data in transient data. The model add-in would pick whatever it like.

> 2. Where would the best place in the code to load/save the persistedData to
> transientData be?

If required, I think SashRenderer is the correct place. 

> 3. Are we OK with these keys: <prefix>.resizeMode, <prefix>.size, and
> <prefix>.unit?  What prefix to use?

Sounds good for an initial implementation. What about sashlayoutdata as prefix?

> 
> 4. Can we add a new widget in on the main tab of the editor for these 3
> values, right after the containerData?

I suggest to first use the existing tooling, once this is implemented we can enhancement the tooling.

> 5.  What's the strategy for legacy containerData values?

I must still support it. Maybe convert it at runtime to the new values and issue a warning message to the log?
Comment 28 Steven Spungin CLA 2014-09-12 11:08:14 EDT
Created attachment 247011 [details]
using persisted state to set part size information
Comment 29 Steven Spungin CLA 2014-09-12 11:09:55 EDT
Created attachment 247012 [details]
equivalant container data shortcut

It is MUCH easier to still specify as a string.  Lateset patch will automatically convert this to persistent data.
Comment 30 Steven Spungin CLA 2014-09-12 11:10:40 EDT
Created attachment 247013 [details]
perspective showing runtime values
Comment 31 Lars Vogel CLA 2016-04-20 12:04:02 EDT
Mass move to 4.7 as M7 is approaching. Please move back in case you are planning to fix it for Neon.
Comment 32 Eclipse Genie CLA 2019-12-04 08:14:25 EST Comment hidden (obsolete)