diff options
author | Simon Brandhof <simon.brandhof@gmail.com> | 2011-08-01 16:10:08 +0200 |
---|---|---|
committer | Simon Brandhof <simon.brandhof@gmail.com> | 2011-08-01 16:10:08 +0200 |
commit | c8c4752cf3f27fb4b0acf1234208127934689568 (patch) | |
tree | 968e2a81f7ba390d2037c48b2c15bffa3c3ef702 /sonar-server/src | |
parent | 67fe723d894ac406fe7b859bdcd13d5ea35e6f6e (diff) | |
download | sonarqube-c8c4752cf3f27fb4b0acf1234208127934689568.tar.gz sonarqube-c8c4752cf3f27fb4b0acf1234208127934689568.zip |
SONAR-75 support GWT components integrated to core
Diffstat (limited to 'sonar-server/src')
5 files changed, 22 insertions, 5 deletions
diff --git a/sonar-server/src/main/java/org/sonar/server/platform/Platform.java b/sonar-server/src/main/java/org/sonar/server/platform/Platform.java index 6835c7f69dd..2d8ef632fa9 100644 --- a/sonar-server/src/main/java/org/sonar/server/platform/Platform.java +++ b/sonar-server/src/main/java/org/sonar/server/platform/Platform.java @@ -41,6 +41,7 @@ import org.sonar.core.components.DefaultMetricFinder; import org.sonar.core.components.DefaultModelFinder; import org.sonar.core.components.DefaultRuleFinder; import org.sonar.core.components.DefaultUserFinder; +import org.sonar.core.i18n.GwtI18n; import org.sonar.core.i18n.I18nManager; import org.sonar.core.i18n.RuleI18nManager; import org.sonar.core.notifications.DefaultNotificationManager; @@ -191,6 +192,7 @@ public final class Platform { servicesContainer.as(Characteristics.CACHE).addComponent(DefaultUserFinder.class); servicesContainer.as(Characteristics.CACHE).addComponent(I18nManager.class); servicesContainer.as(Characteristics.CACHE).addComponent(RuleI18nManager.class); + servicesContainer.as(Characteristics.CACHE).addComponent(GwtI18n.class); // Notifications servicesContainer.as(Characteristics.CACHE).addComponent(NotificationService.class); diff --git a/sonar-server/src/main/java/org/sonar/server/ui/JRubyFacade.java b/sonar-server/src/main/java/org/sonar/server/ui/JRubyFacade.java index df520e59ad2..e72305ebacd 100644 --- a/sonar-server/src/main/java/org/sonar/server/ui/JRubyFacade.java +++ b/sonar-server/src/main/java/org/sonar/server/ui/JRubyFacade.java @@ -338,6 +338,13 @@ public final class JRubyFacade { return i18n.searchRuleName(rubyLocale, searchText); } + public String getJsL10nDictionnary(String rubyLocale) { + if (i18n == null) { + i18n = getContainer().getComponent(JRubyI18n.class); + } + return i18n.getJsDictionnary(rubyLocale); + } + public ReviewsNotificationManager getReviewsNotificationManager() { return getContainer().getComponent(ReviewsNotificationManager.class); } diff --git a/sonar-server/src/main/java/org/sonar/server/ui/JRubyI18n.java b/sonar-server/src/main/java/org/sonar/server/ui/JRubyI18n.java index 077556d67b3..67ecb922744 100644 --- a/sonar-server/src/main/java/org/sonar/server/ui/JRubyI18n.java +++ b/sonar-server/src/main/java/org/sonar/server/ui/JRubyI18n.java @@ -20,14 +20,14 @@ package org.sonar.server.ui; import com.google.common.collect.Maps; +import org.apache.commons.lang.StringEscapeUtils; import org.apache.commons.lang.StringUtils; import org.sonar.api.ServerComponent; import org.sonar.api.i18n.I18n; +import org.sonar.core.i18n.GwtI18n; import org.sonar.core.i18n.RuleI18nManager; -import java.util.List; -import java.util.Locale; -import java.util.Map; +import java.util.*; /** * Bridge between JRuby webapp and Java I18n component @@ -37,10 +37,12 @@ public final class JRubyI18n implements ServerComponent { private I18n i18n; private Map<String, Locale> localesByRubyKey = Maps.newHashMap(); private RuleI18nManager ruleI18nManager; + private GwtI18n gwtI18n; - public JRubyI18n(I18n i18n, RuleI18nManager ruleI18nManager) { + public JRubyI18n(I18n i18n, RuleI18nManager ruleI18nManager, GwtI18n gwtI18n) { this.i18n = i18n; this.ruleI18nManager = ruleI18nManager; + this.gwtI18n = gwtI18n; } Locale getLocale(String rubyKey) { @@ -86,4 +88,8 @@ public final class JRubyI18n implements ServerComponent { public List<RuleI18nManager.RuleKey> searchRuleName(String rubyLocale, String searchText) { return ruleI18nManager.searchNames(searchText, toLocale(rubyLocale)); } + + public String getJsDictionnary(String rubyLocale) { + return gwtI18n.getJsDictionnary(toLocale(rubyLocale)); + } } diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/gwt/_base.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/gwt/_base.html.erb index efb0a92af02..242ac153fae 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/gwt/_base.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/gwt/_base.html.erb @@ -28,4 +28,5 @@ }; var modules = new Object(); + <%= Java::OrgSonarServerUi::JRubyFacade.getInstance().getJsL10nDictionnary(I18n.locale) -%> </script>
\ No newline at end of file diff --git a/sonar-server/src/test/java/org/sonar/server/ui/JRubyI18nTest.java b/sonar-server/src/test/java/org/sonar/server/ui/JRubyI18nTest.java index c03934a3940..7857d6d511d 100644 --- a/sonar-server/src/test/java/org/sonar/server/ui/JRubyI18nTest.java +++ b/sonar-server/src/test/java/org/sonar/server/ui/JRubyI18nTest.java @@ -22,6 +22,7 @@ package org.sonar.server.ui; import org.hamcrest.core.Is; import org.junit.Test; import org.sonar.api.i18n.I18n; +import org.sonar.core.i18n.GwtI18n; import org.sonar.core.i18n.RuleI18nManager; import java.util.Locale; @@ -40,7 +41,7 @@ public class JRubyI18nTest { @Test public void shouldCacheLocales() { - JRubyI18n i18n = new JRubyI18n(mock(I18n.class), mock(RuleI18nManager.class)); + JRubyI18n i18n = new JRubyI18n(mock(I18n.class), mock(RuleI18nManager.class), mock(GwtI18n.class)); assertThat(i18n.getLocalesByRubyKey().size(), Is.is(0)); i18n.getLocale("fr"); |