aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-gwt-api/src
diff options
context:
space:
mode:
authorsimonbrandhof <simon.brandhof@gmail.com>2010-09-06 14:08:06 +0000
committersimonbrandhof <simon.brandhof@gmail.com>2010-09-06 14:08:06 +0000
commitaeadc1f9129274949daaa57738c7c4550bdfbc7b (patch)
tree08dadf5ef7474fc41d1d48f74648f1ba8b55f34d /sonar-gwt-api/src
downloadsonarqube-aeadc1f9129274949daaa57738c7c4550bdfbc7b.tar.gz
sonarqube-aeadc1f9129274949daaa57738c7c4550bdfbc7b.zip
SONAR-236 remove deprecated code from checkstyle plugin + display default value of rule parameters in Q profile console
Diffstat (limited to 'sonar-gwt-api/src')
-rw-r--r--sonar-gwt-api/src/main/java/org/sonar/gwt/Configuration.java97
-rw-r--r--sonar-gwt-api/src/main/java/org/sonar/gwt/JsonUtils.java176
-rw-r--r--sonar-gwt-api/src/main/java/org/sonar/gwt/Links.java106
-rw-r--r--sonar-gwt-api/src/main/java/org/sonar/gwt/Metrics.java110
-rw-r--r--sonar-gwt-api/src/main/java/org/sonar/gwt/Utils.java72
-rw-r--r--sonar-gwt-api/src/main/java/org/sonar/gwt/ui/DefaultSourcePanel.java34
-rw-r--r--sonar-gwt-api/src/main/java/org/sonar/gwt/ui/ExpandCollapseLink.java55
-rw-r--r--sonar-gwt-api/src/main/java/org/sonar/gwt/ui/Icons.java151
-rw-r--r--sonar-gwt-api/src/main/java/org/sonar/gwt/ui/Loading.java33
-rw-r--r--sonar-gwt-api/src/main/java/org/sonar/gwt/ui/Page.java92
-rw-r--r--sonar-gwt-api/src/main/java/org/sonar/gwt/ui/SourcePanel.java336
-rw-r--r--sonar-gwt-api/src/main/java/org/sonar/gwt/ui/ViewerHeader.java138
-rw-r--r--sonar-gwt-api/src/main/java/org/sonar/wsclient/gwt/AbstractCallback.java67
-rw-r--r--sonar-gwt-api/src/main/java/org/sonar/wsclient/gwt/AbstractListCallback.java69
-rw-r--r--sonar-gwt-api/src/main/java/org/sonar/wsclient/gwt/Callback.java33
-rw-r--r--sonar-gwt-api/src/main/java/org/sonar/wsclient/gwt/GwtUtils.java37
-rw-r--r--sonar-gwt-api/src/main/java/org/sonar/wsclient/gwt/ListCallback.java33
-rw-r--r--sonar-gwt-api/src/main/java/org/sonar/wsclient/gwt/Sonar.java92
-rw-r--r--sonar-gwt-api/src/main/java/org/sonar/wsclient/gwt/unmarshallers/AbstractUnmarshaller.java53
-rw-r--r--sonar-gwt-api/src/main/java/org/sonar/wsclient/gwt/unmarshallers/DependencyTreeUnmarshaller.java55
-rw-r--r--sonar-gwt-api/src/main/java/org/sonar/wsclient/gwt/unmarshallers/DependencyUnmarshaller.java42
-rw-r--r--sonar-gwt-api/src/main/java/org/sonar/wsclient/gwt/unmarshallers/MetricUnmarshaller.java39
-rw-r--r--sonar-gwt-api/src/main/java/org/sonar/wsclient/gwt/unmarshallers/PropertyUnmarshaller.java33
-rw-r--r--sonar-gwt-api/src/main/java/org/sonar/wsclient/gwt/unmarshallers/ResourceUnmarshaller.java99
-rw-r--r--sonar-gwt-api/src/main/java/org/sonar/wsclient/gwt/unmarshallers/ServerUnmarshaller.java43
-rw-r--r--sonar-gwt-api/src/main/java/org/sonar/wsclient/gwt/unmarshallers/SourceUnmarshaller.java42
-rw-r--r--sonar-gwt-api/src/main/java/org/sonar/wsclient/gwt/unmarshallers/Unmarshaller.java33
-rw-r--r--sonar-gwt-api/src/main/java/org/sonar/wsclient/gwt/unmarshallers/Unmarshallers.java49
-rw-r--r--sonar-gwt-api/src/main/java/org/sonar/wsclient/gwt/unmarshallers/ViolationUnmarshaller.java49
-rw-r--r--sonar-gwt-api/src/main/resources/org/sonar/Sonar.gwt.xml10
-rw-r--r--sonar-gwt-api/src/main/resources/org/sonar/gwt/ui/empty.gifbin0 -> 55 bytes
-rw-r--r--sonar-gwt-api/src/main/resources/org/sonar/gwt/ui/help.pngbin0 -> 786 bytes
-rwxr-xr-xsonar-gwt-api/src/main/resources/org/sonar/gwt/ui/information.pngbin0 -> 778 bytes
-rw-r--r--sonar-gwt-api/src/main/resources/org/sonar/gwt/ui/javaModule.pngbin0 -> 1027 bytes
-rw-r--r--sonar-gwt-api/src/main/resources/org/sonar/gwt/ui/priorityBlocker.pngbin0 -> 1225 bytes
-rw-r--r--sonar-gwt-api/src/main/resources/org/sonar/gwt/ui/priorityCritical.pngbin0 -> 1160 bytes
-rw-r--r--sonar-gwt-api/src/main/resources/org/sonar/gwt/ui/priorityInfo.pngbin0 -> 1225 bytes
-rw-r--r--sonar-gwt-api/src/main/resources/org/sonar/gwt/ui/priorityMajor.pngbin0 -> 1225 bytes
-rw-r--r--sonar-gwt-api/src/main/resources/org/sonar/gwt/ui/priorityMinor.pngbin0 -> 1225 bytes
-rw-r--r--sonar-gwt-api/src/main/resources/org/sonar/gwt/ui/qualifierClass.pngbin0 -> 529 bytes
-rw-r--r--sonar-gwt-api/src/main/resources/org/sonar/gwt/ui/qualifierDirectory.pngbin0 -> 502 bytes
-rw-r--r--sonar-gwt-api/src/main/resources/org/sonar/gwt/ui/qualifierField.pngbin0 -> 818 bytes
-rw-r--r--sonar-gwt-api/src/main/resources/org/sonar/gwt/ui/qualifierFile.pngbin0 -> 529 bytes
-rw-r--r--sonar-gwt-api/src/main/resources/org/sonar/gwt/ui/qualifierLibrary.pngbin0 -> 608 bytes
-rw-r--r--sonar-gwt-api/src/main/resources/org/sonar/gwt/ui/qualifierMethod.pngbin0 -> 794 bytes
-rw-r--r--sonar-gwt-api/src/main/resources/org/sonar/gwt/ui/qualifierModule.pngbin0 -> 704 bytes
-rw-r--r--sonar-gwt-api/src/main/resources/org/sonar/gwt/ui/qualifierPackage.pngbin0 -> 632 bytes
-rw-r--r--sonar-gwt-api/src/main/resources/org/sonar/gwt/ui/qualifierProject.pngbin0 -> 700 bytes
-rw-r--r--sonar-gwt-api/src/main/resources/org/sonar/gwt/ui/qualifierUnitTest.pngbin0 -> 725 bytes
-rw-r--r--sonar-gwt-api/src/main/resources/org/sonar/gwt/ui/qualifierView.pngbin0 -> 714 bytes
-rwxr-xr-xsonar-gwt-api/src/main/resources/org/sonar/gwt/ui/statusError.pngbin0 -> 1354 bytes
-rwxr-xr-xsonar-gwt-api/src/main/resources/org/sonar/gwt/ui/statusOk.pngbin0 -> 1354 bytes
-rwxr-xr-xsonar-gwt-api/src/main/resources/org/sonar/gwt/ui/statusWarning.pngbin0 -> 1335 bytes
-rw-r--r--sonar-gwt-api/src/main/resources/org/sonar/gwt/ui/zoom.pngbin0 -> 503 bytes
54 files changed, 2278 insertions, 0 deletions
diff --git a/sonar-gwt-api/src/main/java/org/sonar/gwt/Configuration.java b/sonar-gwt-api/src/main/java/org/sonar/gwt/Configuration.java
new file mode 100644
index 00000000000..87b8cae5eab
--- /dev/null
+++ b/sonar-gwt-api/src/main/java/org/sonar/gwt/Configuration.java
@@ -0,0 +1,97 @@
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2009 SonarSource SA
+ * 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.gwt;
+
+import com.google.gwt.i18n.client.Dictionary;
+
+import java.util.Set;
+
+public final class Configuration {
+
+ private Configuration() {
+ // only static methods
+ }
+
+ public static String getSonarVersion() {
+ return getParameter("version");
+ }
+
+ /**
+ * Get the id of the selected resource. Can be null if none resource is selected.
+ */
+ public static String getResourceId() {
+ return getParameter("resource_key");
+ }
+
+ public static String getParameter(String key) {
+ return getParameter(key, null);
+ }
+
+ public static String getParameter(String key, String defaultValue) {
+ String result = getDictionaryEntry("config", key);
+ if (result == null) {
+ result = defaultValue;
+ }
+ return result;
+ }
+
+ public static native void setParameter(String key, String val) /*-{
+ $wnd.config[key] = val;
+ }-*/;
+
+ public static String getRequestParameter(String key) {
+ return getDictionaryEntry("rp", key);
+ }
+
+ public static String getRequestParameter(String key, String defaultValue) {
+ String value = getRequestParameter(key);
+ return (value!=null ? value : defaultValue);
+ }
+
+ public static Set<String> getParameterKeys() {
+ return getDictionaryKeys("config");
+ }
+
+ public static Set<String> getRequestParameterKeys() {
+ return getDictionaryKeys("rp");
+ }
+
+ private static String getDictionaryEntry(String dictionaryName, String key) {
+ try {
+ Dictionary dic = Dictionary.getDictionary(dictionaryName);
+ if (dic != null) {
+ return dic.get(key);
+ }
+ return null;
+
+ } catch (Exception e) {
+ return null;
+ }
+ }
+
+ private static Set<String> getDictionaryKeys(String dictionaryName) {
+ Dictionary dic = Dictionary.getDictionary(dictionaryName);
+ if (dic != null) {
+ return dic.keySet();
+ }
+ return null;
+ }
+
+}
diff --git a/sonar-gwt-api/src/main/java/org/sonar/gwt/JsonUtils.java b/sonar-gwt-api/src/main/java/org/sonar/gwt/JsonUtils.java
new file mode 100644
index 00000000000..5221c70b450
--- /dev/null
+++ b/sonar-gwt-api/src/main/java/org/sonar/gwt/JsonUtils.java
@@ -0,0 +1,176 @@
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2009 SonarSource SA
+ * 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.gwt;
+
+import com.google.gwt.core.client.JavaScriptException;
+import com.google.gwt.core.client.JavaScriptObject;
+import com.google.gwt.http.client.URL;
+import com.google.gwt.i18n.client.DateTimeFormat;
+import com.google.gwt.json.client.*;
+
+import java.util.Date;
+
+public final class JsonUtils {
+ private static int requestId = 0;
+
+ private JsonUtils() {
+ // only static methods
+ }
+
+ public interface JSONHandler {
+ void onResponse(JavaScriptObject obj);
+ void onTimeout();
+ void onError(int errorCode, String errorMessage);
+ }
+
+ public static void requestJson(String url, JSONHandler handler) {
+ if (!url.endsWith("&") && !url.endsWith("?")) {
+ url += "&";
+ }
+ if (!url.contains("format=json")) {
+ url += "format=json&";
+ }
+ if (!url.contains("callback=")) {
+ //IMPORTANT : the url should ended with ?callback= or &callback= for JSONP calls
+ url += "callback=";
+ }
+ makeJSONRequest(requestId++, URL.encode(url), handler);
+ }
+
+ public static native void makeJSONRequest(int requestId, String url, JSONHandler handler) /*-{
+ var callback = "callback" + requestId;
+
+ // create SCRIPT tag, and set SRC attribute equal to JSON feed URL + callback function name
+ var script = document.createElement("script");
+ script.setAttribute("src", url+callback);
+ script.setAttribute("type", "text/javascript");
+
+ window[callback] = function(jsonObj) {
+ @org.sonar.gwt.JsonUtils::dispatchJSON(Lcom/google/gwt/core/client/JavaScriptObject;Lorg/sonar/gwt/JsonUtils$JSONHandler;)(jsonObj, handler);
+ window[callback + "done"] = true;
+ }
+
+ setTimeout(function() {
+ if (!window[callback + "done"]) {
+ handler.@org.sonar.gwt.JsonUtils.JSONHandler::onTimeout();
+ }
+
+ // cleanup
+ document.body.removeChild(script);
+ if (window[callback]) {
+ delete window[callback];
+ }
+ if (window[callback + "done"]) {
+ delete window[callback + "done"];
+ }
+ }, 120000);
+
+ document.body.appendChild(script);
+ }-*/;
+
+ public static void dispatchJSON(JavaScriptObject jsonObj, JSONHandler handler) {
+ JSONObject obj = new JSONObject(jsonObj);
+ if (obj.isObject() != null) {
+ if (obj.containsKey("err_code")) {
+ handler.onError(new Double(obj.get("err_code").isNumber().doubleValue()).intValue(),
+ obj.get("err_msg").isString().stringValue());
+ return;
+ }
+ }
+ handler.onResponse(jsonObj);
+ }
+
+ public static String getString(JSONObject json, String field) {
+ JSONValue jsonValue;
+ JSONString jsonString;
+ if ((jsonValue = json.get(field)) == null) {
+ return null;
+ }
+ if ((jsonString = jsonValue.isString()) == null) {
+ JSONNumber jsonNumber = jsonValue.isNumber();
+ return jsonNumber != null ? jsonNumber.toString() : null;
+ }
+ return jsonString.stringValue();
+ }
+
+ public static Date getDate(JSONObject json, String field) {
+ DateTimeFormat frmt = DateTimeFormat.getFormat("yyyy-MM-dd'T'HH:mm:ssZ");
+ String date = getString(json, field);
+ if (date!=null && date.endsWith("Z") && date.length()>2) {
+ // see SONAR-1182
+ date = date.substring(0, date.length()-2) + "+00:00";
+ }
+ return frmt.parse(date);
+ }
+
+ public static Boolean getBoolean(JSONObject json, String field) {
+ JSONValue jsonValue;
+ JSONBoolean jsonBoolean;
+ if ((jsonValue = json.get(field)) == null) {
+ return null;
+ }
+ if ((jsonBoolean = jsonValue.isBoolean()) == null) {
+ return null;
+ }
+ return jsonBoolean.booleanValue();
+ }
+
+ public static Double getDouble(JSONObject json, String field) {
+ JSONValue jsonValue;
+ JSONNumber jsonNumber;
+ if ((jsonValue = json.get(field)) == null) {
+ return null;
+ }
+ if ((jsonNumber = jsonValue.isNumber()) == null) {
+ return null;
+ }
+ return jsonNumber.doubleValue();
+ }
+
+ public static Integer getInteger(JSONObject json, String field) {
+ final Double d = getDouble(json, field);
+ if (d != null) {
+ return d.intValue();
+ }
+ return null;
+ }
+
+ public static JSONObject getArray(JSONValue json, int i) {
+ if (json instanceof JSONArray) {
+ return ((JSONArray) json).get(i).isObject();
+ }
+ if (json instanceof JSONObject) {
+ return ((JSONObject) json).get(Integer.toString(i)).isObject();
+ }
+ throw new JavaScriptException("Not implemented");
+ }
+
+ public static int getArraySize(JSONValue array) {
+ if (array instanceof JSONArray) {
+ return ((JSONArray) array).size();
+ }
+ if (array instanceof JSONObject) {
+ return ((JSONObject) array).size();
+ }
+ throw new JavaScriptException("Not implemented");
+ }
+
+}
+
diff --git a/sonar-gwt-api/src/main/java/org/sonar/gwt/Links.java b/sonar-gwt-api/src/main/java/org/sonar/gwt/Links.java
new file mode 100644
index 00000000000..a20bc08efee
--- /dev/null
+++ b/sonar-gwt-api/src/main/java/org/sonar/gwt/Links.java
@@ -0,0 +1,106 @@
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2009 SonarSource SA
+ * 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.gwt;
+
+import com.google.gwt.user.client.Window;
+
+public final class Links {
+
+ public static final String DEFAULT_POPUP_HTML_FEATURES = "height=800,width=900,scrollbars=1,resizable=1";
+
+ private Links() {
+ // only static methods
+ }
+
+ public static String baseUrl() {
+ return Configuration.getParameter("sonar_url");
+ }
+
+ public static String apiUrl() {
+ return baseUrl() + "/api";
+ }
+
+
+ public static String urlForResource(String resourceIdOrKey) {
+ return urlForMeasure(resourceIdOrKey, null);
+ }
+
+ public static String urlForMeasure(String resourceIdOrKey, String metricKey) {
+ String url = baseUrl() + "/resource/index/" + resourceIdOrKey;
+ if (metricKey != null) {
+ url += "?metric=" + metricKey;
+ }
+ return url;
+ }
+
+ /**
+ *
+ * @param resourceIdOrKey
+ * @param pageId
+ * @param query additional query parameters. Can be null. Example "layout=false&param1=val1"
+ */
+ public static String urlForResourcePage(String resourceIdOrKey, String pageId, String query) {
+ String url = baseUrl() + "/plugins/resource/";
+ if (resourceIdOrKey != null) {
+ url += resourceIdOrKey;
+ }
+ url += "?page=";
+ url += pageId;
+ if (query != null) {
+ url += "&";
+ url += query;
+ }
+ return url;
+ }
+
+ public static String urlForRule(String ruleIdOrKey, boolean showLayout) {
+ return baseUrl() + "/rules/show/" + ruleIdOrKey + "?layout=" + showLayout;
+ }
+
+ public static String urlForDrilldown(String resourceIdOrKey, String metricKey) {
+ return baseUrl() + "/drilldown/measures/" + resourceIdOrKey + "?metric=" + metricKey;
+ }
+
+ public static void openResourcePopup(final String resourceIdOrKey) {
+ openMeasurePopup(resourceIdOrKey, null);
+ }
+
+ /**
+ * Open the resource in a popup with HTML features like: height=800,width=900,scrollbars=1,resizable=1
+ *
+ * @param resourceIdOrKey the id or key of the resource to display, not null
+ * @param metricKey the metric to highlight (optional : can be null)
+ */
+ public static void openMeasurePopup(final String resourceIdOrKey, final String metricKey) {
+ openMeasurePopup(resourceIdOrKey, metricKey, DEFAULT_POPUP_HTML_FEATURES);
+ }
+
+
+ public static void openMeasurePopup(final String resourceKey, final String metricKey, final String htmlFeatures) {
+ String url = urlForMeasure(resourceKey, metricKey);
+ Window.open(url, "resource", htmlFeatures);
+ }
+
+
+ public static void openResourcePage(final String pageId, final String resourceIdOrKey, final String query) {
+ String url = urlForResourcePage(pageId, resourceIdOrKey, query);
+ Window.Location.assign(url);
+ }
+}
diff --git a/sonar-gwt-api/src/main/java/org/sonar/gwt/Metrics.java b/sonar-gwt-api/src/main/java/org/sonar/gwt/Metrics.java
new file mode 100644
index 00000000000..fad2bf18671
--- /dev/null
+++ b/sonar-gwt-api/src/main/java/org/sonar/gwt/Metrics.java
@@ -0,0 +1,110 @@
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2009 SonarSource SA
+ * 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.gwt;
+
+/**
+ * Keys of core metrics
+ */
+public interface Metrics {
+
+ String LINES = "lines";
+ String NCLOC = "ncloc";
+ String GENERATED_NCLOC = "generated_ncloc";
+ String GENERATED_LINES = "generated_lines";
+ String CLASSES = "classes";
+ String FILES = "files";
+ String DIRECTORIES = "directories";
+ String PACKAGES = "packages";
+ String FUNCTIONS = "functions";
+ String PARAGRAPHS = "paragraphs";
+ String ACCESSORS = "accessors";
+ String STATEMENTS = "statements";
+ String PUBLIC_API = "public_api";
+ String COMPLEXITY = "complexity";
+ String CLASS_COMPLEXITY = "class_complexity";
+ String FUNCTION_COMPLEXITY = "function_complexity";
+ String PARAGRAPH_COMPLEXITY = "paragraph_complexity";
+ String FILE_COMPLEXITY = "file_complexity";
+ String CLASS_COMPLEXITY_DISTRIBUTION = "class_complexity_distribution";
+ String FUNCTION_COMPLEXITY_DISTRIBUTION = "function_complexity_distribution";
+ String COMMENT_LINES = "comment_lines";
+ String COMMENT_LINES_DENSITY = "comment_lines_density";
+ String COMMENT_BLANK_LINES = "comment_blank_lines";
+ String PUBLIC_DOCUMENTED_API_DENSITY = "public_documented_api_density";
+ String PUBLIC_UNDOCUMENTED_API = "public_undocumented_api";
+ String COMMENTED_OUT_CODE_LINES = "commented_out_code_lines";
+ String TESTS = "tests";
+ String TEST_EXECUTION_TIME = "test_execution_time";
+ String TEST_ERRORS = "test_errors";
+ String SKIPPED_TESTS = "skipped_tests";
+ String TEST_FAILURES = "test_failures";
+ String TEST_SUCCESS_DENSITY = "test_success_density";
+ String TEST_DATA = "test_data";
+ String COVERAGE = "coverage";
+ String LINES_TO_COVER = "lines_to_cover";
+ String UNCOVERED_LINES = "uncovered_lines";
+ String LINE_COVERAGE = "line_coverage";
+ String COVERAGE_LINE_HITS_DATA = "coverage_line_hits_data";
+ String CONDITIONS_TO_COVER = "conditions_to_cover";
+ String UNCOVERED_CONDITIONS = "uncovered_conditions";
+ String BRANCH_COVERAGE = "branch_coverage";
+ String BRANCH_COVERAGE_HITS_DATA = "branch_coverage_hits_data";
+ String DUPLICATED_LINES = "duplicated_lines";
+ String DUPLICATED_BLOCKS = "duplicated_blocks";
+ String DUPLICATED_FILES = "duplicated_files";
+ String DUPLICATED_LINES_DENSITY = "duplicated_lines_density";
+ String DUPLICATIONS_DATA = "duplications_data";
+ String USABILITY = "usability";
+ String RELIABILITY = "reliability";
+ String EFFICIENCY = "efficiency";
+ String PORTABILITY = "portability";
+ String MAINTAINABILITY = "maintainability";
+ String WEIGHTED_VIOLATIONS = "weighted_violations";
+ String VIOLATIONS_DENSITY = "violations_density";
+ String VIOLATIONS = "violations";
+ String BLOCKER_VIOLATIONS = "blocker_violations";
+ String CRITICAL_VIOLATIONS = "critical_violations";
+ String MAJOR_VIOLATIONS = "major_violations";
+ String MINOR_VIOLATIONS = "minor_violations";
+ String INFO_VIOLATIONS = "info_violations";
+ String DEPTH_IN_TREE = "dit";
+ String NUMBER_OF_CHILDREN = "noc";
+ String RFC = "rfc";
+ String RFC_DISTRIBUTION = "rfc_distribution";
+ String LCOM4 = "lcom4";
+ String LCOM4_DISTRIBUTION = "lcom4_distribution";
+ String AFFERENT_COUPLINGS = "ca";
+ String EFFERENT_COUPLINGS = "ce";
+ String ABSTRACTNESS = "abstractness";
+ String INSTABILITY = "instability";
+ String DISTANCE = "distance";
+ String DEPENDENCY_MATRIX = "dsm";
+ String PACKAGE_CYCLES = "package_cycles";
+ String PACKAGE_TANGLE_INDEX = "package_tangle_index";
+ String PACKAGE_TANGLES = "package_tangles";
+ String PACKAGE_FEEDBACK_EDGES = "package_feedback_edges";
+ String PACKAGE_EDGES_WEIGHT = "package_edges_weight";
+ String FILE_CYCLES = "file_cycles";
+ String FILE_TANGLE_INDEX = "file_tangle_index";
+ String FILE_TANGLES = "file_tangles";
+ String FILE_FEEDBACK_EDGES = "file_feedback_edges";
+ String FILE_EDGES_WEIGHT = "file_edges_weight";
+ String ALERT_STATUS = "alert_status";
+}
diff --git a/sonar-gwt-api/src/main/java/org/sonar/gwt/Utils.java b/sonar-gwt-api/src/main/java/org/sonar/gwt/Utils.java
new file mode 100644
index 00000000000..65abbadb5a1
--- /dev/null
+++ b/sonar-gwt-api/src/main/java/org/sonar/gwt/Utils.java
@@ -0,0 +1,72 @@
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2009 SonarSource SA
+ * 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.gwt;
+
+import com.google.gwt.i18n.client.NumberFormat;
+import com.google.gwt.user.client.DOM;
+import com.google.gwt.user.client.Element;
+
+public final class Utils {
+
+ private Utils() {
+ // only static methods
+ }
+
+ /**
+ * @return width in pixels of the GWT component in the Sonar page
+ */
+ public static int getPageWidth() {
+ return DOM.getElementById("gwtpage").getClientWidth();
+ }
+
+ public static String escapeHtml(String maybeHtml) {
+ final Element div = DOM.createDiv();
+ DOM.setInnerText(div, maybeHtml);
+ return DOM.getInnerHTML(div);
+ }
+
+ public static String formatPercent(String percentage) {
+ return percentage == null || percentage.equals("") ? "" : formatPercent(new Double(percentage));
+ }
+
+ public static String formatPercent(double percentage) {
+ return NumberFormat.getFormat("0.0").format(percentage) + "%";
+ }
+
+ public static String formatNumber(String number) {
+ return number == null || number.equals("") ? "" : formatNumber(new Double(number));
+ }
+
+ public static String formatNumber(double number) {
+ return NumberFormat.getDecimalFormat().format(number);
+ }
+
+ public static native void showError(String message) /*-{
+ $wnd.error(message);
+ }-*/;
+
+ public static native void showWarning(String message) /*-{
+ $wnd.warning(message);
+ }-*/;
+
+ public static native void showInfo(String message) /*-{
+ $wnd.info(message);
+ }-*/;
+}
diff --git a/sonar-gwt-api/src/main/java/org/sonar/gwt/ui/DefaultSourcePanel.java b/sonar-gwt-api/src/main/java/org/sonar/gwt/ui/DefaultSourcePanel.java
new file mode 100644
index 00000000000..ef7b4ece17b
--- /dev/null
+++ b/sonar-gwt-api/src/main/java/org/sonar/gwt/ui/DefaultSourcePanel.java
@@ -0,0 +1,34 @@
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2009 SonarSource SA
+ * 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.gwt.ui;
+
+import org.sonar.wsclient.services.Resource;
+
+public class DefaultSourcePanel extends SourcePanel {
+ public DefaultSourcePanel(Resource resource) {
+ super(resource);
+ setStarted();
+ }
+
+ public DefaultSourcePanel(Resource resource, int from, int length) {
+ super(resource, from, length);
+ setStarted();
+ }
+}
diff --git a/sonar-gwt-api/src/main/java/org/sonar/gwt/ui/ExpandCollapseLink.java b/sonar-gwt-api/src/main/java/org/sonar/gwt/ui/ExpandCollapseLink.java
new file mode 100644
index 00000000000..3c83903ab7f
--- /dev/null
+++ b/sonar-gwt-api/src/main/java/org/sonar/gwt/ui/ExpandCollapseLink.java
@@ -0,0 +1,55 @@
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2009 SonarSource SA
+ * 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.gwt.ui;
+
+import com.google.gwt.user.client.ui.ClickListener;
+import com.google.gwt.user.client.ui.Hyperlink;
+import com.google.gwt.user.client.ui.Widget;
+
+public class ExpandCollapseLink extends Hyperlink {
+
+ private Widget expandOrCollapse;
+
+ public ExpandCollapseLink(Widget expandOrCollapse) {
+ super();
+ this.expandOrCollapse = expandOrCollapse;
+ setText(getLinkLabel(!expandOrCollapse.isVisible()));
+ getElement().setId("expand-" + expandOrCollapse.getElement().getId());
+ setStyleName("expandCollapseLink");
+ final ExpandCollapseLink link = this;
+ this.addClickListener(new ClickListener() {
+ public void onClick(Widget sender) {
+ link.toggle();
+ }
+ });
+ getElement().getFirstChildElement().setAttribute("href", "#");
+ }
+
+ public void toggle() {
+ boolean visible = expandOrCollapse.isVisible();
+ setText(getLinkLabel(visible));
+ expandOrCollapse.setVisible(!visible);
+ }
+
+ protected String getLinkLabel(boolean show) {
+ return (show ? "expand" : "collapse");
+ }
+
+} \ No newline at end of file
diff --git a/sonar-gwt-api/src/main/java/org/sonar/gwt/ui/Icons.java b/sonar-gwt-api/src/main/java/org/sonar/gwt/ui/Icons.java
new file mode 100644
index 00000000000..10ff4cee076
--- /dev/null
+++ b/sonar-gwt-api/src/main/java/org/sonar/gwt/ui/Icons.java
@@ -0,0 +1,151 @@
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2009 SonarSource SA
+ * 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.gwt.ui;
+
+import com.google.gwt.core.client.GWT;
+import com.google.gwt.user.client.ui.AbstractImagePrototype;
+import com.google.gwt.user.client.ui.ImageBundle;
+
+/**
+ * All icons are 16x16 pixels
+ */
+public final class Icons {
+ private static IconBundle INSTANCE;
+
+ private Icons() {
+ // only static methods
+ }
+
+ public static IconBundle get() {
+ if (INSTANCE == null) {
+ INSTANCE = GWT.create(IconBundle.class);
+ }
+ return INSTANCE;
+ }
+
+ public static AbstractImagePrototype forQualifier(final String qualifier) {
+ AbstractImagePrototype image;
+ if ("FIL".equals(qualifier)) {
+ image = get().qualifierFile();
+ } else if ("CLA".equals(qualifier)) {
+ image = get().qualifierClass();
+
+ } else if ("PAC".equals(qualifier)) {
+ image = get().qualifierPackage();
+
+ } else if ("DIR".equals(qualifier)) {
+ image = get().qualifierDirectory();
+
+ } else if ("BRC".equals(qualifier)) {
+ image = get().qualifierModule();
+
+ } else if ("TRK".equals(qualifier)) {
+ image = get().qualifierProject();
+
+ } else if ("UTS".equals(qualifier)) {
+ image = get().qualifierUnitTest();
+
+ } else if ("FLD".equals(qualifier)) {
+ image = get().qualifierField();
+
+ } else if ("MET".equals(qualifier)) {
+ image = get().qualifierMethod();
+
+ } else if ("LIB".equals(qualifier)) {
+ image = get().qualifierLibrary();
+
+ } else {
+ image = get().empty();
+ }
+ return image;
+ }
+
+ /**
+ * @since 2.2
+ */
+ public static AbstractImagePrototype forPriority(final String priority) {
+ AbstractImagePrototype image;
+ if ("BLOCKER".equals(priority)) {
+ image = get().priorityBlocker();
+
+ } else if ("CRITICAL".equals(priority)) {
+ image = get().priorityCritical();
+
+ } else if ("MAJOR".equals(priority)) {
+ image = get().priorityMajor();
+
+ } else if ("MINOR".equals(priority)) {
+ image = get().priorityMinor();
+
+ } else if ("INFO".equals(priority)) {
+ image = get().priorityInfo();
+
+ } else {
+ image = get().empty();
+ }
+ return image;
+ }
+
+ public static interface IconBundle extends ImageBundle {
+ AbstractImagePrototype empty();
+
+ AbstractImagePrototype zoom();
+
+ AbstractImagePrototype information();
+
+ AbstractImagePrototype help();
+
+ AbstractImagePrototype qualifierField();
+
+ AbstractImagePrototype qualifierMethod();
+
+ AbstractImagePrototype qualifierClass();
+
+ AbstractImagePrototype qualifierFile();
+
+ AbstractImagePrototype qualifierUnitTest();
+
+ AbstractImagePrototype qualifierDirectory();
+
+ AbstractImagePrototype qualifierPackage();
+
+ AbstractImagePrototype qualifierProject();
+
+ AbstractImagePrototype qualifierModule();
+
+ AbstractImagePrototype qualifierLibrary();
+
+ AbstractImagePrototype statusOk();
+
+ AbstractImagePrototype statusError();
+
+ AbstractImagePrototype statusWarning();
+
+ AbstractImagePrototype priorityBlocker();
+
+ AbstractImagePrototype priorityCritical();
+
+ AbstractImagePrototype priorityMajor();
+
+ AbstractImagePrototype priorityMinor();
+
+ AbstractImagePrototype priorityInfo();
+ }
+} \ No newline at end of file
diff --git a/sonar-gwt-api/src/main/java/org/sonar/gwt/ui/Loading.java b/sonar-gwt-api/src/main/java/org/sonar/gwt/ui/Loading.java
new file mode 100644
index 00000000000..fcd516fa556
--- /dev/null
+++ b/sonar-gwt-api/src/main/java/org/sonar/gwt/ui/Loading.java
@@ -0,0 +1,33 @@
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2009 SonarSource SA
+ * 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.gwt.ui;
+
+import com.google.gwt.user.client.ui.Label;
+
+public class Loading extends Label {
+ public Loading() {
+ this("loading...");
+ }
+
+ public Loading(String text) {
+ setStyleName("loading");
+ setText(text);
+ }
+}
diff --git a/sonar-gwt-api/src/main/java/org/sonar/gwt/ui/Page.java b/sonar-gwt-api/src/main/java/org/sonar/gwt/ui/Page.java
new file mode 100644
index 00000000000..94b2785f6e9
--- /dev/null
+++ b/sonar-gwt-api/src/main/java/org/sonar/gwt/ui/Page.java
@@ -0,0 +1,92 @@
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2009 SonarSource SA
+ * 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.gwt.ui;
+
+import com.google.gwt.core.client.EntryPoint;
+import com.google.gwt.core.client.GWT;
+import com.google.gwt.core.client.JavaScriptObject;
+import com.google.gwt.user.client.ui.RootPanel;
+import com.google.gwt.user.client.ui.Widget;
+import org.sonar.wsclient.gwt.unmarshallers.ResourceUnmarshaller;
+import org.sonar.wsclient.services.Resource;
+
+public abstract class Page implements EntryPoint {
+
+ private Widget currentWidget = null;
+ private Integer currentResourceId = null;
+
+ public final void onModuleLoad() {
+ export(GWT.getModuleName(), this);
+ load();
+ onResourceLoad();
+ }
+
+ private void load() {
+ Widget widget = doOnModuleLoad();
+ if (widget!=null) {
+ getRootPanel().add(widget);
+ }
+ }
+
+ protected Widget doOnModuleLoad() {
+ return null;
+ }
+
+ public final void onResourceLoad() {
+ JavaScriptObject json = loadResource();
+ if (json != null) {
+ Resource resource = ResourceUnmarshaller.getInstance().toModel(json);
+
+ RootPanel container = getRootPanel();
+ container.clear();
+ if (resource.getId().equals(currentResourceId) && currentWidget != null) {
+ container.add(currentWidget);
+
+ } else {
+ currentWidget = doOnResourceLoad(resource);
+ currentResourceId = resource.getId();
+ if (currentWidget != null) {
+ container.add(currentWidget);
+ }
+ }
+ }
+ }
+
+ protected Widget doOnResourceLoad(Resource resource) {
+ return null;
+ }
+
+ protected final RootPanel getRootPanel() {
+ RootPanel result = RootPanel.get("gwtpage-" + GWT.getModuleName());
+ if (result == null) {
+ result = RootPanel.get("gwtpage");
+ }
+ return result;
+ }
+
+ private native JavaScriptObject loadResource()/*-{
+ return $wnd.config['resource'];
+ }-*/;
+
+ private native void export(String gwtId, Page page)/*-{
+ $wnd.modules[gwtId]=function() {page.@org.sonar.gwt.ui.Page::onResourceLoad()()};
+ }-*/;
+}
+
diff --git a/sonar-gwt-api/src/main/java/org/sonar/gwt/ui/SourcePanel.java b/sonar-gwt-api/src/main/java/org/sonar/gwt/ui/SourcePanel.java
new file mode 100644
index 00000000000..00f62b6e004
--- /dev/null
+++ b/sonar-gwt-api/src/main/java/org/sonar/gwt/ui/SourcePanel.java
@@ -0,0 +1,336 @@
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2009 SonarSource SA
+ * 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.gwt.ui;
+
+import com.google.gwt.event.dom.client.ClickEvent;
+import com.google.gwt.event.dom.client.ClickHandler;
+import com.google.gwt.user.client.ui.*;
+import com.google.gwt.widgetideas.table.client.PreloadedTable;
+import org.sonar.wsclient.gwt.AbstractCallback;
+import org.sonar.wsclient.gwt.Sonar;
+import org.sonar.wsclient.services.Resource;
+import org.sonar.wsclient.services.Source;
+import org.sonar.wsclient.services.SourceQuery;
+
+import java.util.*;
+
+public abstract class SourcePanel extends Composite implements ClickHandler {
+
+ private static final int MAX_LINES_BY_BLOCK = 3000;
+
+ private final Panel panel = new VerticalPanel();
+ private PreloadedTable rowsTable;
+ private Source source;
+ private final Loading loading = new Loading();
+ private int from = 0;
+ private int length = 0;
+
+ private boolean started = false;
+ private Resource resource;
+ private boolean hasNoSources = false;
+
+ // pagination
+ private Button moreButton = null;
+ private int currentRow = 0;
+ private int offset = 0;
+ private boolean firstPage = true;
+ private boolean previousLineIsDecorated = true;
+ private boolean firstDecoratedLine = true;
+
+ public SourcePanel(Resource resource) {
+ this(resource, 0, 0);
+ }
+
+ public Resource getResource() {
+ return resource;
+ }
+
+ public SourcePanel(Resource resource, int from, int length) {
+ this.from = from;
+ this.length = length;
+ this.resource = resource;
+
+ panel.add(loading);
+ panel.getElement().setId("sourcePanel");
+ initWidget(panel);
+ setStyleName("gwt-SourcePanel");
+
+ loadSources();
+ }
+
+ public void onClick(ClickEvent clickEvent) {
+ if (clickEvent.getSource() == moreButton) {
+ hideMoreButton();
+ displaySource();
+ }
+ }
+
+ public Button getMoreButton() {
+ if (moreButton == null) {
+ moreButton = new Button("More");
+ moreButton.getElement().setId("more_source");
+ moreButton.addClickHandler(this);
+ }
+ return moreButton;
+ }
+
+ public void showMoreButton() {
+ hideMoreButton();
+ panel.add(getMoreButton());
+ }
+
+ public void hideMoreButton() {
+ getMoreButton().removeFromParent();
+ }
+
+
+ public void refresh() {
+ if (!hasNoSources) {
+ panel.clear();
+ panel.add(loading);
+
+ rowsTable = null;
+ currentRow = 0;
+ offset = 0;
+ firstPage = true;
+ previousLineIsDecorated = true;
+ firstDecoratedLine = true;
+ displaySource();
+ }
+ }
+
+ private void loadSources() {
+ Sonar.getInstance().find(SourceQuery.create(resource.getId().toString())
+ .setLinesFromLine(from, length)
+ .setHighlightedSyntax(true), new AbstractCallback<Source>(loading) {
+
+ @Override
+ protected void doOnResponse(Source result) {
+ source = result;
+ displaySource();
+ }
+
+ @Override
+ protected void doOnError(int errorCode, String errorMessage) {
+ if (errorCode == 404) {
+ panel.add(new HTML("<p style=\"padding: 5px\">No sources</p>"));
+ hasNoSources = true;
+ loading.removeFromParent();
+
+ } else if (errorCode == 401) {
+ panel.add(new HTML("<p style=\"padding: 5px\">You're not authorized to view source code</p>"));
+ hasNoSources = true;
+ loading.removeFromParent();
+
+ } else {
+ super.onError(errorCode, errorMessage);
+ }
+ }
+
+ });
+ }
+
+ protected void setStarted() {
+ started = true;
+ displaySource();
+ }
+
+ private void displaySource() {
+ if (started && source != null) {
+ createRowsTable();
+
+ int displayedLines = 0;
+ SortedMap<Integer, String> lines = source.getLinesById().subMap(offset, offset + source.getLinesById().lastKey() + 1);
+ Iterator<Map.Entry<Integer, String>> linesById = lines.entrySet().iterator();
+
+ while (displayedLines < MAX_LINES_BY_BLOCK && linesById.hasNext()) {
+ Map.Entry<Integer, String> entry = linesById.next();
+ Integer lineIndex = entry.getKey();
+ if (shouldDecorateLine(lineIndex)) {
+ if (!previousLineIsDecorated && !firstDecoratedLine) {
+ setRowHtml(0, "<div class='src' style='background-color: #fff;height: 3em; border-top: 1px dashed silver;border-bottom: 1px dashed silver;'> </div>");
+ setRowHtml(1, " ");
+ setRowHtml(2, " ");
+ setRowHtml(3, "<div class='src' style='background-color: #fff;height: 3em; border-top: 1px dashed silver;border-bottom: 1px dashed silver;'> </div>");
+ currentRow++;
+ }
+
+ List<Row> rows = decorateLine(lineIndex, entry.getValue());
+ if (rows != null) {
+ for (Row row : rows) {
+ setRowHtml(0, row.getColumn1());
+ setRowHtml(1, row.getColumn2());
+ setRowHtml(2, row.getColumn3());
+ setRowHtml(3, row.getColumn4());
+ currentRow++;
+ }
+ previousLineIsDecorated = true;
+ firstDecoratedLine = false;
+ }
+ displayedLines++;
+
+ } else {
+ previousLineIsDecorated = false;
+ }
+ offset++;
+ }
+
+ if (firstPage) {
+ panel.clear();
+ panel.add(rowsTable);
+ firstPage = false;
+ }
+
+ if (offset <= source.getLinesById().lastKey()) {
+ showMoreButton();
+ } else {
+ hideMoreButton();
+ }
+ }
+ }
+
+ private void setRowHtml(int colNum, String html) {
+ if (firstPage) {
+ rowsTable.setPendingHTML(currentRow, colNum, html);
+ } else {
+ rowsTable.setHTML(currentRow, colNum, html);
+ }
+ }
+
+ private void createRowsTable() {
+ if (rowsTable == null) {
+ rowsTable = new PreloadedTable();
+ rowsTable.setStyleName("sources code");
+
+ offset = source.getLinesById().firstKey();
+ if (shouldDecorateLine(0)) {
+ List<Row> rows = decorateLine(0, null);
+ if (rows != null) {
+ for (Row row : rows) {
+ rowsTable.setPendingHTML(currentRow, 0, row.getColumn1());
+ rowsTable.setPendingHTML(currentRow, 1, row.getColumn2());
+ rowsTable.setPendingHTML(currentRow, 2, row.getColumn3());
+ rowsTable.setPendingHTML(currentRow, 3, row.getColumn4());
+ currentRow++;
+ }
+ }
+ }
+ }
+ }
+
+ protected boolean shouldDecorateLine(int index) {
+ return true;
+ }
+
+ protected List<Row> decorateLine(int index, String source) {
+ if (index > 0) {
+ return Arrays.asList(new Row(index, source));
+ }
+ return null;
+ }
+
+ public static class Row {
+ protected String column1;
+ protected String column2;
+ protected String column3;
+ protected String column4;
+
+ public Row(String column1, String column2, String column3) {
+ this.column1 = column1;
+ this.column2 = column2;
+ this.column3 = column3;
+ this.column4 = "";
+ }
+
+ public Row(String column1, String column2, String column3, String column4) {
+ this.column1 = column1;
+ this.column2 = column2;
+ this.column3 = column3;
+ this.column4 = column4;
+ }
+
+ public Row(int lineIndex, String source) {
+ setLineIndex(lineIndex, "");
+ unsetValue();
+ setSource(source, "");
+ }
+
+ public Row() {
+ }
+
+ public Row setLineIndex(int index, String style) {
+ column1 = "<div class='ln " + style + "'>" + index + "</div>";
+ return this;
+ }
+
+ public Row setValue(String value, String style) {
+ column2 = "<div class='val " + style + "'>" + value + "</div>";
+ return this;
+ }
+
+ public Row setValue2(String value, String style) {
+ column3 = "<div class='val " + style + "'>" + value + "</div>";
+ return this;
+ }
+
+ public Row unsetValue() {
+ column2 = "";
+ column3 = "";
+ return this;
+ }
+
+ public Row setSource(String source, String style) {
+ column4 = "<div class='src " + style + "'><pre>" + source + "</pre></div>";
+ return this;
+ }
+
+ public String getColumn1() {
+ return column1;
+ }
+
+ public void setColumn1(String column1) {
+ this.column1 = column1;
+ }
+
+ public String getColumn2() {
+ return column2;
+ }
+
+ public void setColumn2(String column2) {
+ this.column2 = column2;
+ }
+
+ public String getColumn3() {
+ return column3;
+ }
+
+ public void setColumn3(String column3) {
+ this.column3 = column3;
+ }
+
+ public String getColumn4() {
+ return column4;
+ }
+
+ public void setColumn4(String column4) {
+ this.column4 = column4;
+ }
+ }
+}
diff --git a/sonar-gwt-api/src/main/java/org/sonar/gwt/ui/ViewerHeader.java b/sonar-gwt-api/src/main/java/org/sonar/gwt/ui/ViewerHeader.java
new file mode 100644
index 00000000000..585b55e6bd9
--- /dev/null
+++ b/sonar-gwt-api/src/main/java/org/sonar/gwt/ui/ViewerHeader.java
@@ -0,0 +1,138 @@
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2009 SonarSource SA
+ * 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.gwt.ui;
+
+import com.google.gwt.user.client.ui.Composite;
+import com.google.gwt.user.client.ui.FlowPanel;
+import com.google.gwt.user.client.ui.HTML;
+import com.google.gwt.user.client.ui.Panel;
+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 abstract class ViewerHeader extends Composite {
+ private String[] metrics;
+ private FlowPanel header;
+
+ public ViewerHeader(Resource resource, String[] metrics) {
+ this.metrics = metrics;
+ header = new FlowPanel();
+ header.setStyleName("gwt-ViewerHeader");
+ initWidget(header);
+ loadMeasures(resource);
+ }
+
+ public String[] getMetrics() {
+ return metrics;
+ }
+
+ private void loadMeasures(Resource resource) {
+ ResourceQuery query = ResourceQuery.createForMetrics(resource.getKey(), metrics).setVerbose(true);
+ Sonar.getInstance().find(query, new AbstractCallback<Resource>() {
+
+ @Override
+ protected void doOnResponse(Resource resource) {
+ display(header, resource);
+ }
+ });
+ }
+
+ protected abstract void display(FlowPanel header, Resource resource);
+
+ protected static class MeasureLabel {
+ private String metricName;
+ private String value;
+
+ public MeasureLabel(Measure measure) {
+ if (measure != null) {
+ this.metricName = measure.getMetricName();
+ this.value = measure.getFormattedValue();
+ }
+ }
+
+ public MeasureLabel(Measure measure, String metricName, String defaultValue) {
+ this.metricName = metricName;
+ if (measure != null) {
+ this.value = measure.getFormattedValue();
+ } else {
+ this.value = defaultValue;
+ }
+ }
+
+ public String getMetricName() {
+ return metricName;
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ public boolean hasValue() {
+ return value != null;
+ }
+ }
+
+ protected void addCell(Panel panel, Measure... measures) {
+ if (measures != null) {
+ String names = "";
+ String values = "";
+ boolean first = true;
+ for (Measure measure : measures) {
+ if (measure != null && measure.getFormattedValue() != null) {
+ if (!first) {
+ names += "<br/>";
+ values += "<br/>";
+ }
+ names += "<b>" + measure.getMetricName() + "</b>: ";
+ values += measure.getFormattedValue();
+ first = false;
+ }
+ }
+
+ if (!first) {
+ HTML html = new HTML(names);
+ html.setStyleName("metric");
+ panel.add(html);
+
+ html = new HTML(values);
+ html.setStyleName("value");
+ panel.add(html);
+ }
+ }
+ }
+
+ protected void addCell(Panel panel, String metric, String value) {
+ HTML html = new HTML(metric);
+ html.setStyleName("metric");
+ panel.add(html);
+
+ html = new HTML(value);
+ html.setStyleName("value");
+ panel.add(html);
+ }
+
+ protected void addBigCell(Panel panel, String html) {
+ HTML htmlDiv = new HTML(html);
+ htmlDiv.setStyleName("big");
+ panel.add(htmlDiv);
+ }
+}
diff --git a/sonar-gwt-api/src/main/java/org/sonar/wsclient/gwt/AbstractCallback.java b/sonar-gwt-api/src/main/java/org/sonar/wsclient/gwt/AbstractCallback.java
new file mode 100644
index 00000000000..853bc0aaedf
--- /dev/null
+++ b/sonar-gwt-api/src/main/java/org/sonar/wsclient/gwt/AbstractCallback.java
@@ -0,0 +1,67 @@
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2009 SonarSource SA
+ * 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.wsclient.gwt;
+
+import com.google.gwt.core.client.JavaScriptObject;
+import com.google.gwt.user.client.ui.Widget;
+import org.sonar.wsclient.services.Model;
+
+public abstract class AbstractCallback<MODEL extends Model> implements Callback<MODEL> {
+
+ private Widget loadingWidget = null;
+
+ protected AbstractCallback(Widget loadingWidget) {
+ this.loadingWidget = loadingWidget;
+ }
+
+ protected AbstractCallback() {
+ }
+
+ public void onResponse(MODEL result, JavaScriptObject json) {
+ hideLoadingWidget();
+ doOnResponse(result);
+ }
+
+ protected abstract void doOnResponse(MODEL result);
+
+ public final void onTimeout() {
+ doOnTimeout();
+ hideLoadingWidget();
+ }
+
+ public final void onError(int errorCode, String errorMessage) {
+ doOnError(errorCode, errorMessage);
+ hideLoadingWidget();
+ }
+
+ protected void doOnError(int errorCode, String errorMessage) {
+
+ }
+
+ protected void doOnTimeout() {
+
+ }
+
+ private void hideLoadingWidget() {
+ if (loadingWidget != null) {
+ loadingWidget.removeFromParent();
+ }
+ }
+} \ No newline at end of file
diff --git a/sonar-gwt-api/src/main/java/org/sonar/wsclient/gwt/AbstractListCallback.java b/sonar-gwt-api/src/main/java/org/sonar/wsclient/gwt/AbstractListCallback.java
new file mode 100644
index 00000000000..2e87908be2f
--- /dev/null
+++ b/sonar-gwt-api/src/main/java/org/sonar/wsclient/gwt/AbstractListCallback.java
@@ -0,0 +1,69 @@
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2009 SonarSource SA
+ * 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.wsclient.gwt;
+
+import com.google.gwt.core.client.JavaScriptObject;
+import com.google.gwt.user.client.ui.Widget;
+import org.sonar.wsclient.services.Model;
+
+import java.util.List;
+
+public abstract class AbstractListCallback<MODEL extends Model> implements ListCallback<MODEL> {
+
+ private Widget loadingWidget = null;
+
+ protected AbstractListCallback(Widget loadingWidget) {
+ this.loadingWidget = loadingWidget;
+ }
+
+ protected AbstractListCallback() {
+ }
+
+ public void onResponse(List<MODEL> result, JavaScriptObject json) {
+ hideLoadingWidget();
+ doOnResponse(result);
+ }
+
+ protected abstract void doOnResponse(List<MODEL> result);
+
+ public final void onTimeout() {
+ doOnTimeout();
+ hideLoadingWidget();
+ }
+
+ public final void onError(int errorCode, String errorMessage) {
+ doOnError(errorCode, errorMessage);
+ hideLoadingWidget();
+ }
+
+ protected void doOnError(int errorCode, String errorMessage) {
+
+ }
+
+ protected void doOnTimeout() {
+
+ }
+
+ private void hideLoadingWidget() {
+ if (loadingWidget != null) {
+ loadingWidget.removeFromParent();
+ }
+ }
+} \ No newline at end of file
diff --git a/sonar-gwt-api/src/main/java/org/sonar/wsclient/gwt/Callback.java b/sonar-gwt-api/src/main/java/org/sonar/wsclient/gwt/Callback.java
new file mode 100644
index 00000000000..35876a99bdc
--- /dev/null
+++ b/sonar-gwt-api/src/main/java/org/sonar/wsclient/gwt/Callback.java
@@ -0,0 +1,33 @@
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2009 SonarSource SA
+ * 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.wsclient.gwt;
+
+import com.google.gwt.core.client.JavaScriptObject;
+import org.sonar.wsclient.services.Model;
+
+public interface Callback<MODEL extends Model> {
+
+ void onResponse(MODEL result, JavaScriptObject json);
+
+ void onTimeout();
+
+ void onError(int errorCode, String errorMessage);
+
+} \ No newline at end of file
diff --git a/sonar-gwt-api/src/main/java/org/sonar/wsclient/gwt/GwtUtils.java b/sonar-gwt-api/src/main/java/org/sonar/wsclient/gwt/GwtUtils.java
new file mode 100644
index 00000000000..8fc7df08fb6
--- /dev/null
+++ b/sonar-gwt-api/src/main/java/org/sonar/wsclient/gwt/GwtUtils.java
@@ -0,0 +1,37 @@
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2009 SonarSource SA
+ * 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.wsclient.gwt;
+
+import com.google.gwt.i18n.client.DateTimeFormat;
+import org.sonar.wsclient.services.WSUtils;
+
+import java.util.Date;
+
+public class GwtUtils extends WSUtils {
+ @Override
+ public String format(Date date, String format) {
+ return DateTimeFormat.getFormat(format).format(date);
+ }
+
+ @Override
+ public String encodeUrl(String url) {
+ return com.google.gwt.http.client.URL.encode(url);
+ }
+}
diff --git a/sonar-gwt-api/src/main/java/org/sonar/wsclient/gwt/ListCallback.java b/sonar-gwt-api/src/main/java/org/sonar/wsclient/gwt/ListCallback.java
new file mode 100644
index 00000000000..9cea18f39c6
--- /dev/null
+++ b/sonar-gwt-api/src/main/java/org/sonar/wsclient/gwt/ListCallback.java
@@ -0,0 +1,33 @@
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2009 SonarSource SA
+ * 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.wsclient.gwt;
+
+import com.google.gwt.core.client.JavaScriptObject;
+import org.sonar.wsclient.services.Model;
+
+import java.util.List;
+
+public interface ListCallback<MODEL extends Model> {
+
+ void onResponse(List<MODEL> result, JavaScriptObject json);
+ void onTimeout();
+ void onError(int errorCode, String errorMessage);
+
+} \ No newline at end of file
diff --git a/sonar-gwt-api/src/main/java/org/sonar/wsclient/gwt/Sonar.java b/sonar-gwt-api/src/main/java/org/sonar/wsclient/gwt/Sonar.java
new file mode 100644
index 00000000000..33f404dd551
--- /dev/null
+++ b/sonar-gwt-api/src/main/java/org/sonar/wsclient/gwt/Sonar.java
@@ -0,0 +1,92 @@
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2009 SonarSource SA
+ * 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.wsclient.gwt;
+
+import com.google.gwt.core.client.JavaScriptObject;
+import com.google.gwt.i18n.client.Dictionary;
+import org.sonar.gwt.JsonUtils;
+import org.sonar.wsclient.gwt.unmarshallers.Unmarshaller;
+import org.sonar.wsclient.gwt.unmarshallers.Unmarshallers;
+import org.sonar.wsclient.services.Model;
+import org.sonar.wsclient.services.Query;
+import org.sonar.wsclient.services.WSUtils;
+
+public class Sonar {
+ static {
+ WSUtils.setInstance(new GwtUtils());
+ }
+
+ private static Sonar instance = null;
+
+ private final String host;
+
+ public Sonar(String host) {
+ this.host = host;
+ }
+
+ /**
+ * To be used in Sonar extensions only, else use constructors.
+ */
+ public static Sonar getInstance() {
+ if (instance == null) {
+ Dictionary dic = Dictionary.getDictionary("config");
+ instance = new Sonar(dic.get("sonar_url"));
+ }
+ return instance;
+ }
+
+ public <MODEL extends Model> void find(final Query<MODEL> query, final Callback<MODEL> callback) {
+ JsonUtils.requestJson(getUrl(query), new JsonUtils.JSONHandler() {
+ public void onResponse(JavaScriptObject obj) {
+ Unmarshaller<MODEL> unmarshaller = Unmarshallers.forModel(query.getModelClass());
+ callback.onResponse(unmarshaller.toModel(obj), obj);
+ }
+
+ public void onTimeout() {
+ callback.onTimeout();
+ }
+
+ public void onError(int errorCode, String errorMessage) {
+ callback.onError(errorCode, errorMessage);
+ }
+ });
+ }
+
+ public <MODEL extends Model> void findAll(final Query<MODEL> query, final ListCallback<MODEL> callback) {
+ JsonUtils.requestJson(getUrl(query), new JsonUtils.JSONHandler() {
+ public void onResponse(JavaScriptObject obj) {
+ Unmarshaller<MODEL> unmarshaller = Unmarshallers.forModel(query.getModelClass());
+ callback.onResponse(unmarshaller.toModels(obj), obj);
+ }
+
+ public void onTimeout() {
+ callback.onTimeout();
+ }
+
+ public void onError(int errorCode, String errorMessage) {
+ callback.onError(errorCode, errorMessage);
+ }
+ });
+ }
+
+ private String getUrl(Query query) {
+ return host + query.getUrl();
+ }
+} \ No newline at end of file
diff --git a/sonar-gwt-api/src/main/java/org/sonar/wsclient/gwt/unmarshallers/AbstractUnmarshaller.java b/sonar-gwt-api/src/main/java/org/sonar/wsclient/gwt/unmarshallers/AbstractUnmarshaller.java
new file mode 100644
index 00000000000..a7a6f835a85
--- /dev/null
+++ b/sonar-gwt-api/src/main/java/org/sonar/wsclient/gwt/unmarshallers/AbstractUnmarshaller.java
@@ -0,0 +1,53 @@
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2009 SonarSource SA
+ * 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.wsclient.gwt.unmarshallers;
+
+import com.google.gwt.core.client.JavaScriptObject;
+import com.google.gwt.json.client.JSONArray;
+import com.google.gwt.json.client.JSONObject;
+import org.sonar.wsclient.services.Model;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public abstract class AbstractUnmarshaller<MODEL extends Model> implements Unmarshaller<MODEL> {
+ public final MODEL toModel(JavaScriptObject json) {
+ JSONArray array = new JSONArray(json);
+ if (array.size() >= 1) {
+ JSONObject elt = array.get(0).isObject();
+ return parse(elt);
+ }
+ return null;
+ }
+
+ public final List<MODEL> toModels(JavaScriptObject json) {
+ List<MODEL> result = new ArrayList<MODEL>();
+ JSONArray array = new JSONArray(json);
+ for (int i = 0; i < array.size(); i++) {
+ JSONObject elt = array.get(i).isObject();
+ if (elt != null) {
+ result.add(parse(elt));
+ }
+ }
+ return result;
+ }
+
+ protected abstract MODEL parse(JSONObject json);
+}
diff --git a/sonar-gwt-api/src/main/java/org/sonar/wsclient/gwt/unmarshallers/DependencyTreeUnmarshaller.java b/sonar-gwt-api/src/main/java/org/sonar/wsclient/gwt/unmarshallers/DependencyTreeUnmarshaller.java
new file mode 100644
index 00000000000..c7c3bb3d29e
--- /dev/null
+++ b/sonar-gwt-api/src/main/java/org/sonar/wsclient/gwt/unmarshallers/DependencyTreeUnmarshaller.java
@@ -0,0 +1,55 @@
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2009 SonarSource SA
+ * 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.wsclient.gwt.unmarshallers;
+
+import com.google.gwt.json.client.JSONArray;
+import com.google.gwt.json.client.JSONObject;
+import org.sonar.gwt.JsonUtils;
+import org.sonar.wsclient.services.DependencyTree;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class DependencyTreeUnmarshaller extends AbstractUnmarshaller<DependencyTree> {
+
+ protected DependencyTree parse(JSONObject json) {
+ DependencyTree tree = new DependencyTree()
+ .setDepId(JsonUtils.getString(json, "did"))
+ .setResourceId(JsonUtils.getString(json, "rid"))
+ .setResourceKey(JsonUtils.getString(json, "k"))
+ .setResourceName(JsonUtils.getString(json, "n"))
+ .setResourceScope(JsonUtils.getString(json, "s"))
+ .setResourceQualifier(JsonUtils.getString(json, "q"))
+ .setResourceVersion(JsonUtils.getString(json, "v"))
+ .setUsage(JsonUtils.getString(json, "u"))
+ .setWeight(JsonUtils.getInteger(json, "w"));
+
+ List<DependencyTree> to = new ArrayList<DependencyTree>();
+ tree.setTo(to);
+
+ JSONArray toJson = (JSONArray) json.get("to");
+ if (toJson != null) {
+ for (int index = 0; index < toJson.size(); index++) {
+ to.add(parse((JSONObject) toJson.get(index)));
+ }
+ }
+ return tree;
+ }
+}
diff --git a/sonar-gwt-api/src/main/java/org/sonar/wsclient/gwt/unmarshallers/DependencyUnmarshaller.java b/sonar-gwt-api/src/main/java/org/sonar/wsclient/gwt/unmarshallers/DependencyUnmarshaller.java
new file mode 100644
index 00000000000..76dd2397eba
--- /dev/null
+++ b/sonar-gwt-api/src/main/java/org/sonar/wsclient/gwt/unmarshallers/DependencyUnmarshaller.java
@@ -0,0 +1,42 @@
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2009 SonarSource SA
+ * 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.wsclient.gwt.unmarshallers;
+
+import com.google.gwt.json.client.JSONObject;
+import org.sonar.gwt.JsonUtils;
+import org.sonar.wsclient.services.Dependency;
+
+public class DependencyUnmarshaller extends AbstractUnmarshaller<Dependency> {
+
+ protected Dependency parse(JSONObject json) {
+ return new Dependency()
+ .setId(JsonUtils.getString(json, "id"))
+ .setFromId(JsonUtils.getDouble(json, "fi").longValue())
+ .setToId(JsonUtils.getDouble(json, "ti").longValue())
+ .setFromKey(JsonUtils.getString(json, "fk"))
+ .setToKey(JsonUtils.getString(json, "tk"))
+ .setUsage(JsonUtils.getString(json, "u"))
+ .setWeight(JsonUtils.getInteger(json, "w"))
+ .setFromName(JsonUtils.getString(json, "fn"))
+ .setFromQualifier(JsonUtils.getString(json, "fq"))
+ .setToName(JsonUtils.getString(json, "tn"))
+ .setToQualifier(JsonUtils.getString(json, "tq"));
+ }
+}
diff --git a/sonar-gwt-api/src/main/java/org/sonar/wsclient/gwt/unmarshallers/MetricUnmarshaller.java b/sonar-gwt-api/src/main/java/org/sonar/wsclient/gwt/unmarshallers/MetricUnmarshaller.java
new file mode 100644
index 00000000000..283f5fe19a9
--- /dev/null
+++ b/sonar-gwt-api/src/main/java/org/sonar/wsclient/gwt/unmarshallers/MetricUnmarshaller.java
@@ -0,0 +1,39 @@
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2009 SonarSource SA
+ * 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.wsclient.gwt.unmarshallers;
+
+import com.google.gwt.json.client.JSONObject;
+import org.sonar.gwt.JsonUtils;
+import org.sonar.wsclient.services.Metric;
+
+public class MetricUnmarshaller extends AbstractUnmarshaller<Metric> {
+
+ protected Metric parse(JSONObject json) {
+ return new Metric()
+ .setKey(JsonUtils.getString(json, "key"))
+ .setName(JsonUtils.getString(json, "name"))
+ .setDomain(JsonUtils.getString(json, "domain"))
+ .setDescription(JsonUtils.getString(json, "description"))
+ .setDirection(JsonUtils.getInteger(json, "direction"))
+ .setType(JsonUtils.getString(json, "val_type"))
+ .setHidden(JsonUtils.getBoolean(json, "hidden"))
+ .setUserManaged(JsonUtils.getBoolean(json, "user_managed"));
+ }
+}
diff --git a/sonar-gwt-api/src/main/java/org/sonar/wsclient/gwt/unmarshallers/PropertyUnmarshaller.java b/sonar-gwt-api/src/main/java/org/sonar/wsclient/gwt/unmarshallers/PropertyUnmarshaller.java
new file mode 100644
index 00000000000..3ff7931a1c8
--- /dev/null
+++ b/sonar-gwt-api/src/main/java/org/sonar/wsclient/gwt/unmarshallers/PropertyUnmarshaller.java
@@ -0,0 +1,33 @@
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2009 SonarSource SA
+ * 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.wsclient.gwt.unmarshallers;
+
+import com.google.gwt.json.client.JSONObject;
+import org.sonar.gwt.JsonUtils;
+import org.sonar.wsclient.services.Property;
+
+public class PropertyUnmarshaller extends AbstractUnmarshaller<Property> {
+
+ protected Property parse(JSONObject json) {
+ return new Property()
+ .setKey(JsonUtils.getString(json, "key"))
+ .setValue(JsonUtils.getString(json, "value"));
+ }
+}
diff --git a/sonar-gwt-api/src/main/java/org/sonar/wsclient/gwt/unmarshallers/ResourceUnmarshaller.java b/sonar-gwt-api/src/main/java/org/sonar/wsclient/gwt/unmarshallers/ResourceUnmarshaller.java
new file mode 100644
index 00000000000..49562c54993
--- /dev/null
+++ b/sonar-gwt-api/src/main/java/org/sonar/wsclient/gwt/unmarshallers/ResourceUnmarshaller.java
@@ -0,0 +1,99 @@
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2009 SonarSource SA
+ * 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.wsclient.gwt.unmarshallers;
+
+import com.google.gwt.json.client.JSONObject;
+import com.google.gwt.json.client.JSONValue;
+import org.sonar.gwt.JsonUtils;
+import org.sonar.wsclient.services.Measure;
+import org.sonar.wsclient.services.Resource;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class ResourceUnmarshaller extends AbstractUnmarshaller<Resource> {
+
+ private static final ResourceUnmarshaller INSTANCE = new ResourceUnmarshaller();
+
+ private ResourceUnmarshaller() {
+ }
+
+ public static ResourceUnmarshaller getInstance() {
+ return INSTANCE;
+ }
+
+ protected Resource parse(JSONObject json) {
+ Resource resource = new Resource();
+ parseResourceFields(json, resource);
+ parseMeasures(json, resource);
+ return resource;
+ }
+
+ private void parseResourceFields(JSONObject json, Resource resource) {
+ resource.setId(JsonUtils.getInteger(json, "id"))
+ .setKey(JsonUtils.getString(json, "key"))
+ .setName(JsonUtils.getString(json, "name"))
+ .setLongName(JsonUtils.getString(json, "lname"))
+ .setScope(JsonUtils.getString(json, "scope"))
+ .setQualifier(JsonUtils.getString(json, "qualifier"))
+ .setLanguage(JsonUtils.getString(json, "lang"))
+ .setVersion(JsonUtils.getString(json, "version"))
+ .setCopy(JsonUtils.getInteger(json, "copy"));
+ }
+
+ private void parseMeasures(JSONObject json, Resource resource) {
+ JSONValue measuresJson = json.get("msr");
+ if (measuresJson != null) {
+ resource.setMeasures(parseMeasures(measuresJson));
+ }
+ }
+
+ private List<Measure> parseMeasures(JSONValue measuresJson) {
+ List<Measure> projectMeasures = new ArrayList<Measure>();
+ int len = JsonUtils.getArraySize(measuresJson);
+ for (int i = 0; i < len; i++) {
+ JSONObject measureJson = JsonUtils.getArray(measuresJson, i);
+ if (measureJson != null) {
+ Measure measure = parseMeasure(measureJson);
+ projectMeasures.add(measure);
+ }
+ }
+ return projectMeasures;
+ }
+
+ private Measure parseMeasure(JSONObject json) {
+ Measure measure = new Measure();
+ measure
+ .setMetricKey(JsonUtils.getString(json, "key"))
+ .setMetricName(JsonUtils.getString(json, "name"))
+ .setValue(JsonUtils.getDouble(json, "val"))
+ .setFormattedValue(JsonUtils.getString(json, "frmt_val"))
+ .setData(JsonUtils.getString(json, "data"))
+ .setTrend(JsonUtils.getInteger(json, "trend"))
+ .setVar(JsonUtils.getInteger(json, "var"))
+ .setRuleKey(JsonUtils.getString(json, "rule_key"))
+ .setRuleName(JsonUtils.getString(json, "rule_name"))
+ .setRuleCategory(JsonUtils.getString(json, "rule_category"))
+ .setRulePriority(JsonUtils.getString(json, "rule_priority"))
+ .setCharacteristicKey(JsonUtils.getString(json, "ctic_key"))
+ .setCharacteristicName(JsonUtils.getString(json, "ctic_name"));
+ return measure;
+ }
+}
diff --git a/sonar-gwt-api/src/main/java/org/sonar/wsclient/gwt/unmarshallers/ServerUnmarshaller.java b/sonar-gwt-api/src/main/java/org/sonar/wsclient/gwt/unmarshallers/ServerUnmarshaller.java
new file mode 100644
index 00000000000..87646fb0305
--- /dev/null
+++ b/sonar-gwt-api/src/main/java/org/sonar/wsclient/gwt/unmarshallers/ServerUnmarshaller.java
@@ -0,0 +1,43 @@
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2009 SonarSource SA
+ * 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.wsclient.gwt.unmarshallers;
+
+import com.google.gwt.core.client.JavaScriptObject;
+import com.google.gwt.json.client.JSONObject;
+import org.sonar.gwt.JsonUtils;
+import org.sonar.wsclient.services.Server;
+
+import java.util.Arrays;
+import java.util.List;
+
+public class ServerUnmarshaller implements Unmarshaller<Server> {
+
+ public Server toModel(JavaScriptObject json) {
+ JSONObject map = new JSONObject(json);
+ return new Server()
+ .setId(JsonUtils.getString(map, "id"))
+ .setVersion(JsonUtils.getString(map, "version"));
+ }
+
+ public List<Server> toModels(JavaScriptObject json) {
+ return Arrays.asList(toModel(json));
+ }
+}
+
diff --git a/sonar-gwt-api/src/main/java/org/sonar/wsclient/gwt/unmarshallers/SourceUnmarshaller.java b/sonar-gwt-api/src/main/java/org/sonar/wsclient/gwt/unmarshallers/SourceUnmarshaller.java
new file mode 100644
index 00000000000..bf2c3ef2f38
--- /dev/null
+++ b/sonar-gwt-api/src/main/java/org/sonar/wsclient/gwt/unmarshallers/SourceUnmarshaller.java
@@ -0,0 +1,42 @@
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2009 SonarSource SA
+ * 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.wsclient.gwt.unmarshallers;
+
+import com.google.gwt.json.client.JSONObject;
+import com.google.gwt.json.client.JSONValue;
+import org.sonar.wsclient.services.Source;
+
+public class SourceUnmarshaller extends AbstractUnmarshaller<Source> {
+
+ protected Source parse(JSONObject json) {
+ Source source = new Source();
+
+ for (String key : json.keySet()) {
+ JSONValue val = json.get(key);
+ if (val.isString() != null) {
+ source.addLine(Integer.parseInt(key), val.isString().stringValue());
+ } else {
+ source.addLine(Integer.parseInt(key), "");
+ }
+ }
+
+ return source;
+ }
+}
diff --git a/sonar-gwt-api/src/main/java/org/sonar/wsclient/gwt/unmarshallers/Unmarshaller.java b/sonar-gwt-api/src/main/java/org/sonar/wsclient/gwt/unmarshallers/Unmarshaller.java
new file mode 100644
index 00000000000..39c5628c302
--- /dev/null
+++ b/sonar-gwt-api/src/main/java/org/sonar/wsclient/gwt/unmarshallers/Unmarshaller.java
@@ -0,0 +1,33 @@
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2009 SonarSource SA
+ * 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.wsclient.gwt.unmarshallers;
+
+import com.google.gwt.core.client.JavaScriptObject;
+import org.sonar.wsclient.services.Model;
+
+import java.util.List;
+
+public interface Unmarshaller<MODEL extends Model> {
+
+ MODEL toModel(JavaScriptObject json);
+
+ List<MODEL> toModels(JavaScriptObject json);
+
+}
diff --git a/sonar-gwt-api/src/main/java/org/sonar/wsclient/gwt/unmarshallers/Unmarshallers.java b/sonar-gwt-api/src/main/java/org/sonar/wsclient/gwt/unmarshallers/Unmarshallers.java
new file mode 100644
index 00000000000..deb77356232
--- /dev/null
+++ b/sonar-gwt-api/src/main/java/org/sonar/wsclient/gwt/unmarshallers/Unmarshallers.java
@@ -0,0 +1,49 @@
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2009 SonarSource SA
+ * 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.wsclient.gwt.unmarshallers;
+
+import org.sonar.wsclient.services.*;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public final class Unmarshallers {
+
+ private Unmarshallers() {
+ }
+
+ private static Map<Class, Unmarshaller> unmarshallers;
+
+ static {
+ unmarshallers = new HashMap<Class, Unmarshaller>();
+ unmarshallers.put(Metric.class, new MetricUnmarshaller());
+ unmarshallers.put(Dependency.class, new DependencyUnmarshaller());
+ unmarshallers.put(Resource.class, ResourceUnmarshaller.getInstance());
+ unmarshallers.put(Property.class, new PropertyUnmarshaller());
+ unmarshallers.put(Source.class, new SourceUnmarshaller());
+ unmarshallers.put(Violation.class, new ViolationUnmarshaller());
+ unmarshallers.put(Server.class, new ServerUnmarshaller());
+ unmarshallers.put(DependencyTree.class, new DependencyTreeUnmarshaller());
+ }
+
+ public static Unmarshaller forModel(Class modelClass) {
+ return unmarshallers.get(modelClass);
+ }
+}
diff --git a/sonar-gwt-api/src/main/java/org/sonar/wsclient/gwt/unmarshallers/ViolationUnmarshaller.java b/sonar-gwt-api/src/main/java/org/sonar/wsclient/gwt/unmarshallers/ViolationUnmarshaller.java
new file mode 100644
index 00000000000..30750eb6782
--- /dev/null
+++ b/sonar-gwt-api/src/main/java/org/sonar/wsclient/gwt/unmarshallers/ViolationUnmarshaller.java
@@ -0,0 +1,49 @@
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2009 SonarSource SA
+ * 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.wsclient.gwt.unmarshallers;
+
+import com.google.gwt.json.client.JSONObject;
+import org.sonar.gwt.JsonUtils;
+import org.sonar.wsclient.services.Violation;
+
+public class ViolationUnmarshaller extends AbstractUnmarshaller<Violation> {
+
+ protected Violation parse(JSONObject json) {
+ Violation violation = new Violation();
+ violation.setMessage(JsonUtils.getString(json, "message"));
+ violation.setLine(JsonUtils.getInteger(json, "line"));
+ violation.setPriority(JsonUtils.getString(json, "priority"));
+
+ JSONObject rule = (JSONObject)json.get("rule");
+ if (rule!=null) {
+ violation.setRuleKey(JsonUtils.getString(rule, "key"));
+ violation.setRuleName(JsonUtils.getString(rule, "name"));
+ }
+
+ JSONObject resource = (JSONObject)json.get("resource");
+ if (resource!=null) {
+ violation.setResourceKey(JsonUtils.getString(resource, "key"));
+ violation.setResourceName(JsonUtils.getString(resource, "name"));
+ violation.setResourceQualifier(JsonUtils.getString(resource, "qualifier"));
+ violation.setResourceScope(JsonUtils.getString(resource, "scope"));
+ }
+ return violation;
+ }
+}
diff --git a/sonar-gwt-api/src/main/resources/org/sonar/Sonar.gwt.xml b/sonar-gwt-api/src/main/resources/org/sonar/Sonar.gwt.xml
new file mode 100644
index 00000000000..ab4d95c0a2c
--- /dev/null
+++ b/sonar-gwt-api/src/main/resources/org/sonar/Sonar.gwt.xml
@@ -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="com.google.gwt.i18n.I18N"/>
+ <inherits name="com.google.gwt.gen2.table.Table"/>
+ <source path="gwt" />
+ <source path="wsclient" />
+</module>
diff --git a/sonar-gwt-api/src/main/resources/org/sonar/gwt/ui/empty.gif b/sonar-gwt-api/src/main/resources/org/sonar/gwt/ui/empty.gif
new file mode 100644
index 00000000000..eef3db1dfe0
--- /dev/null
+++ b/sonar-gwt-api/src/main/resources/org/sonar/gwt/ui/empty.gif
Binary files differ
diff --git a/sonar-gwt-api/src/main/resources/org/sonar/gwt/ui/help.png b/sonar-gwt-api/src/main/resources/org/sonar/gwt/ui/help.png
new file mode 100644
index 00000000000..5c870176d4d
--- /dev/null
+++ b/sonar-gwt-api/src/main/resources/org/sonar/gwt/ui/help.png
Binary files differ
diff --git a/sonar-gwt-api/src/main/resources/org/sonar/gwt/ui/information.png b/sonar-gwt-api/src/main/resources/org/sonar/gwt/ui/information.png
new file mode 100755
index 00000000000..12cd1aef900
--- /dev/null
+++ b/sonar-gwt-api/src/main/resources/org/sonar/gwt/ui/information.png
Binary files differ
diff --git a/sonar-gwt-api/src/main/resources/org/sonar/gwt/ui/javaModule.png b/sonar-gwt-api/src/main/resources/org/sonar/gwt/ui/javaModule.png
new file mode 100644
index 00000000000..ec945247521
--- /dev/null
+++ b/sonar-gwt-api/src/main/resources/org/sonar/gwt/ui/javaModule.png
Binary files differ
diff --git a/sonar-gwt-api/src/main/resources/org/sonar/gwt/ui/priorityBlocker.png b/sonar-gwt-api/src/main/resources/org/sonar/gwt/ui/priorityBlocker.png
new file mode 100644
index 00000000000..70f433a36e7
--- /dev/null
+++ b/sonar-gwt-api/src/main/resources/org/sonar/gwt/ui/priorityBlocker.png
Binary files differ
diff --git a/sonar-gwt-api/src/main/resources/org/sonar/gwt/ui/priorityCritical.png b/sonar-gwt-api/src/main/resources/org/sonar/gwt/ui/priorityCritical.png
new file mode 100644
index 00000000000..cf29106a4a7
--- /dev/null
+++ b/sonar-gwt-api/src/main/resources/org/sonar/gwt/ui/priorityCritical.png
Binary files differ
diff --git a/sonar-gwt-api/src/main/resources/org/sonar/gwt/ui/priorityInfo.png b/sonar-gwt-api/src/main/resources/org/sonar/gwt/ui/priorityInfo.png
new file mode 100644
index 00000000000..8e3f869770b
--- /dev/null
+++ b/sonar-gwt-api/src/main/resources/org/sonar/gwt/ui/priorityInfo.png
Binary files differ
diff --git a/sonar-gwt-api/src/main/resources/org/sonar/gwt/ui/priorityMajor.png b/sonar-gwt-api/src/main/resources/org/sonar/gwt/ui/priorityMajor.png
new file mode 100644
index 00000000000..5958296cd03
--- /dev/null
+++ b/sonar-gwt-api/src/main/resources/org/sonar/gwt/ui/priorityMajor.png
Binary files differ
diff --git a/sonar-gwt-api/src/main/resources/org/sonar/gwt/ui/priorityMinor.png b/sonar-gwt-api/src/main/resources/org/sonar/gwt/ui/priorityMinor.png
new file mode 100644
index 00000000000..cbb05910ba1
--- /dev/null
+++ b/sonar-gwt-api/src/main/resources/org/sonar/gwt/ui/priorityMinor.png
Binary files differ
diff --git a/sonar-gwt-api/src/main/resources/org/sonar/gwt/ui/qualifierClass.png b/sonar-gwt-api/src/main/resources/org/sonar/gwt/ui/qualifierClass.png
new file mode 100644
index 00000000000..b4b3ba28cdf
--- /dev/null
+++ b/sonar-gwt-api/src/main/resources/org/sonar/gwt/ui/qualifierClass.png
Binary files differ
diff --git a/sonar-gwt-api/src/main/resources/org/sonar/gwt/ui/qualifierDirectory.png b/sonar-gwt-api/src/main/resources/org/sonar/gwt/ui/qualifierDirectory.png
new file mode 100644
index 00000000000..19460e913ea
--- /dev/null
+++ b/sonar-gwt-api/src/main/resources/org/sonar/gwt/ui/qualifierDirectory.png
Binary files differ
diff --git a/sonar-gwt-api/src/main/resources/org/sonar/gwt/ui/qualifierField.png b/sonar-gwt-api/src/main/resources/org/sonar/gwt/ui/qualifierField.png
new file mode 100644
index 00000000000..fa7f848c77d
--- /dev/null
+++ b/sonar-gwt-api/src/main/resources/org/sonar/gwt/ui/qualifierField.png
Binary files differ
diff --git a/sonar-gwt-api/src/main/resources/org/sonar/gwt/ui/qualifierFile.png b/sonar-gwt-api/src/main/resources/org/sonar/gwt/ui/qualifierFile.png
new file mode 100644
index 00000000000..b4b3ba28cdf
--- /dev/null
+++ b/sonar-gwt-api/src/main/resources/org/sonar/gwt/ui/qualifierFile.png
Binary files differ
diff --git a/sonar-gwt-api/src/main/resources/org/sonar/gwt/ui/qualifierLibrary.png b/sonar-gwt-api/src/main/resources/org/sonar/gwt/ui/qualifierLibrary.png
new file mode 100644
index 00000000000..ce33d56ee9b
--- /dev/null
+++ b/sonar-gwt-api/src/main/resources/org/sonar/gwt/ui/qualifierLibrary.png
Binary files differ
diff --git a/sonar-gwt-api/src/main/resources/org/sonar/gwt/ui/qualifierMethod.png b/sonar-gwt-api/src/main/resources/org/sonar/gwt/ui/qualifierMethod.png
new file mode 100644
index 00000000000..946d0ff4943
--- /dev/null
+++ b/sonar-gwt-api/src/main/resources/org/sonar/gwt/ui/qualifierMethod.png
Binary files differ
diff --git a/sonar-gwt-api/src/main/resources/org/sonar/gwt/ui/qualifierModule.png b/sonar-gwt-api/src/main/resources/org/sonar/gwt/ui/qualifierModule.png
new file mode 100644
index 00000000000..27d42738e6f
--- /dev/null
+++ b/sonar-gwt-api/src/main/resources/org/sonar/gwt/ui/qualifierModule.png
Binary files differ
diff --git a/sonar-gwt-api/src/main/resources/org/sonar/gwt/ui/qualifierPackage.png b/sonar-gwt-api/src/main/resources/org/sonar/gwt/ui/qualifierPackage.png
new file mode 100644
index 00000000000..0d314a34f5c
--- /dev/null
+++ b/sonar-gwt-api/src/main/resources/org/sonar/gwt/ui/qualifierPackage.png
Binary files differ
diff --git a/sonar-gwt-api/src/main/resources/org/sonar/gwt/ui/qualifierProject.png b/sonar-gwt-api/src/main/resources/org/sonar/gwt/ui/qualifierProject.png
new file mode 100644
index 00000000000..a1b3df1a466
--- /dev/null
+++ b/sonar-gwt-api/src/main/resources/org/sonar/gwt/ui/qualifierProject.png
Binary files differ
diff --git a/sonar-gwt-api/src/main/resources/org/sonar/gwt/ui/qualifierUnitTest.png b/sonar-gwt-api/src/main/resources/org/sonar/gwt/ui/qualifierUnitTest.png
new file mode 100644
index 00000000000..1b0679ae116
--- /dev/null
+++ b/sonar-gwt-api/src/main/resources/org/sonar/gwt/ui/qualifierUnitTest.png
Binary files differ
diff --git a/sonar-gwt-api/src/main/resources/org/sonar/gwt/ui/qualifierView.png b/sonar-gwt-api/src/main/resources/org/sonar/gwt/ui/qualifierView.png
new file mode 100644
index 00000000000..273e8250d38
--- /dev/null
+++ b/sonar-gwt-api/src/main/resources/org/sonar/gwt/ui/qualifierView.png
Binary files differ
diff --git a/sonar-gwt-api/src/main/resources/org/sonar/gwt/ui/statusError.png b/sonar-gwt-api/src/main/resources/org/sonar/gwt/ui/statusError.png
new file mode 100755
index 00000000000..1f12cc9461b
--- /dev/null
+++ b/sonar-gwt-api/src/main/resources/org/sonar/gwt/ui/statusError.png
Binary files differ
diff --git a/sonar-gwt-api/src/main/resources/org/sonar/gwt/ui/statusOk.png b/sonar-gwt-api/src/main/resources/org/sonar/gwt/ui/statusOk.png
new file mode 100755
index 00000000000..e688bd62581
--- /dev/null
+++ b/sonar-gwt-api/src/main/resources/org/sonar/gwt/ui/statusOk.png
Binary files differ
diff --git a/sonar-gwt-api/src/main/resources/org/sonar/gwt/ui/statusWarning.png b/sonar-gwt-api/src/main/resources/org/sonar/gwt/ui/statusWarning.png
new file mode 100755
index 00000000000..4c788c1ba11
--- /dev/null
+++ b/sonar-gwt-api/src/main/resources/org/sonar/gwt/ui/statusWarning.png
Binary files differ
diff --git a/sonar-gwt-api/src/main/resources/org/sonar/gwt/ui/zoom.png b/sonar-gwt-api/src/main/resources/org/sonar/gwt/ui/zoom.png
new file mode 100644
index 00000000000..f1c70db10c5
--- /dev/null
+++ b/sonar-gwt-api/src/main/resources/org/sonar/gwt/ui/zoom.png
Binary files differ