diff options
author | David Gageot <david@gageot.net> | 2012-05-04 19:18:28 +0200 |
---|---|---|
committer | David Gageot <david@gageot.net> | 2012-05-04 19:18:28 +0200 |
commit | 68e826e238d0fc16b06675bedd2f3805c17bc117 (patch) | |
tree | c5927261014604e6fa6eb38371a19fd27621fc8e /plugins | |
parent | 1ff9677915d04fe5d9131eed029ee013824dcad2 (diff) | |
download | sonarqube-68e826e238d0fc16b06675bedd2f3805c17bc117.tar.gz sonarqube-68e826e238d0fc16b06675bedd2f3805c17bc117.zip |
SONAR-1927 Add global image widget and fix HelloWorld widget
Diffstat (limited to 'plugins')
8 files changed, 68 insertions, 6 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 085cd673624..a4746f9dc13 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 @@ -268,6 +268,7 @@ public final class CorePlugin extends SonarPlugin { extensions.add(ReviewsMetricsWidget.class); extensions.add(TreemapWidget.class); extensions.add(GlobalWidget.class); + extensions.add(ImageWidget.class); // dashboards extensions.add(DefaultDashboard.class); diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/dashboards/GlobalDashboard.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/dashboards/GlobalDashboard.java index e330209fc91..bdb044f8bc7 100644 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/dashboards/GlobalDashboard.java +++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/dashboards/GlobalDashboard.java @@ -46,6 +46,7 @@ public final class GlobalDashboard extends DashboardTemplate { } private void addWidget(Dashboard dashboard) { + dashboard.addWidget("image", 1); dashboard.addWidget("global", 1); } } diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/GlobalWidget.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/GlobalWidget.java index c165e62f88e..02fffc1047b 100644 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/GlobalWidget.java +++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/GlobalWidget.java @@ -19,16 +19,13 @@ */ package org.sonar.plugins.core.widgets; -import org.sonar.api.web.WidgetGlobal; - import org.sonar.api.web.AbstractRubyTemplate; import org.sonar.api.web.RubyRailsWidget; -import org.sonar.api.web.UserRole; import org.sonar.api.web.WidgetCategory; +import org.sonar.api.web.WidgetGlobal; @WidgetCategory("Beta") @WidgetGlobal -@UserRole(UserRole.USER) public class GlobalWidget extends AbstractRubyTemplate implements RubyRailsWidget { public String getId() { diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/ImageWidget.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/ImageWidget.java new file mode 100644 index 00000000000..f8e7f6afb9a --- /dev/null +++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/ImageWidget.java @@ -0,0 +1,54 @@ +/* + * 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.web.AbstractRubyTemplate; +import org.sonar.api.web.RubyRailsWidget; +import org.sonar.api.web.WidgetCategory; +import org.sonar.api.web.WidgetGlobal; +import org.sonar.api.web.WidgetProperties; +import org.sonar.api.web.WidgetProperty; +import org.sonar.api.web.WidgetPropertyType; + +@WidgetCategory("Beta") +@WidgetGlobal +@WidgetProperties( +{ + @WidgetProperty(key = "imageUrl", type = WidgetPropertyType.STRING, defaultValue = "http://www.sonarsource.org/wp-content/themes/sonarsource.org/images/sonar.png"), + @WidgetProperty(key = "alt", type = WidgetPropertyType.STRING, defaultValue = "SonarSource"), + @WidgetProperty(key = "link", type = WidgetPropertyType.STRING, defaultValue = "http://www.sonarsource.org"), + @WidgetProperty(key = "width", type = WidgetPropertyType.INTEGER, defaultValue = "100"), + @WidgetProperty(key = "height", type = WidgetPropertyType.INTEGER, defaultValue = "54") +}) +public class ImageWidget extends AbstractRubyTemplate implements RubyRailsWidget { + + public String getId() { + return "image"; + } + + public String getTitle() { + return "Image"; + } + + @Override + protected String getTemplatePath() { + return "/org/sonar/plugins/core/widgets/image.html.erb"; + } +} diff --git a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/global.html.erb b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/global.html.erb index 756dbfb1cf0..34fa97df868 100644 --- a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/global.html.erb +++ b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/global.html.erb @@ -1 +1 @@ -<div>WIDGET GLOBAL !!!</div>
\ No newline at end of file +<div>Hello World</div>
\ No newline at end of file diff --git a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/image.html.erb b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/image.html.erb new file mode 100644 index 00000000000..c0ab4d71810 --- /dev/null +++ b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/image.html.erb @@ -0,0 +1,3 @@ +<a href="<%= widget_properties['link'] %>" title="<%= widget_properties['alt'] %>"> + <img src="<%= widget_properties['imageUrl'] %>" alt="<%= widget_properties['alt'] %>" width="<%= widget_properties['width'] %>" height="<%= widget_properties['height'] %>" /> +</a> diff --git a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/dashboards/GlobalDashboardTest.java b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/dashboards/GlobalDashboardTest.java index d94f4cbd9a7..e16c1983aec 100644 --- a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/dashboards/GlobalDashboardTest.java +++ b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/dashboards/GlobalDashboardTest.java @@ -34,6 +34,6 @@ public class GlobalDashboardTest { assertThat(template.getName()).isEqualTo("Global"); assertThat(dashboard.getLayout()).isEqualTo(DashboardLayout.ONE_COLUMN); - assertThat(dashboard.getWidgets()).onProperty("id").containsOnly("global"); + assertThat(dashboard.getWidgets()).onProperty("id").containsOnly("global", "image"); } } 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 d7472712dd0..e288c6ff182 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 @@ -756,6 +756,12 @@ widget.reviews_metrics.added_unreviewed_violations=Added: widget.treemap.name=Treemap of components widget.treemap.description=Displays a treemap of all direct components of the selected resource +widget.global.name=Hello World +widget.global.description=Shows Hello Word + +widget.image.name=Image +widget.image.description=Shows an image with a link + #------------------------------------------------------------------------------ # # COMPONENTS |