aboutsummaryrefslogtreecommitdiffstats
path: root/archetypes
diff options
context:
space:
mode:
authorsimonbrandhof <simon.brandhof@gmail.com>2010-11-01 14:20:55 +0000
committersimonbrandhof <simon.brandhof@gmail.com>2010-11-01 14:20:55 +0000
commit61a84575510a2cdde57ce7b2139c52458903df52 (patch)
tree6d7f34da22a1c084b2ef3c9b4c8339ddb66d09e3 /archetypes
parente22ca92f752d628a2371d7a95a50e71dfabcfc69 (diff)
downloadsonarqube-61a84575510a2cdde57ce7b2139c52458903df52.tar.gz
sonarqube-61a84575510a2cdde57ce7b2139c52458903df52.zip
SONAR-1643 add example of widget properties in plugin archetype + use enumeration for the type of widget property
Diffstat (limited to 'archetypes')
-rw-r--r--archetypes/sonar-basic-plugin/README.txt3
-rw-r--r--archetypes/sonar-basic-plugin/project/src/main/java/org/sonar/plugins/sample/SampleDashboardWidget.java23
-rw-r--r--archetypes/sonar-basic-plugin/project/src/main/resources/sample_dashboard_widget.html.erb19
-rw-r--r--archetypes/sonar-basic-plugin/src/main/resources/archetype-resources/src/main/java/SampleDashboardWidget.java24
-rw-r--r--archetypes/sonar-basic-plugin/src/main/resources/archetype-resources/src/main/resources/sample_dashboard_widget.html.erb19
5 files changed, 77 insertions, 11 deletions
diff --git a/archetypes/sonar-basic-plugin/README.txt b/archetypes/sonar-basic-plugin/README.txt
index 6f0d0d9c557..a4dca475c74 100644
--- a/archetypes/sonar-basic-plugin/README.txt
+++ b/archetypes/sonar-basic-plugin/README.txt
@@ -3,3 +3,6 @@ To update the archetype project :
1. update sources of the initial project (/project directory)
2. /project$ mvn install -DsonarTargetVersion=<version>
3. copy the content of /project/target/generated-sources/archetype/src/main/resources to src/main/resources. Be careful with .svn files !
+
+To execute the archetype :
+mvn archetype:generate -B -DarchetypeGroupId=org.codehaus.sonar.archetypes -DarchetypeArtifactId=sonar-basic-plugin-archetype -DarchetypeVersion=<SONAR VERSION> -DgroupId=com.mycompany.sonar -DartifactId=sonar-basic-sample-plugin -Dversion=0.1-SNAPSHOT \ No newline at end of file
diff --git a/archetypes/sonar-basic-plugin/project/src/main/java/org/sonar/plugins/sample/SampleDashboardWidget.java b/archetypes/sonar-basic-plugin/project/src/main/java/org/sonar/plugins/sample/SampleDashboardWidget.java
index 1ce3680f5b6..0bc7ba1cc55 100644
--- a/archetypes/sonar-basic-plugin/project/src/main/java/org/sonar/plugins/sample/SampleDashboardWidget.java
+++ b/archetypes/sonar-basic-plugin/project/src/main/java/org/sonar/plugins/sample/SampleDashboardWidget.java
@@ -1,12 +1,27 @@
package org.sonar.plugins.sample;
-import org.sonar.api.web.AbstractRubyTemplate;
-import org.sonar.api.web.NavigationSection;
-import org.sonar.api.web.RubyRailsWidget;
-import org.sonar.api.web.UserRole;
+import org.sonar.api.web.*;
@NavigationSection(NavigationSection.RESOURCE)
@UserRole(UserRole.USER)
+@Description("Show how to use Ruby Widget API")
+@WidgetProperties({
+ @WidgetProperty(key="param1",
+ description="This is a mandatory parameter",
+ optional=false
+ ),
+ @WidgetProperty(key="max",
+ description="max threshold",
+ type=WidgetPropertyType.INTEGER,
+ defaultValue="80"
+ ),
+ @WidgetProperty(key="param2",
+ description="This is an optional parameter"
+ ),
+ @WidgetProperty(key="floatprop",
+ description="test description"
+ )
+})
public class SampleDashboardWidget extends AbstractRubyTemplate implements RubyRailsWidget {
public String getId() {
diff --git a/archetypes/sonar-basic-plugin/project/src/main/resources/sample_dashboard_widget.html.erb b/archetypes/sonar-basic-plugin/project/src/main/resources/sample_dashboard_widget.html.erb
index 34b80a937e7..d52038ffe25 100644
--- a/archetypes/sonar-basic-plugin/project/src/main/resources/sample_dashboard_widget.html.erb
+++ b/archetypes/sonar-basic-plugin/project/src/main/resources/sample_dashboard_widget.html.erb
@@ -20,4 +20,21 @@
Sample of Jfree Eastwood chart : <br/>
<%= gchart('cht=bhs&chco=FF0000,00FF00,0000FF&chs=200x125&chd=s:FOE,THE,Bar&chxt=x,y&chxl=1:|Dec|Nov|Oct|0:||20K||60K||100K|') -%>
</p>
-</div> \ No newline at end of file
+ <p>
+ Widget properties:
+ <table>
+ <tr>
+ <td>max:</td>
+ <td><%= widget_properties['max'] -%></td>
+ </tr>
+ <tr>
+ <td>param1:</td>
+ <td><%= widget_properties['param1'] -%></td>
+ </tr>
+ <tr>
+ <td>param2:</td>
+ <td><%= widget_properties['param2'] -%></td>
+ </tr>
+ </table>
+ </p>
+</div>
diff --git a/archetypes/sonar-basic-plugin/src/main/resources/archetype-resources/src/main/java/SampleDashboardWidget.java b/archetypes/sonar-basic-plugin/src/main/resources/archetype-resources/src/main/java/SampleDashboardWidget.java
index e545be14157..05789347804 100644
--- a/archetypes/sonar-basic-plugin/src/main/resources/archetype-resources/src/main/java/SampleDashboardWidget.java
+++ b/archetypes/sonar-basic-plugin/src/main/resources/archetype-resources/src/main/java/SampleDashboardWidget.java
@@ -3,13 +3,28 @@
#set( $symbol_escape = '\' )
package ${package};
-import org.sonar.api.web.AbstractRubyTemplate;
-import org.sonar.api.web.NavigationSection;
-import org.sonar.api.web.RubyRailsWidget;
-import org.sonar.api.web.UserRole;
+import org.sonar.api.web.*;
@NavigationSection(NavigationSection.RESOURCE)
@UserRole(UserRole.USER)
+@Description("Show how to use Ruby Widget API")
+@WidgetProperties({
+ @WidgetProperty(key="param1",
+ description="This is a mandatory parameter",
+ optional=false
+ ),
+ @WidgetProperty(key="max",
+ description="max threshold",
+ type=WidgetPropertyType.INTEGER,
+ defaultValue="80"
+ ),
+ @WidgetProperty(key="param2",
+ description="This is an optional parameter"
+ ),
+ @WidgetProperty(key="floatprop",
+ description="test description"
+ )
+})
public class SampleDashboardWidget extends AbstractRubyTemplate implements RubyRailsWidget {
public String getId() {
@@ -17,7 +32,6 @@ public class SampleDashboardWidget extends AbstractRubyTemplate implements RubyR
}
public String getTitle() {
- // not used for the moment by widgets.
return "Sample";
}
diff --git a/archetypes/sonar-basic-plugin/src/main/resources/archetype-resources/src/main/resources/sample_dashboard_widget.html.erb b/archetypes/sonar-basic-plugin/src/main/resources/archetype-resources/src/main/resources/sample_dashboard_widget.html.erb
index 34b80a937e7..d52038ffe25 100644
--- a/archetypes/sonar-basic-plugin/src/main/resources/archetype-resources/src/main/resources/sample_dashboard_widget.html.erb
+++ b/archetypes/sonar-basic-plugin/src/main/resources/archetype-resources/src/main/resources/sample_dashboard_widget.html.erb
@@ -20,4 +20,21 @@
Sample of Jfree Eastwood chart : <br/>
<%= gchart('cht=bhs&chco=FF0000,00FF00,0000FF&chs=200x125&chd=s:FOE,THE,Bar&chxt=x,y&chxl=1:|Dec|Nov|Oct|0:||20K||60K||100K|') -%>
</p>
-</div> \ No newline at end of file
+ <p>
+ Widget properties:
+ <table>
+ <tr>
+ <td>max:</td>
+ <td><%= widget_properties['max'] -%></td>
+ </tr>
+ <tr>
+ <td>param1:</td>
+ <td><%= widget_properties['param1'] -%></td>
+ </tr>
+ <tr>
+ <td>param2:</td>
+ <td><%= widget_properties['param2'] -%></td>
+ </tr>
+ </table>
+ </p>
+</div>