From bb3b75ca4444e69509c1efec25e6b172398a642c Mon Sep 17 00:00:00 2001 From: Julien Lancelot Date: Tue, 8 Apr 2014 13:50:29 +0200 Subject: [PATCH] SONAR-3113 Add Project File Word Cloud widget skeleton --- .../org/sonar/plugins/core/CorePlugin.java | 1 + .../core/widgets/ProjectFileCloudWidget.java | 41 +++++++++++++++++++ .../measures/MeasureFilterAsCloudWidget.java | 5 +-- .../resources/org/sonar/l10n/core.properties | 11 ++++- .../core/widgets/project_file_cloud.html.erb | 20 +++++++++ 5 files changed, 74 insertions(+), 4 deletions(-) create mode 100644 plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/ProjectFileCloudWidget.java create mode 100644 plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/project_file_cloud.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 d7cf88cc2a2..a87d01690a6 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 @@ -244,6 +244,7 @@ public final class CorePlugin extends SonarPlugin { MeasureFilterAsCloudWidget.class, MeasureFilterAsHistogramWidget.class, MeasureFilterAsBubbleChartWidget.class, + ProjectFileCloudWidget.class, // dashboards ProjectDefaultDashboard.class, diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/ProjectFileCloudWidget.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/ProjectFileCloudWidget.java new file mode 100644 index 00000000000..3af7c9b380a --- /dev/null +++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/ProjectFileCloudWidget.java @@ -0,0 +1,41 @@ +/* + * 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; + +import org.sonar.api.measures.CoreMetrics; +import org.sonar.api.web.WidgetProperties; +import org.sonar.api.web.WidgetProperty; +import org.sonar.api.web.WidgetPropertyType; + +@WidgetProperties({ + @WidgetProperty(key = "chartTitle", type = WidgetPropertyType.STRING), + @WidgetProperty(key = "filter", type = WidgetPropertyType.FILTER, optional = false), + @WidgetProperty(key = "colorMetric", type = WidgetPropertyType.METRIC, defaultValue = CoreMetrics.COVERAGE_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 = "100"), + @WidgetProperty(key = "reverseColor", type = WidgetPropertyType.BOOLEAN, defaultValue = "false") + +}) +public class ProjectFileCloudWidget extends CoreWidget { + public ProjectFileCloudWidget() { + super("project_file_cloud", "Project File Word Cloud", "/org/sonar/plugins/core/widgets/project_file_cloud.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 8a6d8d861bf..daf8d2f6f5c 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 @@ -30,11 +30,10 @@ import static org.sonar.api.web.WidgetScope.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 = "colorMetric", type = WidgetPropertyType.METRIC, defaultValue = CoreMetrics.COVERAGE_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 = "maxItems", type = WidgetPropertyType.INTEGER, defaultValue = "100"), @WidgetProperty(key = "reverseColor", type = WidgetPropertyType.BOOLEAN, defaultValue = "false") }) public class MeasureFilterAsCloudWidget extends CoreWidget { 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 1dea1f37b25..96db9a459fc 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,7 +1122,6 @@ widget.measure_filter_pie_chart.property.maxItems.desc=Maximum number of compone 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 @@ -1157,6 +1156,16 @@ widget.measure_filter_bubble_chart.property.yLogarithmic.name=Y Logarithmic Scal widget.measure_filter_bubble_chart.property.maxItems.name=Max Components widget.measure_filter_bubble_chart.property.maxItems.desc=Maximum number of components to display +widget.project_file_cloud.name=Project File Word Cloud +widget.project_file_cloud.description=Display a component's source files in a word cloud. Both axes are configurable. +widget.project_file_cloud.property.chartTitle.name=Chart Title +widget.project_file_cloud.property.filter.name=Filter +widget.project_file_cloud.property.colorMetric.name=Color Metric +widget.project_file_cloud.property.sizeMetric.name=Size Metric +widget.project_file_cloud.property.maxItems.name=Max components +widget.project_file_cloud.property.maxItems.desc=Maximum number of components to show +widget.project_file_cloud.property.reverseColor.name=Reverse order on color + 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/project_file_cloud.html.erb b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/project_file_cloud.html.erb new file mode 100644 index 00000000000..01379bfd9ae --- /dev/null +++ b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/project_file_cloud.html.erb @@ -0,0 +1,20 @@ +<% + containerId = 'project-file-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'} +%> + +
+ + + + <% if chartTitle %> +

<%= h(chartTitle) -%>

+ <% end %> + +
-- 2.39.5