Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 558842 - [Databinding] Small convenience improvements
Summary: [Databinding] Small convenience improvements
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 4.15   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 4.15   Edit
Assignee: Jens Lideström CLA
QA Contact: Jens Lideström CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-01-06 10:27 EST by Jens Lideström CLA
Modified: 2020-11-10 15:24 EST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jens Lideström CLA 2020-01-06 10:27:29 EST
There are certain tasks with the databinding framework that are verbose and messy, but where simple convenience methods would simplify the user code significantly.

Examples:

* Create a update strategy with a converter (type inference doesn't work for chained methods)
* Create update strategies with the NEVER policy
* Create simple conversion properties
* Binding enum values

This ticket is meant as an umbrella for work with such convenience code.
Comment 1 Eclipse Genie CLA 2020-01-06 11:14:10 EST
New Gerrit change created: https://git.eclipse.org/r/155303
Comment 2 Eclipse Genie CLA 2020-01-06 11:14:11 EST
New Gerrit change created: https://git.eclipse.org/r/155304
Comment 3 Eclipse Genie CLA 2020-01-06 11:14:12 EST
New Gerrit change created: https://git.eclipse.org/r/155306
Comment 4 Eclipse Genie CLA 2020-01-06 11:14:13 EST
New Gerrit change created: https://git.eclipse.org/r/155305
Comment 5 Eclipse Genie CLA 2020-01-06 11:14:24 EST
New Gerrit change created: https://git.eclipse.org/r/155307
Comment 6 Jens Lideström CLA 2020-01-09 14:51:06 EST
The following demonstrates the convenience improvements that are made in the Gerrit changes.

Snippets are also updated to demonstrate these additions.

These examples are all pretty common tasks to do with the databinding framework.

### Update strategy `never` methods

--- Code before changes

bindingContext.bindValue(value1, value2, null, new UpdateValueStrategy<>(false, UpdateValueStrategy.POLICY_NEVER));

--- Code after changes

bindingContext.bindValue(value1, value2, null, UpdateValueStrategy.never()));

### Update strategy `create` methods

--- Code before changes

bindingContext.bindValue(value1, value2, null, 
	new UpdateValueStrategy<String, ExampleBean>().setConverter(exampleConverter));

--- Code after changes

bindingContext.bindValue(value1, value2, null, UpdateValueStrategy.create(exampleConverter));

(The methods on UpdateValueStrategy already existed, but not the once for lists and sets.)

### `Properties#convertedValue` method

--- Code before changes

IValueProperty<Boolean, Font> fontProperty = BindingProperties.convertedValue(
	IConverter.create(boolean.class, boolean.clss, stale -> stale ? italicFont : shellFont);

--- Code after changes

IValueProperty<Boolean, Font> fontProperty = Properties.convertedValue(stale -> stale ? italicFont : shellFont);


### IConverter `create` method without type arguments

--- Code before changes

IConverter c = IConverter.create(boolean.class, boolean.clss, stale -> stale ? italicFont : shellFont);

--- Code after changes

IConverter c = IConverter.create(stale -> stale ? italicFont : shellFont);
Comment 7 Jens Lideström CLA 2020-01-09 14:51:59 EST
I plan to merge these additions in a couple of days if I don't hear any objections.