From 8eb8e2a22167d5816462b6127e938a88ffc2338c Mon Sep 17 00:00:00 2001 From: Julien Lancelot Date: Thu, 19 Dec 2013 08:23:02 +0100 Subject: [PATCH] SONAR-4953 Add new measure filter as bubble chart widget, SONAR-3762 SONAR-3113 Update properties --- .../org/sonar/plugins/core/CorePlugin.java | 2 + .../MeasureFilterAsBubbleChartWidget.java | 48 +++++++++++++++++++ .../measures/MeasureFilterAsCloudWidget.java | 2 +- .../MeasureFilterAsHistogramWidget.java | 2 +- .../MeasureFilterAsPieChartWidget.java | 2 +- .../resources/org/sonar/l10n/core.properties | 17 +++++++ .../measure_filter_bubble_chart.html.erb | 16 +++++++ 7 files changed, 86 insertions(+), 3 deletions(-) create mode 100644 plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/measures/MeasureFilterAsBubbleChartWidget.java create mode 100644 plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/measures/measure_filter_bubble_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 cbae32fb865..f9d2f9ece9e 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 @@ -48,6 +48,7 @@ import org.sonar.plugins.core.timemachine.*; import org.sonar.plugins.core.web.TestsViewer; import org.sonar.plugins.core.widgets.*; import org.sonar.plugins.core.widgets.issues.*; +import org.sonar.plugins.core.widgets.measures.MeasureFilterAsBubbleChartWidget; import org.sonar.plugins.core.widgets.measures.MeasureFilterAsCloudWidget; import org.sonar.plugins.core.widgets.measures.MeasureFilterAsHistogramWidget; import org.sonar.plugins.core.widgets.measures.MeasureFilterAsPieChartWidget; @@ -253,6 +254,7 @@ public final class CorePlugin extends SonarPlugin { MeasureFilterAsPieChartWidget.class, MeasureFilterAsCloudWidget.class, MeasureFilterAsHistogramWidget.class, + MeasureFilterAsBubbleChartWidget.class, // dashboards ProjectDefaultDashboard.class, diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/measures/MeasureFilterAsBubbleChartWidget.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/measures/MeasureFilterAsBubbleChartWidget.java new file mode 100644 index 00000000000..afb43f5ede9 --- /dev/null +++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/measures/MeasureFilterAsBubbleChartWidget.java @@ -0,0 +1,48 @@ +/* + * 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.measures; + +import org.sonar.api.measures.CoreMetrics; +import org.sonar.api.web.*; +import org.sonar.plugins.core.widgets.CoreWidget; +import org.sonar.plugins.core.widgets.WidgetConstants; + +import static org.sonar.api.web.WidgetScope.GLOBAL; + +@WidgetCategory({"Filters", "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 = "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), + @WidgetProperty(key = "maxItems", type = WidgetPropertyType.INTEGER) +}) +public class MeasureFilterAsBubbleChartWidget extends CoreWidget { + + public MeasureFilterAsBubbleChartWidget() { + super("measure_filter_bubble_chart", "Measure Filter as Bubble Chart", "/org/sonar/plugins/core/widgets/measures/measure_filter_bubble_chart.html.erb"); + } + +} diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/measures/MeasureFilterAsCloudWidget.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/measures/MeasureFilterAsCloudWidget.java index e36e56884c1..79b4e31b5aa 100644 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/measures/MeasureFilterAsCloudWidget.java +++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/measures/MeasureFilterAsCloudWidget.java @@ -26,7 +26,7 @@ import org.sonar.plugins.core.widgets.WidgetConstants; import static org.sonar.api.web.WidgetScope.GLOBAL; -@WidgetCategory("Global") +@WidgetCategory({"Filters", "Global"}) @WidgetScope(GLOBAL) @WidgetProperties({ @WidgetProperty(key = "chartTitle", type = WidgetPropertyType.STRING), diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/measures/MeasureFilterAsHistogramWidget.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/measures/MeasureFilterAsHistogramWidget.java index d21645e630a..42ecce2a60e 100644 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/measures/MeasureFilterAsHistogramWidget.java +++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/measures/MeasureFilterAsHistogramWidget.java @@ -26,7 +26,7 @@ import org.sonar.plugins.core.widgets.WidgetConstants; import static org.sonar.api.web.WidgetScope.GLOBAL; -@WidgetCategory("Global") +@WidgetCategory({"Filters", "Global"}) @WidgetScope(GLOBAL) @WidgetProperties({ @WidgetProperty(key = "chartTitle", type = WidgetPropertyType.STRING), diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/measures/MeasureFilterAsPieChartWidget.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/measures/MeasureFilterAsPieChartWidget.java index a95222c09cc..e4e887620ed 100644 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/measures/MeasureFilterAsPieChartWidget.java +++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/measures/MeasureFilterAsPieChartWidget.java @@ -26,7 +26,7 @@ import org.sonar.plugins.core.widgets.WidgetConstants; import static org.sonar.api.web.WidgetScope.GLOBAL; -@WidgetCategory("Global") +@WidgetCategory({"Filters", "Global"}) @WidgetScope(GLOBAL) @WidgetProperties({ @WidgetProperty(key = "chartTitle", type = WidgetPropertyType.STRING), 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 d02cba5a6a2..cbaf92c0b4f 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 @@ -1122,6 +1122,8 @@ widget.measure_filter_cloud.property.chartHeight.name=Chart Height widget.measure_filter_cloud.property.filter.name=Filter widget.measure_filter_cloud.property.colorMetric.name=Color Metric widget.measure_filter_cloud.property.sizeMetric.name=Size Metric +widget.measure_filter_cloud.property.maxItems.name=Maximum number of components to show +widget.measure_filter_cloud.property.reverseColor.name=Reverse order on color widget.measure_filter_histogram.name=Measure Filter as Histogram widget.measure_filter_histogram.description=Displays the result of a pre-configured measure filter as a histogram. @@ -1129,8 +1131,23 @@ widget.measure_filter_histogram.property.chartTitle.name=Chart Title widget.measure_filter_histogram.property.chartHeight.name=Chart Height widget.measure_filter_histogram.property.filter.name=Filter widget.measure_filter_histogram.property.metric.name=Metric +widget.measure_filter_histogram.property.maxItems.name=Maximum number of components to show +widget.measure_filter_histogram.property.reverseOrder.name=Reverse sort order of filter +widget.measure_filter_histogram.property.displayWorstBestValues.name=Display scale with worst and best values when appropriate widget.measure_filter_histogram.max_items_reached=Max items are reached. +widget.measure_filter_bubble_chart.name=Measure Filter as Bubble Chart +widget.measure_filter_bubble_chart.description=Displays the result of a pre-configured measure filter as a bubble chart. +widget.measure_filter_bubble_chart.property.filter.name=Filter +widget.measure_filter_bubble_chart.property.chartTitle.name=Chart Title +widget.measure_filter_bubble_chart.property.chartHeight.name=Chart Height +widget.measure_filter_bubble_chart.property.xMetric.name=X Metric +widget.measure_filter_bubble_chart.property.yMetric.name=Y Metric +widget.measure_filter_bubble_chart.property.sizeMetric.name=Size Metric +widget.measure_filter_bubble_chart.property.xLogarithmic.name=X Logarithmic Scale +widget.measure_filter_bubble_chart.property.yLogarithmic.name=Y Logarithmic Scale +widget.measure_filter_bubble_chart.property.maxItems.name=Maximum number of components to show + 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. widget.time_machine.property.title.name=Title diff --git a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/measures/measure_filter_bubble_chart.html.erb b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/measures/measure_filter_bubble_chart.html.erb new file mode 100644 index 00000000000..e64827a88e1 --- /dev/null +++ b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/measures/measure_filter_bubble_chart.html.erb @@ -0,0 +1,16 @@ +<% + container_id = 'bubble-chart-widget' + widget.id.to_s + chartTitle = widget_properties["chartTitle"] + chartHeight = widget_properties["chartHeight"] + filterId = widget_properties["filter"].to_i + xMetric = widget_properties["xMetric"] + yMetric = widget_properties["yMetric"] + sizeMetric = widget_properties["sizeMetric"] + xLog = !!widget_properties["xLogarithmic"] + yLog = !!widget_properties["yLogarithmic"] + maxItems = widget_properties["maxItems"].to_i +%> + + + + -- 2.39.5