summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJulien Lancelot <julien.lancelot@sonarsource.com>2013-12-11 10:09:05 +0100
committerJulien Lancelot <julien.lancelot@sonarsource.com>2013-12-11 10:09:05 +0100
commitc25f03e9ee8d48633e1fff84a8390a1c5cec4860 (patch)
tree465403c92237c90aed3a98b2c9fe6f2fb06aae77
parent69195c83e5a88848d75a5cb74f5115ec95d4c272 (diff)
downloadsonarqube-c25f03e9ee8d48633e1fff84a8390a1c5cec4860.tar.gz
sonarqube-c25f03e9ee8d48633e1fff84a8390a1c5cec4860.zip
SONAR-4952 Create skeleton for PieChartWidget
-rw-r--r--plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/CorePlugin.java1
-rw-r--r--plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/BubbleChartWidget.java15
-rw-r--r--plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/PieChartWidget.java44
-rw-r--r--plugins/sonar-core-plugin/src/main/resources/org/sonar/l10n/core.properties12
-rw-r--r--plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/pie_chart.html.erb11
5 files changed, 75 insertions, 8 deletions
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 @@
+<script>
+ var filterId = <%= widget_properties['filter'].to_i %>;
+ var chartTitle = <%= widget_properties['chartTitle'].to_s %>;
+ var chartHeight = <%= widget_properties['chartHeight'].to_s %>;
+ var mainMetric = <%= widget_properties['mainMetric'].to_s %>;
+ var extraMetric1 = <%= widget_properties['extraMetric1'].to_s %>;
+ var extraMetric2 = <%= widget_properties['extraMetric2'].to_s %>;
+ var extraMetric3 = <%= widget_properties['extraMetric3'].to_s %>;
+</script>
+
+