Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 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 BressonFriend
Messages: 1252
Registered: October 2011
Senior Member
Hi,

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.)


Thanks,
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 BressonFriend
Messages: 1252
Registered: October 2011
Senior Member
It seems to work with:
public class MyAppTextProviderService extends AbstractDynamicNlsTextProviderService {

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

  @Override
  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:
Quote:
WARNING org.eclipse.scout.rt.ui.swing.AbstractSwingApplication.<init>(AbstractSwingApplication.java:92) null java.lang.reflect.InvocationTargetException
at java.awt.EventQueue.invokeAndWait(EventQueue.java:1055)
at javax.swing.SwingUtilities.invokeAndWait(SwingUtilities.java:1326)
....
Caused by: java.lang.IllegalArgumentException: Missing Text key <Apply> for locale <null>
at myapp.shared.core.services.common.text.MyAppTextProviderService.getText(MyAppTextProviderService.java:19)
at org.eclipse.scout.rt.shared.ScoutTexts.getTextInternal(ScoutTexts.java:97)
at org.eclipse.scout.rt.shared.ScoutTexts.getText(ScoutTexts.java:79)
at org.eclipse.scout.rt.shared.ScoutTexts.getText(ScoutTexts.java:75)
at org.eclipse.scout.rt.shared.ScoutTexts.get(ScoutTexts.java:52)
at org.eclipse.scout.rt.ui.swing.SwingUtility.getNlsText(SwingUtility.java:283)
at org.eclipse.scout.rt.ui.swing.inject.UIDefaultsInjector.inject(UIDefaultsInjector.java:65)
...


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 GuglielmoFriend
Messages: 256
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.

Regards
Claudio

[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 Apr 25 00:22:25 GMT 2024

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

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

Back to the top