summaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@gmail.com>2012-02-06 16:46:54 +0100
committerSimon Brandhof <simon.brandhof@gmail.com>2012-02-06 19:47:12 +0100
commitb9a7fa1711b0549417c48fc3100a01726f26b378 (patch)
tree0286fbb97db411f9b9bb6090314ed1dbcc13f30c /plugins
parent6a174837516ec2457f881e30c2cd4ee3468455cb (diff)
downloadsonarqube-b9a7fa1711b0549417c48fc3100a01726f26b378.tar.gz
sonarqube-b9a7fa1711b0549417c48fc3100a01726f26b378.zip
SONAR-2069 New treemap widget
Diffstat (limited to 'plugins')
-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/TreemapWidget.java44
-rw-r--r--plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/treemap.html.erb7
3 files changed, 52 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 48c94a861e8..1bbb8c29ecb 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
@@ -267,6 +267,7 @@ public class CorePlugin extends SonarPlugin {
extensions.add(UnplannedReviewsWidget.class);
extensions.add(ActionPlansWidget.class);
extensions.add(ReviewsMetricsWidget.class);
+ extensions.add(TreemapWidget.class);
// dashboards
extensions.add(DefaultDashboard.class);
diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/TreemapWidget.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/TreemapWidget.java
new file mode 100644
index 00000000000..733e0a07780
--- /dev/null
+++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/TreemapWidget.java
@@ -0,0 +1,44 @@
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2012 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar 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.
+ *
+ * Sonar 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 Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+ */
+package org.sonar.plugins.core.widgets;
+
+import org.sonar.api.measures.CoreMetrics;
+import org.sonar.api.web.*;
+
+@WidgetCategory("Reporting")
+@WidgetProperties({
+ @WidgetProperty(key = "heightInPercents", type= WidgetPropertyType.INTEGER, defaultValue = "100", description = "Height, in percents of width"),
+ @WidgetProperty(key = "sizeMetric", type= WidgetPropertyType.METRIC, defaultValue = CoreMetrics.NCLOC_KEY, description = "Default metric for size"),
+ @WidgetProperty(key = "colorMetric", type= WidgetPropertyType.METRIC, defaultValue = CoreMetrics.VIOLATIONS_DENSITY_KEY, description = "Default metric for color")
+})
+public class TreemapWidget extends AbstractRubyTemplate implements RubyRailsWidget {
+ public String getId() {
+ return "tm"; // avoid conflict with CSS style "treemap"
+ }
+
+ public String getTitle() {
+ return "Treemap of components";
+ }
+
+ @Override
+ protected String getTemplatePath() {
+ return "/Users/sbrandhof/projects/github/sonar/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/treemap.html.erb";
+ }
+} \ No newline at end of file
diff --git a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/treemap.html.erb b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/treemap.html.erb
new file mode 100644
index 00000000000..93b2527aebf
--- /dev/null
+++ b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/treemap.html.erb
@@ -0,0 +1,7 @@
+<%= render :partial => 'treemap/treemap_container', :locals => {
+ :treemap_id => widget.id,
+ :size_metric => widget_properties['sizeMetric'],
+ :color_metric => widget_properties['colorMetric'],
+ :heightInPercents => widget_properties['heightInPercents'],
+ :resource_id => @resource.id
+ } -%> \ No newline at end of file