Bug 423991 - Add support for Locale changes at runtime to the Application Model
Summary: Add support for Locale changes at runtime to the Application Model
Status: VERIFIED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Runtime (show other bugs)
Version: 4.4   Edit
Hardware: PC Windows 7
: P3 enhancement (vote)
Target Milestone: 4.4 M6   Edit
Assignee: Paul Webster CLA
QA Contact:
URL:
Whiteboard:
Keywords: noteworthy
Depends on:
Blocks:
 
Reported: 2013-12-13 03:26 EST by Dirk Fauth CLA
Modified: 2014-03-05 07:55 EST (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dirk Fauth CLA 2013-12-13 03:26:58 EST
The new Message extension for localization in Eclipse supports Locale changes at runtime.

To have a clean overall solution, also the Application Model should support this. For as much encapsulation as possible for the necessary tasks, there should be a new service to change the Locale, and some enhancements to the application model.

I have done the necessary modifications already and will contribute via Gerrit.
Comment 1 Paul Webster CLA 2013-12-13 11:25:29 EST
From Tom http://dev.eclipse.org/mhonarc/lists/e4-dev/msg08202.html


First of all a big thank to Dirk for working through this rather complex
topic which has been a lot of work!

What makes me a bit proud is that the archtitecture we have in e4 allows
to implement something like this with justifiable cost - imagine doing this

Now let me elaborate bit what the changes are and how address them. I
guess this should make it easier to understand the patch.

a) The model changes
--------------------
Until today the localization was done through EOperations (=Methods)
defined in our Ecore model. We have changed that so that those are
volatile, transient, derived, unchangeable EStructuralFeatures who from
an API point of view are identical to the EOperations previously defined
e.g. in MUILabel hence our API is not broken!

The reason we change to EStructuralFeatures is that we can now send out
Notifications about the changes who are then going directly through our
Event-System.

To mark EClasses who hold localizable informations and to inform them
externally about a changed locale we introduced a new Mixin named
Localizable who has a method named updateLocalization().

This allows use the generically search the model for model elements
effected by a locale change and force them sending out updates. There's
a very small potential that this breaks backwards compat if people have
extended our Ecore in a way like this:

MySpecialPart superTypes [*MySuperClass*, Part]

so the generated java code will look like this:

class MySpecialPartImpl extends MySuperClassImpl implements MPart {
}

I don't really think that we should bother with those who have extended
our ecore because a similar source incompatible change was made with
TrimElement - let me restate the breakage is ONLY for people who
extended our Ecore (and even there those who did it in a sensible way
would not be affected)

b) Local change propagation
---------------------------
The central point to switch the locale is ILocaleChangeService which is
not implemented at the OSGi-Level but through a ContextFunction which is
implemented in ui.workbench.

It allows to switch the locale at the application, as well as the
context level and the implemention does 2 things:
- it will inform *all* model elements of an application who implement
   MLocalization about the change
- posts an event on the event broker

c) Local change consumption:
----------------------------
There are 3 ways one can get informed about a local change:
- Through the event-broker by listening to the topic
  org/eclipse/e4/core/NLS/LOCALE_CHANGE

- By using DI and make your bean get TranslationService.LOCALE injected
  => the new message system Dirk & me introduced does use this and
     you'll get an update Message-Instance injected!

- Attaching to the model events listening to the LOCALIZED-Features we
  introduced instead of the EOperations from above
  => the renderers have to be modified to listen to the LOCALIZED-
     Features!

I hope you followed along until this point but I felt you need to get
some background on what Dirk did and why he did it this way.

My plan is to get this in very early in the M5 cycle immediately after
M4 has been declared unless someone speaks up. We have to file a CQ
because of the size of the contribution. I guess I should go ahead with
that once we managed to have consensus if this initial bits are ready to
go in

Like the split editors in the IDE world this has been the most requested
feature in RCP applications I encountered in my past ~10 years of
Eclipse RCP consulting.

Tom
Comment 2 Paul Webster CLA 2013-12-13 11:25:50 EST
Changes:

