-
Notifications
You must be signed in to change notification settings - Fork 842
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
84f5e90
commit ad10a91
Showing
21 changed files
with
538 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<groupId>org.codehaus.sonar.examples</groupId> | ||
<artifactId>sonar-gwt-plugin</artifactId> | ||
<packaging>sonar-plugin</packaging> | ||
<version>0.1-SNAPSHOT</version> | ||
<name>Sonar Examples :: GWT Plugin</name> | ||
|
||
<properties> | ||
<sonar.buildVersion>2.10</sonar.buildVersion> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.codehaus.sonar</groupId> | ||
<artifactId>sonar-plugin-api</artifactId> | ||
<version>${sonar.buildVersion}</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.codehaus.sonar</groupId> | ||
<artifactId>sonar-gwt-api</artifactId> | ||
<version>${sonar.buildVersion}</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.google.gwt</groupId> | ||
<artifactId>gwt-user</artifactId> | ||
<version>2.0.3</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.google.gwt</groupId> | ||
<artifactId>gwt-incubator</artifactId> | ||
<version>2.0.1</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
|
||
<!-- unit tests --> | ||
<dependency> | ||
<groupId>org.codehaus.sonar</groupId> | ||
<artifactId>sonar-testing-harness</artifactId> | ||
<version>${sonar.buildVersion}</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>junit</groupId> | ||
<artifactId>junit</artifactId> | ||
<version>4.8.2</version> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.codehaus.sonar</groupId> | ||
<artifactId>sonar-packaging-maven-plugin</artifactId> | ||
<version>1.1</version> | ||
<extensions>true</extensions> | ||
<configuration> | ||
<pluginClass>com.mycompany.sonar.gwt.GwtPlugin</pluginClass> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.codehaus.mojo</groupId> | ||
<artifactId>gwt-maven-plugin</artifactId> | ||
<version>1.2</version> | ||
<executions> | ||
<execution> | ||
<configuration> | ||
<modules> | ||
<module>com.mycompany.sonar.gwt.viewer.SampleViewer</module> | ||
<module>com.mycompany.sonar.gwt.page.SamplePage</module> | ||
</modules> | ||
<webappDirectory>${project.build.directory}/classes</webappDirectory> | ||
<extraJvmArgs>-Xmx512m</extraJvmArgs> | ||
</configuration> | ||
<goals> | ||
<goal>compile</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<version>2.0.2</version> | ||
<configuration> | ||
<source>1.5</source> | ||
<target>1.5</target> | ||
<encoding>UTF-8</encoding> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
19 changes: 19 additions & 0 deletions
19
plugins/sonar-gwt-plugin/src/main/java/com/mycompany/sonar/gwt/GwtPlugin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package com.mycompany.sonar.gwt; | ||
|
||
import com.mycompany.sonar.gwt.page.SamplePage; | ||
import com.mycompany.sonar.gwt.viewer.SampleViewer; | ||
import org.sonar.api.SonarPlugin; | ||
|
||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
public final class GwtPlugin extends SonarPlugin { | ||
|
||
public List getExtensions() { | ||
return Arrays.asList(SampleViewer.class, SamplePage.class); | ||
} | ||
|
||
public String toString() { | ||
return getKey(); | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
plugins/sonar-gwt-plugin/src/main/java/com/mycompany/sonar/gwt/page/SamplePage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.mycompany.sonar.gwt.page; | ||
|
||
import org.sonar.api.web.GwtPage; | ||
import org.sonar.api.web.NavigationSection; | ||
import org.sonar.api.web.UserRole; | ||
|
||
@NavigationSection(NavigationSection.RESOURCE) | ||
@UserRole(UserRole.USER) | ||
public class SamplePage extends GwtPage { | ||
|
||
public String getGwtId() { | ||
return "com.mycompany.sonar.gwt.page.SamplePage"; | ||
} | ||
|
||
public String getTitle() { | ||
return "Sample"; | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
...ins/sonar-gwt-plugin/src/main/java/com/mycompany/sonar/gwt/page/client/I18nConstants.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package com.mycompany.sonar.gwt.page.client; | ||
|
||
import com.google.gwt.core.client.GWT; | ||
|
||
public interface I18nConstants extends com.google.gwt.i18n.client.Constants { | ||
|
||
static I18nConstants INSTANCE = GWT.create(I18nConstants.class); | ||
|
||
@DefaultStringValue("This is a sample") | ||
String sample(); | ||
} |
18 changes: 18 additions & 0 deletions
18
...s/sonar-gwt-plugin/src/main/java/com/mycompany/sonar/gwt/page/client/SamplePagePanel.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.mycompany.sonar.gwt.page.client; | ||
|
||
import com.google.gwt.user.client.ui.Label; | ||
import com.google.gwt.user.client.ui.VerticalPanel; | ||
import com.google.gwt.user.client.ui.Widget; | ||
import org.sonar.gwt.ui.Page; | ||
import org.sonar.wsclient.services.Resource; | ||
|
||
public class SamplePagePanel extends Page { | ||
|
||
@Override | ||
protected Widget doOnResourceLoad(Resource resource) { | ||
VerticalPanel panel = new VerticalPanel(); | ||
panel.add(new Label(resource.getName(true))); | ||
panel.add(new Label(I18nConstants.INSTANCE.sample())); | ||
return panel; | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
plugins/sonar-gwt-plugin/src/main/java/com/mycompany/sonar/gwt/viewer/SampleViewer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.mycompany.sonar.gwt.viewer; | ||
|
||
import org.sonar.api.web.GwtPage; | ||
import org.sonar.api.web.NavigationSection; | ||
import org.sonar.api.web.UserRole; | ||
|
||
@NavigationSection(NavigationSection.RESOURCE_TAB) | ||
@UserRole(UserRole.USER) | ||
public class SampleViewer extends GwtPage { | ||
public String getTitle() { | ||
return "Sample"; | ||
} | ||
|
||
public String getGwtId() { | ||
return "com.mycompany.sonar.gwt.viewer.SampleViewer"; | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
...nar-gwt-plugin/src/main/java/com/mycompany/sonar/gwt/viewer/client/SampleViewerPanel.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package com.mycompany.sonar.gwt.viewer.client; | ||
|
||
import com.google.gwt.user.client.ui.Label; | ||
import com.google.gwt.user.client.ui.Widget; | ||
import org.sonar.gwt.ui.Page; | ||
import org.sonar.wsclient.gwt.AbstractCallback; | ||
import org.sonar.wsclient.gwt.Sonar; | ||
import org.sonar.wsclient.services.Measure; | ||
import org.sonar.wsclient.services.Resource; | ||
import org.sonar.wsclient.services.ResourceQuery; | ||
|
||
public class SampleViewerPanel extends Page { | ||
|
||
private Label label; | ||
|
||
@Override | ||
protected Widget doOnResourceLoad(Resource resource) { | ||
label = new Label("Loading value"); | ||
loadMeasureFromServer(resource); | ||
return label; | ||
} | ||
|
||
// Ajax call to web service | ||
private void loadMeasureFromServer(Resource resource) { | ||
ResourceQuery query = ResourceQuery.createForResource(resource, "random"); | ||
Sonar.getInstance().find(query, new AbstractCallback<Resource>() { | ||
@Override | ||
protected void doOnResponse(Resource result) { | ||
Measure measure = result.getMeasure("random"); | ||
if (measure==null || measure.getValue()==null) { | ||
label.setText("No random value"); | ||
} else { | ||
label.setText("Random value inserted during analysis: " + measure.getValue()); | ||
} | ||
} | ||
}); | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
plugins/sonar-gwt-plugin/src/main/resources/com/mycompany/sonar/gwt/page/SamplePage.gwt.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<module> | ||
|
||
<inherits name='com.google.gwt.user.User'/> | ||
<inherits name="com.google.gwt.json.JSON"/> | ||
<inherits name="com.google.gwt.http.HTTP"/> | ||
<inherits name="org.sonar.Sonar"/> | ||
|
||
<entry-point class='com.mycompany.sonar.gwt.page.client.SamplePagePanel'/> | ||
|
||
<extend-property name="locale" values="en"/> | ||
<extend-property name="locale" values="fr"/> | ||
|
||
</module> |
2 changes: 2 additions & 0 deletions
2
...plugin/src/main/resources/com/mycompany/sonar/gwt/page/client/I18nConstants_fr.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# This file must use UTF-8 encoding | ||
sample=Ceci est un exemple |
32 changes: 32 additions & 0 deletions
32
plugins/sonar-gwt-plugin/src/main/resources/com/mycompany/sonar/gwt/page/public/test.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" | ||
"http://www.w3.org/TR/html4/loose.dtd"> | ||
|
||
<html> | ||
<head> | ||
<meta http-equiv="content-type" content="text/html; charset=UTF-8"> | ||
<title>GWT Smaple</title> | ||
<link href="http://localhost:9000/dev/stylesheets/yui-2.6.0.css" media="all" rel="Stylesheet" type="text/css" /> | ||
<link href="http://localhost:9000/dev/stylesheets/style.css" media="all" rel="Stylesheet" type="text/css" /> | ||
<script src="http://localhost:9000/dev/javascripts/application.js" type="text/javascript"></script> | ||
<script src="http://localhost:9000/dev/javascripts/prototype.js" type="text/javascript"></script> | ||
<script src="http://localhost:9000/dev/javascripts/scriptaculous.js" type="text/javascript"></script> | ||
</head> | ||
|
||
<body> | ||
<script type="text/javascript"> | ||
var config = { | ||
"sonar_url": "http://localhost:9000/dev", | ||
"resource_key" : "org.codehaus.sonar:sonar", | ||
}; | ||
</script> | ||
|
||
<div class="error" id="error" style="display:none"><span id="errormsg"></span> [<a href="#" onclick="javascript:$('error').hide();return false;">hide</a>]</div> | ||
<div class="warning" id="warning" style="display:none"><span id="warningmsg"></span> [<a href="#" onclick="javascript:$('warning').hide();return false;">hide</a>]</div> | ||
<div class="notice" id="info" style="display:none"><span id="infomsg"></span> [<a href="#" onclick="javascript:$('info').hide();return false;">hide</a>]</div> | ||
|
||
<div id="gwtpage"> | ||
</div> | ||
|
||
<script type="text/javascript" language="javascript" src="org.sonar.plugins.gwtsample.page.GwtSamplePage.nocache.js"></script> | ||
</body> | ||
</html> |
10 changes: 10 additions & 0 deletions
10
...s/sonar-gwt-plugin/src/main/resources/com/mycompany/sonar/gwt/viewer/SampleViewer.gwt.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<module> | ||
|
||
<inherits name='com.google.gwt.user.User'/> | ||
<inherits name="com.google.gwt.json.JSON"/> | ||
<inherits name="com.google.gwt.http.HTTP"/> | ||
<inherits name="org.sonar.Sonar"/> | ||
|
||
<entry-point class='com.mycompany.sonar.gwt.viewer.client.SampleViewerPanel'/> | ||
|
||
</module> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<groupId>org.codehaus.sonar.examples</groupId> | ||
<artifactId>sonar-reference-plugin</artifactId> | ||
<packaging>sonar-plugin</packaging> | ||
<version>0.1-SNAPSHOT</version> | ||
<name>Sonar Examples :: Reference Plugin</name> | ||
|
||
<properties> | ||
<sonar.buildVersion>2.10</sonar.buildVersion> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.codehaus.sonar</groupId> | ||
<artifactId>sonar-plugin-api</artifactId> | ||
<version>${sonar.buildVersion}</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
|
||
<!-- unit tests --> | ||
<dependency> | ||
<groupId>org.codehaus.sonar</groupId> | ||
<artifactId>sonar-testing-harness</artifactId> | ||
<version>${sonar.buildVersion}</version> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.codehaus.sonar</groupId> | ||
<artifactId>sonar-packaging-maven-plugin</artifactId> | ||
<version>1.1</version> | ||
<extensions>true</extensions> | ||
<configuration> | ||
<pluginClass>com.mycompany.sonar.reference.SamplePlugin</pluginClass> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<version>2.0.2</version> | ||
<configuration> | ||
<source>1.5</source> | ||
<target>1.5</target> | ||
<encoding>UTF-8</encoding> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
31 changes: 31 additions & 0 deletions
31
...ins/sonar-reference-plugin/src/main/java/com/mycompany/sonar/reference/SampleMetrics.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package com.mycompany.sonar.reference; | ||
|
||
import org.sonar.api.measures.CoreMetrics; | ||
import org.sonar.api.measures.Metric; | ||
import org.sonar.api.measures.Metrics; | ||
|
||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
public final class SampleMetrics implements Metrics { | ||
|
||
public static final Metric MESSAGE = new Metric.Builder("message_key", "Message", Metric.ValueType.STRING) | ||
.setDescription("This is a metric to store a well known message") | ||
.setDirection(Metric.DIRECTION_WORST) | ||
.setQualitative(false) | ||
.setDomain(CoreMetrics.DOMAIN_GENERAL) | ||
.create(); | ||
|
||
public static final Metric RANDOM = new Metric.Builder("random", "Random", Metric.ValueType.FLOAT) | ||
.setDescription("Random value") | ||
.setDirection(Metric.DIRECTION_BETTER) | ||
.setQualitative(false) | ||
.setDomain(CoreMetrics.DOMAIN_GENERAL) | ||
.create(); | ||
|
||
// getMetrics() method is defined in the Metrics interface and is used by | ||
// Sonar to retrieve the list of new Metric | ||
public List<Metric> getMetrics() { | ||
return Arrays.asList(MESSAGE, RANDOM); | ||
} | ||
} |
Oops, something went wrong.