Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 331535

Summary: Merge ScoutText and Text classes
Product: z_Archived Reporter: Arthur vD <avandorp>
Component: ScoutAssignee: Matthias Zimmermann <zimmermann>
Status: CLOSED FIXED QA Contact:
Severity: enhancement    
Priority: P3 CC: Andreas.Hoegger, avandorp, lhu, zimmermann
Version: unspecified   
Target Milestone: 3.7.0 Indigo   
Hardware: All   
OS: All   
URL: http://www.eclipse.org/forums/index.php?t=msg&th=201084
Whiteboard:

Description Arthur vD CLA 2010-12-01 08:10:32 EST
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
Comment 1 Matthias Zimmermann CLA 2011-04-05 07:41:08 EDT
ref at BSI #100433
Comment 2 Matthias Zimmermann CLA 2011-05-05 02:26:51 EDT
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();
  }
Comment 3 Matthias Zimmermann CLA 2011-05-05 02:28:49 EDT
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().
Comment 4 Ivan Motsch CLA 2011-05-05 11:42:23 EDT
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();
  }
Comment 5 Lukas Huser CLA 2011-05-06 06:28:35 EDT
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).
Comment 6 Lukas Huser CLA 2011-05-09 10:20:08 EDT
Successfully tested on Scout Trunk after another update by Ivan Motsch.
Comment 7 Matthias Zimmermann CLA 2011-06-28 08:02:19 EDT
shipped with eclipse scout 3.7.0