From 3e87a7151696d1a4aaa85ce314b74d5cc62f1309 Mon Sep 17 00:00:00 2001 From: Simon Brandhof Date: Mon, 1 Aug 2011 17:27:07 +0200 Subject: [PATCH] SONAR-75 Remove unused French GWT properties + add method Metric.Builder#setUserManaged(boolean) --- .../testdetailsviewer/client/TestsPanel.java | 7 ++-- .../testdetailsviewer/client/TestsViewer.java | 10 +++-- .../plugins/core/hotspots/GwtHotspots.gwt.xml | 1 - .../client/I18nConstants_fr.properties | 16 -------- .../core/metrics/UserManagedMetrics.java | 26 +++++++++---- .../ui/dependencies/DependenciesTab.gwt.xml | 2 - .../client/I18nConstants_fr.properties | 7 ---- .../design/ui/libraries/LibrariesPage.gwt.xml | 1 - .../client/I18nConstants_fr.properties | 6 --- .../plugins/design/ui/page/DesignPage.gwt.xml | 1 - .../page/client/I18nConstants_fr.properties | 8 ---- .../resources/org/sonar/l10n/core.properties | 38 +++++++++++++------ .../resources/org/sonar/l10n/gwt.properties | 11 +++++- .../java/org/sonar/api/measures/Metric.java | 24 +++++++++++- .../main/webapp/WEB-INF/app/models/metric.rb | 2 +- 15 files changed, 88 insertions(+), 72 deletions(-) delete mode 100644 plugins/sonar-core-gwt/src/main/resources/org/sonar/plugins/core/hotspots/client/I18nConstants_fr.properties delete mode 100644 plugins/sonar-design-plugin/src/main/resources/org/sonar/plugins/design/ui/dependencies/client/I18nConstants_fr.properties delete mode 100644 plugins/sonar-design-plugin/src/main/resources/org/sonar/plugins/design/ui/libraries/client/I18nConstants_fr.properties delete mode 100644 plugins/sonar-design-plugin/src/main/resources/org/sonar/plugins/design/ui/page/client/I18nConstants_fr.properties diff --git a/plugins/sonar-core-gwt/src/main/java/org/sonar/plugins/core/testdetailsviewer/client/TestsPanel.java b/plugins/sonar-core-gwt/src/main/java/org/sonar/plugins/core/testdetailsviewer/client/TestsPanel.java index 99f50ff1bc2..39e06712348 100644 --- a/plugins/sonar-core-gwt/src/main/java/org/sonar/plugins/core/testdetailsviewer/client/TestsPanel.java +++ b/plugins/sonar-core-gwt/src/main/java/org/sonar/plugins/core/testdetailsviewer/client/TestsPanel.java @@ -21,6 +21,7 @@ package org.sonar.plugins.core.testdetailsviewer.client; import com.google.gwt.gen2.table.override.client.FlexTable; import com.google.gwt.gen2.table.override.client.FlexTable.FlexCellFormatter; +import com.google.gwt.i18n.client.Dictionary; import com.google.gwt.user.client.DOM; import com.google.gwt.user.client.ui.*; import com.google.gwt.xml.client.Document; @@ -75,12 +76,13 @@ public class TestsPanel extends Composite { Document parsed = XMLParser.parse(testXMLData); NodeList testcasesXML = parsed.getElementsByTagName("testcase"); + Dictionary l10n = Dictionary.getDictionary("l10n"); FlexTable table = new FlexTable(); table.setStylePrimaryName("detailsTable"); table.setText(0, 0, ""); table.setText(0, 1, ""); - table.setText(0, 2, "Duration"); - table.setText(0, 3, "Unit test name"); + table.setText(0, 2, l10n.get("unittest.duration")); + table.setText(0, 3, l10n.get("unittest.name")); table.getCellFormatter().getElement(0, 1).setId("iCol"); table.getCellFormatter().getElement(0, 2).setId("dCol"); setRowStyle(0, table, "header", false); @@ -106,7 +108,6 @@ public class TestsPanel extends Composite { } private void renderTestDetails(int row, int testCounter, String testCaseStatus, Element stackTrace, String name, String timeMS, FlexTable table) { - HTML icon = new HTML(" "); icon.setStyleName(testCaseStatus); table.setWidget(row, 1, icon); diff --git a/plugins/sonar-core-gwt/src/main/java/org/sonar/plugins/core/testdetailsviewer/client/TestsViewer.java b/plugins/sonar-core-gwt/src/main/java/org/sonar/plugins/core/testdetailsviewer/client/TestsViewer.java index c757be379f6..9b066b0659b 100644 --- a/plugins/sonar-core-gwt/src/main/java/org/sonar/plugins/core/testdetailsviewer/client/TestsViewer.java +++ b/plugins/sonar-core-gwt/src/main/java/org/sonar/plugins/core/testdetailsviewer/client/TestsViewer.java @@ -19,6 +19,7 @@ */ package org.sonar.plugins.core.testdetailsviewer.client; +import com.google.gwt.i18n.client.Dictionary; import com.google.gwt.user.client.ui.FlowPanel; import com.google.gwt.user.client.ui.HorizontalPanel; import com.google.gwt.user.client.ui.Widget; @@ -55,6 +56,7 @@ public class TestsViewer extends Page { @Override protected void display(FlowPanel header, Resource resource) { + Dictionary l10n = Dictionary.getDictionary("l10n"); HorizontalPanel panel = new HorizontalPanel(); header.add(panel); @@ -68,18 +70,18 @@ public class TestsViewer extends Page { String skippedHtml = ""; Measure skipped = resource.getMeasure(Metrics.SKIPPED_TESTS); if (skipped != null && skipped.getValue() > 0.0) { - skippedHtml += " (+" + skipped.getFormattedValue() + " skipped)"; + skippedHtml += " (+" + skipped.getFormattedValue() + " " + l10n.get("unittest.skipped") + ")"; } addCell(panel, - "Tests: ", + l10n.get("unittest.tests") + ": ", resource.getMeasureFormattedValue(Metrics.TESTS, "-") + skippedHtml); addCell(panel, - "Failures/Errors: ", + l10n.get("unittest.failures") + ": ", resource.getMeasureFormattedValue(Metrics.TEST_FAILURES, "0") + "/" + resource.getMeasureFormattedValue(Metrics.TEST_ERRORS, "0")); addCell(panel, - "Duration: ", + l10n.get("unittest.duration") + ": ", resource.getMeasureFormattedValue(Metrics.TEST_EXECUTION_TIME, "-")); } } diff --git a/plugins/sonar-core-gwt/src/main/resources/org/sonar/plugins/core/hotspots/GwtHotspots.gwt.xml b/plugins/sonar-core-gwt/src/main/resources/org/sonar/plugins/core/hotspots/GwtHotspots.gwt.xml index ad7ecd8c11f..ffb2d169793 100644 --- a/plugins/sonar-core-gwt/src/main/resources/org/sonar/plugins/core/hotspots/GwtHotspots.gwt.xml +++ b/plugins/sonar-core-gwt/src/main/resources/org/sonar/plugins/core/hotspots/GwtHotspots.gwt.xml @@ -6,5 +6,4 @@ - \ No newline at end of file diff --git a/plugins/sonar-core-gwt/src/main/resources/org/sonar/plugins/core/hotspots/client/I18nConstants_fr.properties b/plugins/sonar-core-gwt/src/main/resources/org/sonar/plugins/core/hotspots/client/I18nConstants_fr.properties deleted file mode 100644 index efd8a8c42d6..00000000000 --- a/plugins/sonar-core-gwt/src/main/resources/org/sonar/plugins/core/hotspots/client/I18nConstants_fr.properties +++ /dev/null @@ -1,16 +0,0 @@ -# This file must use UTF-8 encoding - -titleMostViolatedRules=Règles les moins respectées -titleMostViolatedResources=Les moins respectueux des règles -titleLongestTests=Les plus long tests -titleMostComplexResources=Les plus complexes -titleMostDuplicatedResources=Les plus dupliqués -titleLessTested=Le plus de lignes non testées -titleMostComplexMethods=Avec les méthodes les plus complexes -titleMostUndocumentedAPI=Les API les moins documentées -noMeasures=Aucune mesure -anyPriority=Toutes les priorités -moreDetails=Détails -lcom4=Manque de cohésion entre méthodes -rfc=Response for class -designTitle= \ No newline at end of file diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/metrics/UserManagedMetrics.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/metrics/UserManagedMetrics.java index 8082cd4b95c..f92fc25fbcd 100644 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/metrics/UserManagedMetrics.java +++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/metrics/UserManagedMetrics.java @@ -30,13 +30,23 @@ public final class UserManagedMetrics implements Metrics { public List getMetrics() { return Arrays.asList( - new Metric("burned_budget", "Burned budget", "The budget already used in the project", Metric.ValueType.FLOAT, - Metric.DIRECTION_NONE, false, DOMAIN) - .setUserManaged(true), - new Metric("team_size", "Team size", "Size of the project team", Metric.ValueType.INT, Metric.DIRECTION_NONE, false, DOMAIN) - .setUserManaged(true), - new Metric("business_value", "Business value", "An indication on the value of the project for the business", - Metric.ValueType.FLOAT, Metric.DIRECTION_BETTER, true, DOMAIN) - .setUserManaged(true)); + new Metric.Builder("burned_budget", "Burned budget", Metric.ValueType.FLOAT) + .setDirection(Metric.DIRECTION_NONE) + .setQualitative(false) + .setDomain(DOMAIN) + .setUserManaged(true) + .create(), + new Metric.Builder("business_value", "Business value", Metric.ValueType.FLOAT) + .setDirection(Metric.DIRECTION_BETTER) + .setQualitative(true) + .setDomain(DOMAIN) + .setUserManaged(true) + .create(), + new Metric.Builder("team_size", "Team size", Metric.ValueType.INT) + .setDirection(Metric.DIRECTION_NONE) + .setQualitative(false) + .setDomain(DOMAIN) + .setUserManaged(true) + .create()); } } diff --git a/plugins/sonar-design-plugin/src/main/resources/org/sonar/plugins/design/ui/dependencies/DependenciesTab.gwt.xml b/plugins/sonar-design-plugin/src/main/resources/org/sonar/plugins/design/ui/dependencies/DependenciesTab.gwt.xml index 1d8aa50cac9..dcb24d7e3fa 100644 --- a/plugins/sonar-design-plugin/src/main/resources/org/sonar/plugins/design/ui/dependencies/DependenciesTab.gwt.xml +++ b/plugins/sonar-design-plugin/src/main/resources/org/sonar/plugins/design/ui/dependencies/DependenciesTab.gwt.xml @@ -6,6 +6,4 @@ - - diff --git a/plugins/sonar-design-plugin/src/main/resources/org/sonar/plugins/design/ui/dependencies/client/I18nConstants_fr.properties b/plugins/sonar-design-plugin/src/main/resources/org/sonar/plugins/design/ui/dependencies/client/I18nConstants_fr.properties deleted file mode 100644 index ab2e9eab623..00000000000 --- a/plugins/sonar-design-plugin/src/main/resources/org/sonar/plugins/design/ui/dependencies/client/I18nConstants_fr.properties +++ /dev/null @@ -1,7 +0,0 @@ -afferentCouplings= Dépendances entrantes -efferentCouplings= Dépendances sortantes -classes=Classes -dit=Profondeur d'héritage -noc=Nombre d'enfants -lcom4=Manque de cohésion des méthodes -noData=Aucune information \ No newline at end of file diff --git a/plugins/sonar-design-plugin/src/main/resources/org/sonar/plugins/design/ui/libraries/LibrariesPage.gwt.xml b/plugins/sonar-design-plugin/src/main/resources/org/sonar/plugins/design/ui/libraries/LibrariesPage.gwt.xml index ebcb5b8971a..c37ecc6e9fe 100644 --- a/plugins/sonar-design-plugin/src/main/resources/org/sonar/plugins/design/ui/libraries/LibrariesPage.gwt.xml +++ b/plugins/sonar-design-plugin/src/main/resources/org/sonar/plugins/design/ui/libraries/LibrariesPage.gwt.xml @@ -5,5 +5,4 @@ - diff --git a/plugins/sonar-design-plugin/src/main/resources/org/sonar/plugins/design/ui/libraries/client/I18nConstants_fr.properties b/plugins/sonar-design-plugin/src/main/resources/org/sonar/plugins/design/ui/libraries/client/I18nConstants_fr.properties deleted file mode 100644 index 52e1a94be75..00000000000 --- a/plugins/sonar-design-plugin/src/main/resources/org/sonar/plugins/design/ui/libraries/client/I18nConstants_fr.properties +++ /dev/null @@ -1,6 +0,0 @@ -filter: Filtre: -displayTests: Afficher les librairies de test -expand: Développer -collapse: Réduire -noLibraries: Aucune librairie -usageLink: Utilisations \ No newline at end of file diff --git a/plugins/sonar-design-plugin/src/main/resources/org/sonar/plugins/design/ui/page/DesignPage.gwt.xml b/plugins/sonar-design-plugin/src/main/resources/org/sonar/plugins/design/ui/page/DesignPage.gwt.xml index 79a507eb137..f97ac1b5574 100644 --- a/plugins/sonar-design-plugin/src/main/resources/org/sonar/plugins/design/ui/page/DesignPage.gwt.xml +++ b/plugins/sonar-design-plugin/src/main/resources/org/sonar/plugins/design/ui/page/DesignPage.gwt.xml @@ -5,5 +5,4 @@ - diff --git a/plugins/sonar-design-plugin/src/main/resources/org/sonar/plugins/design/ui/page/client/I18nConstants_fr.properties b/plugins/sonar-design-plugin/src/main/resources/org/sonar/plugins/design/ui/page/client/I18nConstants_fr.properties deleted file mode 100644 index b2e15b28ca0..00000000000 --- a/plugins/sonar-design-plugin/src/main/resources/org/sonar/plugins/design/ui/page/client/I18nConstants_fr.properties +++ /dev/null @@ -1,8 +0,0 @@ -legendDependencies=Dépendance -legendCycles=Dépendance suspecte (cycle) -legendUses=- dépend de > -noData=Aucune information -noWindow=Nouvelle fenêtre -cellTooltip=Cliquez pour sélectionner, double-cliquez pour afficher plus de détails. -rowTooltip=Cliquez pour sélectionner, double-cliquez pour zoomer. -linkToHelp=Aide \ No newline at end of file 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 b5b2ae3815a..c2eb62f0964 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 @@ -765,16 +765,16 @@ severity.INFO=Info # #------------------------------------------------------------------------------ -domain.Size=Size -domain.Tests=Tests -domain.Complexity=Complexity -domain.Documentation=Documentation -domain.Rules=Rules -domain.General=General -domain.Duplication=Duplication -domain.Design=Design -domain.SCM=SCM -domain.Management=Management +metric_domain.Size=Size +metric_domain.Tests=Tests +metric_domain.Complexity=Complexity +metric_domain.Documentation=Documentation +metric_domain.Rules=Rules +metric_domain.General=General +metric_domain.Duplication=Duplication +metric_domain.Design=Design +metric_domain.SCM=SCM +metric_domain.Management=Management #------------------------------------------------------------------------------ @@ -1137,4 +1137,20 @@ metric.profile.name=Profile metric.profile.description=Selected quality profile metric.profile_version.name=Profile version -metric.profile_version.description=Selected quality profile version \ No newline at end of file +metric.profile_version.description=Selected quality profile version + + +#-------------------------------------------------------------------------------------------------------------------- +# +# MANUAL METRICS +# +#-------------------------------------------------------------------------------------------------------------------- +metric.burned_budget.name=Burned budget +metric.burned_budget.description=The budget already used in the project + +metric.business_value.name=Business value +metric.business_value.description=An indication on the value of the project for the business + +metric.team_size.name=Team size +metric.team_size.description=Size of the project team + diff --git a/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/gwt.properties b/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/gwt.properties index d36d51254e9..00c2e64404a 100644 --- a/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/gwt.properties +++ b/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/gwt.properties @@ -56,4 +56,13 @@ hotspot.designTitle=Highest # LCOM4 viewer -lcom4.metric=Lack of Cohesion of Methods \ No newline at end of file +lcom4.metric=Lack of Cohesion of Methods + + +# Unit tests viewer +unittest.duration=Duration +unittest.name=Unit test name +unittest.skipped=skipped +unittest.tests=Tests +unittest.duration=Duration +unittest.failures=Failures/Errors \ No newline at end of file diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/measures/Metric.java b/sonar-plugin-api/src/main/java/org/sonar/api/measures/Metric.java index dc27e6fe46e..4ecd5ab5eac 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/measures/Metric.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/measures/Metric.java @@ -230,7 +230,7 @@ public class Metric implements ServerExtension, BatchExtension { } private Metric(String key, String name, ValueType type, String description, Integer direction, String domain, Boolean qualitative, Double worstValue, Double bestValue, - Boolean optimizedBestValue, Boolean hidden, Formula formula) { + Boolean optimizedBestValue, Boolean hidden, Formula formula, boolean userManaged) { this.key = key; this.name = name; this.description = description; @@ -245,6 +245,7 @@ public class Metric implements ServerExtension, BatchExtension { this.bestValue = bestValue; this.hidden = hidden; this.formula = formula; + this.userManaged = userManaged; } /** @@ -601,6 +602,7 @@ public class Metric implements ServerExtension, BatchExtension { private Double bestValue; private boolean optimizedBestValue = false; private boolean hidden = false; + private boolean userManaged = false; /** * @param key the metric key, should be unique among all metrics @@ -692,12 +694,30 @@ public class Metric implements ServerExtension, BatchExtension { return this; } + /** + * Values of user-managed metrics can be set online in the "Manual measures" page. + * @since 2.10 + */ + public boolean isUserManaged() { + return userManaged; + } + + /** + * Values of user-managed metrics can be set online in the "Manual measures" page. + * + * @since 2.10 + */ + public Builder setUserManaged(boolean b) { + this.userManaged = b; + return this; + } + public Metric create() { if (ValueType.PERCENT.equals(this.type)) { this.bestValue = (direction == DIRECTION_BETTER ? 100.0 : 0.0); this.worstValue = (direction == DIRECTION_BETTER ? 0.0 : 100.0); } - return new Metric(key, name, type, description, direction, domain, qualitative, worstValue, bestValue, optimizedBestValue, hidden, formula); + return new Metric(key, name, type, description, direction, domain, qualitative, worstValue, bestValue, optimizedBestValue, hidden, formula, userManaged); } } } diff --git a/sonar-server/src/main/webapp/WEB-INF/app/models/metric.rb b/sonar-server/src/main/webapp/WEB-INF/app/models/metric.rb index 614d6b21824..024f82c56df 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/models/metric.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/models/metric.rb @@ -76,7 +76,7 @@ class Metric < ActiveRecord::Base return localeMap[locale] if not localeMap.nil? and localeMap.has_key?(locale) - i18n_key = 'domain.' + to_translate + i18n_key = 'metric_domain.' + to_translate result = Api::Utils.message(i18n_key, :default => to_translate) localeMap[locale] = result if localeMap result -- 2.39.5