From: Evgeny Mandrikov Date: Thu, 19 Jan 2012 15:15:43 +0000 (+0400) Subject: SONAR-3179 Use naming convention for localization of qualifiers X-Git-Tag: 2.14~266 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=7e8f15bbae7bee07d6b0845743fbb79f5ae5b1f0;p=sonarqube.git SONAR-3179 Use naming convention for localization of qualifiers Change localization for "qualifier.BRK" from "Module" to "Sub-project". --- diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/resources/DefaultResources.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/resources/DefaultResources.java index 6380431f40d..ab954783c3e 100644 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/resources/DefaultResources.java +++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/resources/DefaultResources.java @@ -32,16 +32,16 @@ public class DefaultResources extends ExtensionProvider implements ServerExtensi @Override public List provide() { return Arrays.asList( - ResourceDefinition.builder(Qualifiers.VIEW).setName("view").build(), - ResourceDefinition.builder(Qualifiers.SUBVIEW).setName("sub_view").build(), - ResourceDefinition.builder(Qualifiers.PROJECT).setName("project").build(), - ResourceDefinition.builder(Qualifiers.MODULE).setName("sub_project").build(), - ResourceDefinition.builder(Qualifiers.DIRECTORY).setName("directory").build(), - ResourceDefinition.builder(Qualifiers.PACKAGE).setName("package").build(), - ResourceDefinition.builder(Qualifiers.FILE).setName("file").build(), - ResourceDefinition.builder(Qualifiers.CLASS).setName("class").build(), - ResourceDefinition.builder(Qualifiers.UNIT_TEST_FILE).setName("unit_test").build(), - ResourceDefinition.builder(Qualifiers.LIBRARY).setName("library").build()); + ResourceDefinition.builder(Qualifiers.VIEW).build(), + ResourceDefinition.builder(Qualifiers.SUBVIEW).build(), + ResourceDefinition.builder(Qualifiers.PROJECT).build(), + ResourceDefinition.builder(Qualifiers.MODULE).build(), + ResourceDefinition.builder(Qualifiers.DIRECTORY).build(), + ResourceDefinition.builder(Qualifiers.PACKAGE).build(), + ResourceDefinition.builder(Qualifiers.FILE).build(), + ResourceDefinition.builder(Qualifiers.CLASS).build(), + ResourceDefinition.builder(Qualifiers.UNIT_TEST_FILE).build(), + ResourceDefinition.builder(Qualifiers.LIBRARY).build()); } } diff --git a/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/core.properties b/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/core.properties index a3e5a58a631..00435931bb2 100644 --- a/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/core.properties +++ b/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/core.properties @@ -211,7 +211,7 @@ time_changes=Time changes #------------------------------------------------------------------------------ qualifier.TRK=Project -qualifier.BRC=Module +qualifier.BRC=Sub-project qualifier.DIR=Directory qualifier.PAC=Package qualifier.VW=View @@ -221,7 +221,7 @@ qualifier.CLA=File qualifier.UTS=Unit Test File qualifiers.TRK=Projects -qualifiers.BRC=Modules +qualifiers.BRC=Sub-projects qualifiers.DIR=Directories qualifiers.PAC=Packages qualifiers.VW=Views diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/resources/ResourceDefinition.java b/sonar-plugin-api/src/main/java/org/sonar/api/resources/ResourceDefinition.java index 899ba0b6c84..09a057373cc 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/resources/ResourceDefinition.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/resources/ResourceDefinition.java @@ -32,7 +32,6 @@ public final class ResourceDefinition implements ServerExtension { public static class Builder { private String qualifier; - private String name; private String iconPath; private boolean availableForFilters = false; @@ -40,14 +39,6 @@ public final class ResourceDefinition implements ServerExtension { this.qualifier = qualifier; } - /** - * @param name name which would be used for localization - */ - public Builder setName(String name) { - this.name = name; - return this; - } - /** * @param iconPath path to icon, relative to context of web-application (e.g. "/images/q/DIR.png") */ @@ -62,13 +53,10 @@ public final class ResourceDefinition implements ServerExtension { } public ResourceDefinition build() { - if (Strings.isNullOrEmpty(name)) { - name = qualifier; - } if (Strings.isNullOrEmpty(iconPath)) { iconPath = "/images/q/" + qualifier + ".png"; } - return new ResourceDefinition(qualifier, name, iconPath, availableForFilters); + return new ResourceDefinition(qualifier, iconPath, availableForFilters); } } @@ -79,13 +67,11 @@ public final class ResourceDefinition implements ServerExtension { } private final String qualifier; - private final String name; private final String iconPath; private final boolean availableForFilters; - private ResourceDefinition(String qualifier, String name, String iconPath, boolean availableForFilters) { + private ResourceDefinition(String qualifier, String iconPath, boolean availableForFilters) { this.qualifier = qualifier; - this.name = name; this.iconPath = iconPath; this.availableForFilters = availableForFilters; } @@ -94,10 +80,6 @@ public final class ResourceDefinition implements ServerExtension { return qualifier; } - public String getName() { - return name; - } - public String getIconPath() { return iconPath; } diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/resources/ResourceDefinitionTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/resources/ResourceDefinitionTest.java index 852919406b1..c18d59a7f58 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/resources/ResourceDefinitionTest.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/resources/ResourceDefinitionTest.java @@ -31,7 +31,6 @@ public class ResourceDefinitionTest { ResourceDefinition def = ResourceDefinition.builder("qualifier") .build(); assertThat(def.getQualifier(), is("qualifier")); - assertThat(def.getName(), is("qualifier")); assertThat(def.getIconPath(), is("/images/q/qualifier.png")); } @@ -39,10 +38,8 @@ public class ResourceDefinitionTest { public void shouldCreate() { ResourceDefinition def = ResourceDefinition.builder("qualifier") .setIconPath("/custom-icon.png") - .setName("custom-name") .build(); assertThat(def.getQualifier(), is("qualifier")); - assertThat(def.getName(), is("custom-name")); assertThat(def.getIconPath(), is("/custom-icon.png")); } diff --git a/sonar-server/src/main/webapp/WEB-INF/app/helpers/application_helper.rb b/sonar-server/src/main/webapp/WEB-INF/app/helpers/application_helper.rb index 4bdd5be00ab..3d69c422203 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/helpers/application_helper.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/helpers/application_helper.rb @@ -42,7 +42,7 @@ module ApplicationHelper qualifier=(object.respond_to?('qualifier') ? object.qualifier : object.to_s) if qualifier definition = Java::OrgSonarServerUi::JRubyFacade.getInstance().getResourceDefinition(qualifier) - image_tag(definition.getIconPath(), :alt => message(definition.getName())) + image_tag(definition.getIconPath(), :alt => message("qualifier.#{qualifier}")) else image_tag('e16.gif') end diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/filters/new.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/filters/new.html.erb index d4c9a75eab5..dc1b9b21f28 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/filters/new.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/filters/new.html.erb @@ -50,32 +50,32 @@ table#columns td { <% qualifiers=(@filter.criterion('qualifier') ? @filter.criterion('qualifier').text_values : []) %> <% if controller.java_facade.hasPlugin('views') %> - id="q-VW"> + id="q-VW"> - id="q-SVW"> + id="q-SVW"> <% end %> - id="q-TRK"> + id="q-TRK"> - id="q-BRC"> + id="q-BRC"> - id="q-DIR"> + id="q-DIR"> - id="q-FIL"> + id="q-FIL"> - id="q-UTS"> + id="q-UTS"> <% for desc in controller.java_facade.getResourceDefinitionsForFilter() qualifier = desc.getQualifier() %> id="q-<%= qualifier -%>"> - + <% end %>