aboutsummaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorFabrice Bellingard <bellingard@gmail.com>2011-08-18 17:47:18 +0200
committerFabrice Bellingard <bellingard@gmail.com>2011-08-18 17:50:22 +0200
commit9001f7e14b547fc15fcbb1709466f7ce8de31a32 (patch)
tree7e2d4d97b290f805d002571ca1621c67dd748859 /plugins
parentb3aa83b929e85e3b057fa3a9cb66198b4aec3909 (diff)
downloadsonarqube-9001f7e14b547fc15fcbb1709466f7ce8de31a32.tar.gz
sonarqube-9001f7e14b547fc15fcbb1709466f7ce8de31a32.zip
SONAR-2074 New timeline widget: first basic version
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/TimelineWidget.java46
-rw-r--r--plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/timeline.html.erb41
-rw-r--r--plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/core.properties3
4 files changed, 91 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 ebc5c48a4c1..4a30f0daac8 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
@@ -214,6 +214,7 @@ public class CorePlugin extends SonarPlugin {
extensions.add(SizeWidget.class);
extensions.add(EventsWidget.class);
extensions.add(CustomMeasuresWidget.class);
+ extensions.add(TimelineWidget.class);
// chart
extensions.add(XradarChart.class);
diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/TimelineWidget.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/TimelineWidget.java
new file mode 100644
index 00000000000..c7c98054d88
--- /dev/null
+++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/TimelineWidget.java
@@ -0,0 +1,46 @@
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2011 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.web.*;
+
+@WidgetProperties(
+ {
+ @WidgetProperty(key = "metric1", type = WidgetPropertyType.METRIC),
+ @WidgetProperty(key = "metric2", type = WidgetPropertyType.METRIC),
+ @WidgetProperty(key = "metric3", type = WidgetPropertyType.METRIC),
+ @WidgetProperty(key = "displayEvents", type = WidgetPropertyType.BOOLEAN)
+ }
+)
+public class TimelineWidget extends AbstractRubyTemplate implements RubyRailsWidget {
+ public String getId() {
+ return "timeline";
+ }
+
+ public String getTitle() {
+ return "Timeline";
+ }
+
+ @Override
+ protected String getTemplatePath() {
+ return "/org/sonar/plugins/core/widgets/timeline.html.erb";
+ //return "/Users/fbellingard/Documents/Sonar/repos/sonar/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/timeline.html.erb";
+ }
+} \ No newline at end of file
diff --git a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/timeline.html.erb b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/timeline.html.erb
new file mode 100644
index 00000000000..d50e8ad9405
--- /dev/null
+++ b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/timeline.html.erb
@@ -0,0 +1,41 @@
+<%= javascript_include_tag 'protovis-sonar' %>
+
+<div id="timeline-chart"></div>
+
+<script type="text/javascript+protovis">
+
+<%
+ metric_data_map = {}
+ (1..3).each do |index|
+ metric=widget_properties["metric#{index}"]
+ if metric
+ metric_data_map[metric.id] = []
+ end
+ end
+
+ trends = TrendsChart.time_machine_measures(@resource, metric_data_map.keys, {}).sort { |t1, t2| t1["created_at"] <=> t2["created_at"] }
+ trends.each() do |trend_item|
+ metric_data_map[trend_item["metric_id"].to_i] << {:date => trend_item["created_at"], :value => trend_item["value"]}
+ end
+
+ js_data = "["
+ metric_data_map.keys.each() do |metric_id|
+ js_data += "["
+ metric_data_map[metric_id].each() do |metric_data|
+ m_date = Time.parse(metric_data[:date])
+ js_data += "{\"x\":new Date("
+ js_data += m_date.strftime("%Y,%m,%d")
+ js_data += "),\"y\":\""
+ js_data += metric_data[:value]
+ js_data += "\"},"
+ end
+ js_data += "],"
+ end
+ js_data += "]"
+
+%>
+ var data = <%= js_data -%>;
+
+ displayTrendChart('timeline-chart', data);
+
+</script> \ No newline at end of file
diff --git a/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/core.properties b/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/core.properties
index 9f98474b8e2..f61dd520ddd 100644
--- a/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/core.properties
+++ b/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/core.properties
@@ -508,6 +508,9 @@ widget.size.methods.suffix=\ methods
widget.size.accessors.suffix=\ accessors
widget.size.paragraphs.suffix=\ paragraphs
+widget.timeline.name=Timeline
+widget.timeline.description=Displays up to 3 metrics on a history chart.
+
widget.ckjm.name=Chidamber & Kemerer
widget.ckjm.description=Reports on LCOM4 and RFC average and distribution.
widget.ckjm.lcom4=LCOM4