From c25f03e9ee8d48633e1fff84a8390a1c5cec4860 Mon Sep 17 00:00:00 2001 From: Julien Lancelot Date: Wed, 11 Dec 2013 10:09:05 +0100 Subject: [PATCH] SONAR-4952 Create skeleton for PieChartWidget --- .../org/sonar/plugins/core/CorePlugin.java | 1 + .../core/widgets/BubbleChartWidget.java | 15 ++++--- .../plugins/core/widgets/PieChartWidget.java | 44 +++++++++++++++++++ .../resources/org/sonar/l10n/core.properties | 12 ++++- .../plugins/core/widgets/pie_chart.html.erb | 11 +++++ 5 files changed, 75 insertions(+), 8 deletions(-) create mode 100644 plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/PieChartWidget.java create mode 100644 plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/pie_chart.html.erb diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/CorePlugin.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/CorePlugin.java index 9d69cb3247a..02f48fa372f 100644 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/CorePlugin.java +++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/CorePlugin.java @@ -238,6 +238,7 @@ public final class CorePlugin extends SonarPlugin { DocumentationCommentsWidget.class, DuplicationsWidget.class, TechnicalDebtPyramidWidget.class, + PieChartWidget.class, // dashboards ProjectDefaultDashboard.class, diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/BubbleChartWidget.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/BubbleChartWidget.java index e842eeef12c..02c6b0710e4 100644 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/BubbleChartWidget.java +++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/BubbleChartWidget.java @@ -19,6 +19,7 @@ */ package org.sonar.plugins.core.widgets; +import org.sonar.api.measures.CoreMetrics; import org.sonar.api.web.WidgetCategory; import org.sonar.api.web.WidgetProperties; import org.sonar.api.web.WidgetProperty; @@ -26,13 +27,13 @@ import org.sonar.api.web.WidgetPropertyType; @WidgetCategory("Global") @WidgetProperties({ - @WidgetProperty(key = "chartTitle", type = WidgetPropertyType.STRING), - @WidgetProperty(key = "xMetric", type = WidgetPropertyType.METRIC, defaultValue = "ncloc", options = {WidgetConstants.FILTER_OUT_NEW_METRICS}), - @WidgetProperty(key = "yMetric", type = WidgetPropertyType.METRIC, defaultValue = "violations", options = {WidgetConstants.FILTER_OUT_NEW_METRICS}), - @WidgetProperty(key = "sizeMetric", type = WidgetPropertyType.METRIC, defaultValue = "sqale_index", options = {WidgetConstants.FILTER_OUT_NEW_METRICS}), - @WidgetProperty(key = "xLogarithmic", type = WidgetPropertyType.BOOLEAN), - @WidgetProperty(key = "yLogarithmic", type = WidgetPropertyType.BOOLEAN), - @WidgetProperty(key = "chartHeight", type = WidgetPropertyType.INTEGER, defaultValue = "300") + @WidgetProperty(key = "chartTitle", type = WidgetPropertyType.STRING), + @WidgetProperty(key = "chartHeight", type = WidgetPropertyType.INTEGER, defaultValue = "300"), + @WidgetProperty(key = "xMetric", type = WidgetPropertyType.METRIC, defaultValue = CoreMetrics.NCLOC_KEY, options = {WidgetConstants.FILTER_OUT_NEW_METRICS}), + @WidgetProperty(key = "yMetric", type = WidgetPropertyType.METRIC, defaultValue = CoreMetrics.VIOLATIONS_KEY, options = {WidgetConstants.FILTER_OUT_NEW_METRICS}), + @WidgetProperty(key = "sizeMetric", type = WidgetPropertyType.METRIC, defaultValue = CoreMetrics.TECHNICAL_DEBT_KEY, options = {WidgetConstants.FILTER_OUT_NEW_METRICS}), + @WidgetProperty(key = "xLogarithmic", type = WidgetPropertyType.BOOLEAN), + @WidgetProperty(key = "yLogarithmic", type = WidgetPropertyType.BOOLEAN) }) public class BubbleChartWidget extends CoreWidget { public BubbleChartWidget() { diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/PieChartWidget.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/PieChartWidget.java new file mode 100644 index 00000000000..4c5943d6f24 --- /dev/null +++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/PieChartWidget.java @@ -0,0 +1,44 @@ +/* + * SonarQube, open source software quality management tool. + * Copyright (C) 2008-2013 SonarSource + * mailto:contact AT sonarsource DOT com + * + * SonarQube is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * SonarQube is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.plugins.core.widgets; + +import org.sonar.api.measures.CoreMetrics; +import org.sonar.api.web.*; + +import static org.sonar.api.web.WidgetScope.GLOBAL; + +@WidgetCategory("Global") +@WidgetScope(GLOBAL) +@WidgetProperties({ + @WidgetProperty(key = "chartTitle", type = WidgetPropertyType.STRING), + @WidgetProperty(key = "chartHeight", type = WidgetPropertyType.INTEGER, defaultValue = "300"), + @WidgetProperty(key = "filter", type = WidgetPropertyType.FILTER, optional = false), + @WidgetProperty(key = "mainMetric", type = WidgetPropertyType.METRIC, defaultValue = CoreMetrics.TECHNICAL_DEBT_KEY, options = {WidgetConstants.FILTER_OUT_NEW_METRICS}), + @WidgetProperty(key = "extraMetric1", type = WidgetPropertyType.METRIC, defaultValue = CoreMetrics.NCLOC_KEY, options = {WidgetConstants.FILTER_OUT_NEW_METRICS}), + @WidgetProperty(key = "extraMetric2", type = WidgetPropertyType.METRIC, defaultValue = CoreMetrics.COMPLEXITY_KEY, options = {WidgetConstants.FILTER_OUT_NEW_METRICS}), + @WidgetProperty(key = "extraMetric3", type = WidgetPropertyType.METRIC, defaultValue = CoreMetrics.COVERAGE_KEY, options = {WidgetConstants.FILTER_OUT_NEW_METRICS}) +}) +public class PieChartWidget extends CoreWidget { + + public PieChartWidget() { + super("pie_chart", "Pie Chart", "/org/sonar/plugins/core/widgets/pie_chart.html.erb"); + } + +} diff --git a/plugins/sonar-core-plugin/src/main/resources/org/sonar/l10n/core.properties b/plugins/sonar-core-plugin/src/main/resources/org/sonar/l10n/core.properties index fa8a194bbd4..34acec19296 100644 --- a/plugins/sonar-core-plugin/src/main/resources/org/sonar/l10n/core.properties +++ b/plugins/sonar-core-plugin/src/main/resources/org/sonar/l10n/core.properties @@ -1098,12 +1098,22 @@ widget.timeline.property.chartHeight.name=Chart height widget.bubble_chart.name=Bubble Chart widget.bubble_chart.description=Display a component's source files in a Bubble chart. Both axes and bubble size are configurable. widget.bubble_chart.property.chartTitle.name=Chart Title +widget.bubble_chart.property.chartHeight.name=Chart Height widget.bubble_chart.property.xMetric.name=X Metric widget.bubble_chart.property.yMetric.name=Y Metric widget.bubble_chart.property.sizeMetric.name=Size Metric widget.bubble_chart.property.xLogarithmic.name=X Logarithmic Scale widget.bubble_chart.property.yLogarithmic.name=Y Logarithmic Scale -widget.bubble_chart.property.chartHeight.name=Chart Height + +widget.pie_chart.name=Measure Filter as Pie Chart +widget.pie_chart.description=Displays the result of a pre-configured measure filter as a pie chart. +widget.pie_chart.property.chartTitle.name=Chart Title +widget.pie_chart.property.chartHeight.name=Chart Height +widget.pie_chart.property.filter.name=Filter +widget.pie_chart.property.mainMetric.name=Main Metric +widget.pie_chart.property.extraMetric1.name=Extra Metric 1 +widget.pie_chart.property.extraMetric2.name=Extra Metric 2 +widget.pie_chart.property.extraMetric3.name=Extra Metric 3 widget.time_machine.name=History Table widget.time_machine.description=Displays up to 10 metrics in a table, showing their value for a specified number of past snapshots. diff --git a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/pie_chart.html.erb b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/pie_chart.html.erb new file mode 100644 index 00000000000..b83b65e351f --- /dev/null +++ b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/pie_chart.html.erb @@ -0,0 +1,11 @@ + + + -- 2.39.5