Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » scout » TEXTS: having a strict service
TEXTS: having a strict service [message #830162] Tue, 27 March 2012 09:23 Go to next message
Jeremie Bresson is currently offline Jeremie Bresson
Messages: 729
Registered: October 2011
Senior Member

I was wondering if it is possible to write a second TextProviderService that is stricter than the Default. My idea is to have it fail (ProcessingException) if the text is not found.

I would like to overwrite (maybe with a @Priority) the default TEXTS service. I could use that for some tests (maybe dev product, or JUnit Test application).

Is it possible?

(I am on Jan2012 branch; this means that I have already the TextProvider Service coming with Juno.)

Re: TEXTS: having a strict service [message #830172 is a reply to message #830162] Tue, 27 March 2012 09:40 Go to previous messageGo to next message
Jeremie Bresson is currently offline Jeremie Bresson
Messages: 729
Registered: October 2011
Senior Member
It seems to work with:
public class MyAppTextProviderService extends AbstractDynamicNlsTextProviderService {

  protected String getDynamicNlsBaseName() {
    return "resources.texts.Texts";

  public String getText(Locale locale, String key, String... messageArguments) {
    if (getTextMap(locale).get(key) != null) {
      return super.getText(locale, key, messageArguments);
    throw new IllegalArgumentException("Missing Text key <" + key + "> for locale <" + locale + ">");

But now the application do not start:
WARNING org.eclipse.scout.rt.ui.swing.AbstractSwingApplication.<init>( null java.lang.reflect.InvocationTargetException
at java.awt.EventQueue.invokeAndWait(
at javax.swing.SwingUtilities.invokeAndWait(
Caused by: java.lang.IllegalArgumentException: Missing Text key <Apply> for locale <null>
at org.eclipse.scout.rt.shared.ScoutTexts.getTextInternal(
at org.eclipse.scout.rt.shared.ScoutTexts.getText(
at org.eclipse.scout.rt.shared.ScoutTexts.getText(
at org.eclipse.scout.rt.shared.ScoutTexts.get(
at org.eclipse.scout.rt.ui.swing.SwingUtility.getNlsText(
at org.eclipse.scout.rt.ui.swing.inject.UIDefaultsInjector.inject(

Need to check what this "Apply" key is.

What is the Idea of multiple TextProviderService?
- Asking the first TextProvider (Application Provider), then ask Scout TextProvider and so on?

In this case is my first try not good enougth... Because I only want to have an exception when nothing was found (in each TextProvider of the application)....

Re: TEXTS: having a strict service [message #832134 is a reply to message #830162] Thu, 29 March 2012 20:25 Go to previous message
Claudio Guglielmo is currently offline Claudio Guglielmo
Messages: 127
Registered: March 2010
Senior Member
Hi Jéremie

When using the priority annotation on the text provider services (and as well on the icon provider services) your are actually defining the order of the text resp. icon lookup. This enables overriding of existing texts and icons.

A very low priority means the service is considered last for the lookup. You can try setting the priority of your MyAppTextProviderService to a very low value (f.e. -5000). If any other service can't provide the text your service will be considered.

I haven't tried it. Please let us know if it works.

BTW: Setting the priority annotation has the same effect as setting the service ranking when registering the service in the plugin.xml.


[Updated on: Thu, 29 March 2012 20:27]

Report message to a moderator

Previous Topic:Eclipse Scout 3.8 M6
Next Topic:Unit Tests and BlockingCondition
Goto Forum:

Current Time: Thu Oct 02 10:32:03 GMT 2014

Powered by FUDForum. Page generated in 0.01751 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software