Community
Participate
Working Groups
Build Identifier: Spin of from discussion at http://www.eclipse.org/forums/index.php?t=msg&th=201084 Currently some parts of the Scout framework rely on the class ScoutTexts to provide texts while user written code is meant to rely on the class Texts. Texts_*.properties files can't overload texts from ScoutTexts_*.properties files, making it difficult to provide fully translated applications. Andys proposed solution: "The solution for such a behavior would be to provide a INlsTextService. A service has the mentioned scope of a scout project (environment) and can easily be overloaded (service ranking)." Reproducible: Always
ref at BSI #100433
26.4.11 imotsch Details: Evaluated various solution variants: 1) service: not quite flexible since osgi services are either global or scoped on scout sessions. However, also gui composites are using ScoutTexts.get(...) 2) extension point: not valid. since this would merge texts of all scout apps in same workbench together 3) texts attached to client/server session: good starting point since swing/swt environment knows session. 3) is the solution. The session-scoped nls texts (Texts.java) is set as ClientJob/ServerJob.setProperty() value on the Job and is then accessible via currentJob. ScoutTexts is delegating to this scope texts (default to ScoutTexts self) ClientSession and ServerSession can override getNlsTexts() method to return their specific Texts.getInstance() object. Swing is using the client session texts globally, swt / rwt is using the client session texts via Display.getData() accessor. Migration: optionally add the following overrides to the client and server session of the application to support for partially overriding existing scout texts public class ClientSession ... @Override public DynamicNls getNlsTexts() { return Texts.getInstance(); } public class ServerSession ... @Override public DynamicNls getNlsTexts() { return Texts.getInstance(); }
4.5.2011 lhuser: Tested on Scout Trunk with Swing Gui. NOT tested with SWT Gui. The following test cases are OK: - Overwrite texts for ScoutTexts.get() in custom Form: OK - Overwrite texts for ScoutTexts.get() in Scout components (e.g. AbstractSearchButton): OK - Overwrite texts for SwingUtlity.getNlsText() in Swing components (e.g. StatusBar->Network Latency): OK - NOT tested for SWT components! The following test case is NOK: - Overwrite texts in the Calendar (e.g. link 'Month'). Some texts are set as UI defaults (interceptUIDefaults() in AbstractSwingEnvironment calls UIDefaultsInjector.inject(), which queries texts with ScoutTexts.get()). The SwingEnvironment is created in the constructor of the AbstractSwingApplication. The ClientSession is created afterwards (during the start() Method of AbstractSwingApplication). Possible solution(?): call interceptUIDefaults() after the ClientSession has been created in Method AbstractSwingApplication.startInSubject().
Since this applies to swing ui, you can simply override SwingApplication.createSwingEnvironment() in your project as: @Override protected ISwingEnvironment createSwingEnvironment() { SwingUtility.setNlsTexts(Texts.getInstance()); return super.createSwingEnvironment(); }
This will not resolve the issue, because UIDefaultsInjector.inject() does not invoke the SwingUtility for texts but calls ScoutTexts.get(). ScoutTexts.get() then queries the current Job for an instance of DynamicNls. At this point, the current Job will not deliver a DynamicNls instance (because a ClientSession has not been created yet).
Successfully tested on Scout Trunk after another update by Ivan Motsch.
shipped with eclipse scout 3.7.0