diff options
author | Julien Lancelot <julien.lancelot@sonarsource.com> | 2014-04-04 14:39:00 +0200 |
---|---|---|
committer | Julien Lancelot <julien.lancelot@sonarsource.com> | 2014-04-04 14:39:00 +0200 |
commit | 06951c5a26e71e20d26d1457e0dfe800f7a9813c (patch) | |
tree | 2f4217323847c19ecb5009170e93a1def5024f9f /plugins | |
parent | 41c86d81b9c4ae4f045da26a631e38c201521077 (diff) | |
download | sonarqube-06951c5a26e71e20d26d1457e0dfe800f7a9813c.tar.gz sonarqube-06951c5a26e71e20d26d1457e0dfe800f7a9813c.zip |
SONAR-3113 Restore the Measure filter as cloud widget
Diffstat (limited to 'plugins')
4 files changed, 117 insertions, 0 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 373f1cdf932..d7cf88cc2a2 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 @@ -241,6 +241,7 @@ public final class CorePlugin extends SonarPlugin { DuplicationsWidget.class, TechnicalDebtPyramidWidget.class, MeasureFilterAsPieChartWidget.class, + MeasureFilterAsCloudWidget.class, MeasureFilterAsHistogramWidget.class, MeasureFilterAsBubbleChartWidget.class, 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 new file mode 100644 index 00000000000..8a6d8d861bf --- /dev/null +++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/measures/MeasureFilterAsCloudWidget.java @@ -0,0 +1,46 @@ +/* + * SonarQube, open source software quality management tool. + * Copyright (C) 2008-2014 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 = "colorMetric", type = WidgetPropertyType.METRIC, defaultValue = CoreMetrics.TECHNICAL_DEBT_KEY, options = "type:PERCENT"), + @WidgetProperty(key = "sizeMetric", type = WidgetPropertyType.METRIC, defaultValue = CoreMetrics.COMPLEXITY_KEY, options = {WidgetConstants.FILTER_OUT_NEW_METRICS}), + @WidgetProperty(key = "maxItems", type = WidgetPropertyType.INTEGER, defaultValue = "50"), + @WidgetProperty(key = "reverseColor", type = WidgetPropertyType.BOOLEAN, defaultValue = "false") +}) +public class MeasureFilterAsCloudWidget extends CoreWidget { + + public MeasureFilterAsCloudWidget() { + super("measure_filter_cloud", "Measure Filter as Cloud", "/org/sonar/plugins/core/widgets/measures/measure_filter_cloud.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 f1668a6a796..1dea1f37b25 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 @@ -1119,6 +1119,17 @@ widget.measure_filter_pie_chart.property.extraMetric2.name=Extra Metric 2 widget.measure_filter_pie_chart.property.maxItems.name=Max Components widget.measure_filter_pie_chart.property.maxItems.desc=Maximum number of components to display +widget.measure_filter_cloud.name=Measure Filter as Word Cloud +widget.measure_filter_cloud.description=Displays the result of a pre-configured measure filter as a word cloud. +widget.measure_filter_cloud.property.chartTitle.name=Chart Title +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=Max components +widget.measure_filter_cloud.property.maxItems.desc=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. widget.measure_filter_histogram.property.chartTitle.name=Chart Title diff --git a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/measures/measure_filter_cloud.html.erb b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/measures/measure_filter_cloud.html.erb new file mode 100644 index 00000000000..48988ee7a4c --- /dev/null +++ b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/measures/measure_filter_cloud.html.erb @@ -0,0 +1,59 @@ +<% + containerId = 'pie-chart-widget' + widget.id.to_s + chartTitle = widget_properties['chartTitle'] + filterId = widget_properties['filter'].to_i + maxItems = widget_properties['maxItems'].to_i + reverseColor = widget_properties['reverseColor'] + + filter = MeasureFilter.find_by_id(filterId.to_i) + @widget_title = link_to h(filter.name), {:controller => 'measures', :action => 'filter', :id => filter.id, :display => 'list'} +%> + +<div class="histogram-widget" id="<%= containerId %>"> + <!--[if lte IE 8 ]> <h3><%= message('widget.unsupported_browser_warning') -%></h3> <![endif]--> + + <!--[if (gte IE 9)|!(IE)]><!--> + <% if chartTitle %> + <h3><%= h(chartTitle) -%></h3> + <% end %> + <!--<![endif]--> +</div> + +<!--[if (gte IE 9)|!(IE)]><!--> +<script> + (function () { + var metrics = [ + '<%= widget_properties['colorMetric'].name -%>', + '<%= widget_properties['sizeMetric'].name -%>' + ], + query = [ + 'filter=<%= filterId -%>', + 'metrics=' + metrics.join(','), + 'fields=name,qualifier', + 'pageSize=<%= maxItems -%>', + 'page=1', + 'sort=metric:' + metrics[0], + 'asc=false' + ].join('&'), + widget = new SonarWidgets.Widget(); + + widget + .type('WordCloud') + .source(baseUrl + '/measures/search_filter?' + query) + .metricsPriority(metrics) + .options({ + baseUrl: baseUrl + '/dashboard/index/', + noData: '<%= message('no_data') -%>' + }) + .render('#<%= containerId -%>'); + + autoResize(500, function() { + widget.update('#<%= containerId -%>'); + }); + })(); +</script> +<!--<![endif]--> + + + + |