> https://git.eclipse.org/r/#/c/19743/
> https://git.eclipse.org/r/#/c/19746/
Comment 4 Thomas Schindl CLA 2014-01-15 02:12:58 EST
Paul - Hudson fails for the https://git.eclipse.org/r/#/c/19746/ with very strange compiler errors. I'd really like to get this into M5 - if not everything, at least the model changes need to go in.

I'm in a meeting all day but try to ping you some time in the afternoon so that we can get this fixed.
Comment 5 Paul Webster CLA 2014-01-15 06:22:01 EST
It looks like org.eclipse.e4.ui.tests needs to be updated (and run) for the model changes.

PW
Comment 6 Thomas Schindl CLA 2014-01-15 17:02:25 EST
I've pushed the test updates as https://git.eclipse.org/r/#/c/20690/
Comment 7 Thomas Schindl CLA 2014-01-15 17:04:34 EST
I guess I have done something wrong because this should most likely get a new patchset at https://git.eclipse.org/r/#/c/19746/
Comment 8 Thomas Schindl CLA 2014-01-16 14:08:49 EST
The CQ is http://dev.eclipse.org/ipzilla/show_bug.cgi?id=7862
Comment 9 Thomas Schindl CLA 2014-01-16 14:12:42 EST
I'm not sure if this is still needed when we have the CLA but to make extra sure. Dirk can you:
a) I've authored the code commited to the e(fx)clipse project 100% myself
b) I have the right to conribute it
c) I have contributed the content under the EPL
Comment 10 Dirk Fauth CLA 2014-01-16 14:26:58 EST
AFAIK with the signed CLA this is not necessary anymore. But to be sure

a) I've authored the code committed 100% myself
b) I have the right to conribute it
c) I have contributed the content under the EPL
Comment 11 Paul Webster CLA 2014-01-24 14:33:24 EST
Released as http://git.eclipse.org/c/platform/eclipse.platform.ui.git/commit/?id=00ef1b00b3c680ff49720c442cbf117566d8d60b and http://git.eclipse.org/c/platform/eclipse.platform.ui.git/commit/?id=e0d7e6a9a396df1f0709de5ffd4e76617df90c03

We have an I build on Tuesday, at 08:00 EST.  Can we confirm this is working they way we want after that?

PW
Comment 12 Paul Webster CLA 2014-01-24 14:42:07 EST
(In reply to Paul Webster from comment #11)
> Released as
> http://git.eclipse.org/c/platform/eclipse.platform.ui.git/commit/
> ?id=00ef1b00b3c680ff49720c442cbf117566d8d60b and
> http://git.eclipse.org/c/platform/eclipse.platform.ui.git/commit/
> ?id=e0d7e6a9a396df1f0709de5ffd4e76617df90c03

Dirk and Tom, thank you for this effort.  It's been a long time since we've needed a CQ for a code contribution :-)

PW
Comment 13 Paul Webster CLA 2014-02-21 10:16:44 EST
Now that the contributions are in, what's the state of this bug?

PW
Comment 14 Dirk Fauth CLA 2014-02-21 10:19:20 EST
As the implementation is in the repository and the tests with the example applications are working fine, the state of this ticket is resolved.

If any issues occur, there should be new tickets that point to this one.
Comment 15 Paul Webster CLA 2014-03-04 12:21:42 EST
In 4.4.0.I20140303-2000

Dirk, could you also confirm the build works the way you expect?

PW
Comment 16 Dirk Fauth CLA 2014-03-05 07:33:39 EST
Downloaded and installed 4.4.0.I20140303-2000

Imported my projects from GitHub that are making use of the new features. Started the sample applications without any further modifications, and everything works as expected.
Comment 17 Lars Vogel CLA 2014-03-05 07:49:01 EST
(In reply to Dirk Fauth from comment #16)
> Downloaded and installed 4.4.0.I20140303-2000
> 
> Imported my projects from GitHub that are making use of the new features.
> Started the sample applications without any further modifications, and
> everything works as expected.

Can you, for reference, at a link to the Github project?
Comment 18 Dirk Fauth CLA 2014-03-05 07:55:36 EST
New message extension and dynamic Locale change example:
https://github.com/fipro78/e4translationexample

Using class based ResourceBundles for the application model example:
https://github.com/fipro78/e4classbasedtranslation