summaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/CorePlugin.java4
-rw-r--r--plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/web/Lcom4Viewer.java (renamed from plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/ui/lcom4/GwtLcom4Tab.java)27
-rw-r--r--plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/web/lcom4_viewer.html.erb85
-rw-r--r--plugins/sonar-design-plugin/pom.xml4
-rw-r--r--plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/DesignPlugin.java2
-rw-r--r--plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/ui/lcom4/client/Data.java52
-rw-r--r--plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/ui/lcom4/client/Lcom4Tab.java105
-rw-r--r--plugins/sonar-design-plugin/src/main/resources/org/sonar/plugins/design/ui/lcom4/Lcom4Tab.gwt.xml8
-rw-r--r--plugins/sonar-design-plugin/src/main/resources/org/sonar/plugins/design/ui/lcom4/Lcom4TabDev.gwt.xml6
-rw-r--r--plugins/sonar-design-plugin/src/main/resources/org/sonar/plugins/design/ui/lcom4/public/lcom4.css23
-rw-r--r--plugins/sonar-design-plugin/src/main/resources/org/sonar/plugins/design/ui/lcom4/public/lcom4.html28
-rw-r--r--plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/core.properties2
12 files changed, 106 insertions, 240 deletions
diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/CorePlugin.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/CorePlugin.java
index 8fa1ac51be7..4299ce8c699 100644
--- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/CorePlugin.java
+++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/CorePlugin.java
@@ -39,6 +39,7 @@ import org.sonar.plugins.core.security.ApplyProjectRolesDecorator;
import org.sonar.plugins.core.sensors.*;
import org.sonar.plugins.core.testdetailsviewer.TestsViewerDefinition;
import org.sonar.plugins.core.timemachine.*;
+import org.sonar.plugins.core.web.Lcom4Viewer;
import org.sonar.plugins.core.widgets.*;
import org.sonar.plugins.core.widgets.reviews.FalsePositiveReviewsWidget;
import org.sonar.plugins.core.widgets.reviews.MyReviewsWidget;
@@ -207,7 +208,7 @@ import java.util.List;
})
public class CorePlugin extends SonarPlugin {
- @SuppressWarnings({ "rawtypes", "unchecked" })
+ @SuppressWarnings({"rawtypes", "unchecked"})
public List getExtensions() {
List extensions = Lists.newLinkedList();
@@ -225,6 +226,7 @@ public class CorePlugin extends SonarPlugin {
// pages
extensions.add(TestsViewerDefinition.class);
extensions.add(Hotspots.class);
+ extensions.add(Lcom4Viewer.class);
// widgets
extensions.add(AlertsWidget.class);
diff --git a/plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/ui/lcom4/GwtLcom4Tab.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/web/Lcom4Viewer.java
index 51eef44558a..60a5f758928 100644
--- a/plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/ui/lcom4/GwtLcom4Tab.java
+++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/web/Lcom4Viewer.java
@@ -17,26 +17,29 @@
* License along with Sonar; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
*/
-package org.sonar.plugins.design.ui.lcom4;
+package org.sonar.plugins.core.web;
-import org.sonar.api.measures.CoreMetrics;
import org.sonar.api.resources.Java;
-import org.sonar.api.resources.Resource;
+import org.sonar.api.resources.Qualifiers;
import org.sonar.api.web.*;
-import org.sonar.plugins.design.ui.lcom4.client.Lcom4Tab;
-@ResourceLanguage(Java.KEY)
-@ResourceQualifier({Resource.QUALIFIER_CLASS})
-@DefaultTab(metrics = {CoreMetrics.LCOM4_KEY})
-@NavigationSection({NavigationSection.RESOURCE_TAB})
+@NavigationSection(NavigationSection.RESOURCE_TAB)
@UserRole(UserRole.CODEVIEWER)
-public class GwtLcom4Tab extends GwtPage {
+@ResourceLanguage(Java.KEY)
+@ResourceQualifier(Qualifiers.CLASS)
+@DefaultTab(metrics = {"lcom4", "lcom4_blocks"})
+public class Lcom4Viewer extends AbstractRubyTemplate implements RubyRailsPage {
+
+ public String getId() {
+ return "lcom4_viewer";
+ }
public String getTitle() {
return "LCOM4";
}
- public String getGwtId() {
- return Lcom4Tab.GWT_ID;
+ @Override
+ protected String getTemplatePath() {
+ return "/org/sonar/plugins/core/web/lcom4_viewer.html.erb";
}
-}
+} \ No newline at end of file
diff --git a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/web/lcom4_viewer.html.erb b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/web/lcom4_viewer.html.erb
new file mode 100644
index 00000000000..6e1a283647c
--- /dev/null
+++ b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/web/lcom4_viewer.html.erb
@@ -0,0 +1,85 @@
+<style type="text/css">
+ table#lcom4blocks {
+ width: 100%;
+ }
+
+ table#lcom4blocks td {
+ vertical-align: top;
+ }
+
+ table#lcom4blocks td.lcom4BlockIndex {
+ font-size: 130%;
+ margin-top: 3px;
+ text-align: center;
+ width: 2em;
+ }
+
+ table.lcom4block {
+ background-color: #EEEEEE;
+ border: 1px solid #CCCCCC;
+ margin-bottom: 15px;
+ width: 100%;
+ }
+
+ table.lcom4block td {
+ height: 22px;
+ line-height: 22px;
+ vertical-align: middle;
+ }
+
+ table.lcom4block td img {
+ vertical-align: middle;
+ }
+
+ table.lcom4block td.lcom4Qualifier {
+ width: 20px;
+ }
+</style>
+
+<%
+ lcom4 = measure('lcom4')
+ lcom4_blocks = measure('lcom4_blocks')
+%>
+<div class="tab_header" id="source_header">
+ <p>
+ <span><%= Metric.by_key('lcom4').description -%>: </span>
+ <span id="m_lcom4" class="big"><%= lcom4 ? number_with_precision(lcom4.value(), :precision => 0) : '-' -%></span>
+ </p>
+</div>
+
+<%
+ if lcom4_blocks && lcom4_blocks.data
+%>
+ <table id="lcom4blocks">
+ <tbody>
+ <%
+ blocks = JSON(lcom4_blocks.data)
+ blocks.each_with_index do |block, index|
+ %>
+ <tr id="lcom4block_<%= index+1 -%>">
+ <td class="lcom4BlockIndex">
+ <%= index+1 -%>
+ </td>
+ <td>
+ <table cellspacing="0" cellpadding="0" class="lcom4block">
+ <tbody>
+ <% block.each do |hash| %>
+ <tr id="">
+ <td align="left" class="lcom4Qualifier">
+ <%= image_tag "q/#{hash['q']}.png" -%>
+ </td>
+ <td><%= hash['n'] -%></td>
+ </tr>
+ <% end %>
+ </tbody>
+ </table>
+ </td>
+ </tr>
+ <%
+ end
+ %>
+ </tbody>
+ </table>
+<%
+ end
+%> \ No newline at end of file
diff --git a/plugins/sonar-design-plugin/pom.xml b/plugins/sonar-design-plugin/pom.xml
index 6961f66435a..b73ceecdbd4 100644
--- a/plugins/sonar-design-plugin/pom.xml
+++ b/plugins/sonar-design-plugin/pom.xml
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.codehaus.sonar</groupId>
@@ -73,7 +74,6 @@
<execution>
<configuration>
<modules>
- <module>org.sonar.plugins.design.ui.lcom4.Lcom4Tab${gwt.permutationSuffix}</module>
<module>org.sonar.plugins.design.ui.page.DesignPage${gwt.permutationSuffix}</module>
<module>org.sonar.plugins.design.ui.dependencies.DependenciesTab${gwt.permutationSuffix}</module>
<module>org.sonar.plugins.design.ui.libraries.LibrariesPage${gwt.permutationSuffix}</module>
diff --git a/plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/DesignPlugin.java b/plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/DesignPlugin.java
index ac392718a4f..c4a8aabe8e8 100644
--- a/plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/DesignPlugin.java
+++ b/plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/DesignPlugin.java
@@ -23,7 +23,6 @@ import com.google.common.collect.Lists;
import org.sonar.api.SonarPlugin;
import org.sonar.plugins.design.batch.*;
import org.sonar.plugins.design.ui.dependencies.GwtDependenciesTab;
-import org.sonar.plugins.design.ui.lcom4.GwtLcom4Tab;
import org.sonar.plugins.design.ui.libraries.GwtLibrariesPage;
import org.sonar.plugins.design.ui.page.GwtDesignPage;
import org.sonar.plugins.design.ui.widgets.ChidamberKemererWidget;
@@ -51,7 +50,6 @@ public class DesignPlugin extends SonarPlugin {
extensions.add(FileDesignWidget.class);
extensions.add(PackageDesignWidget.class);
extensions.add(ChidamberKemererWidget.class);
- extensions.add(GwtLcom4Tab.class);
return extensions;
}
diff --git a/plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/ui/lcom4/client/Data.java b/plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/ui/lcom4/client/Data.java
deleted file mode 100644
index 76ee31729f2..00000000000
--- a/plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/ui/lcom4/client/Data.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Sonar, open source software quality management tool.
- * Copyright (C) 2008-2011 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * Sonar is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * Sonar is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Sonar; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
- */
-package org.sonar.plugins.design.ui.lcom4.client;
-
-import com.google.gwt.core.client.JavaScriptObject;
-
-public final class Data {
-
- public static class Entity extends JavaScriptObject {
- // Overlay types always have protected, zero-arg ctors
- protected Entity() {
- }
-
- public final native String getName() /*-{ return this.n; }-*/;
- public final native String getQualifier() /*-{ return this.q; }-*/;
- }
-
- public static class Block extends JavaScriptObject {
- protected Block() {
- }
- public final native int size() /*-{ return this.length; }-*/;
- public final native Entity get(int i) /*-{ return this[i]; }-*/;
- }
-
- public static class Blocks extends JavaScriptObject {
- protected Blocks() {
- }
- public final native int size() /*-{ return this.length; }-*/;
- public final native Block get(int i) /*-{ return this[i]; }-*/;
- }
-
- public static native Blocks parse(String json) /*-{
- return eval('(' + json + ')')
- }-*/;
-}
diff --git a/plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/ui/lcom4/client/Lcom4Tab.java b/plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/ui/lcom4/client/Lcom4Tab.java
deleted file mode 100644
index b9aaba09578..00000000000
--- a/plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/ui/lcom4/client/Lcom4Tab.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * Sonar, open source software quality management tool.
- * Copyright (C) 2008-2011 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * Sonar is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * Sonar is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Sonar; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
- */
-package org.sonar.plugins.design.ui.lcom4.client;
-
-import com.google.gwt.i18n.client.Dictionary;
-import com.google.gwt.user.client.ui.*;
-import org.sonar.gwt.ui.Icons;
-import org.sonar.gwt.ui.Loading;
-import org.sonar.gwt.ui.Page;
-import org.sonar.wsclient.gwt.AbstractCallback;
-import org.sonar.wsclient.gwt.Sonar;
-import org.sonar.wsclient.services.Resource;
-import org.sonar.wsclient.services.ResourceQuery;
-
-public class Lcom4Tab extends Page {
- public static final String GWT_ID = "org.sonar.plugins.design.ui.lcom4.Lcom4Tab";
-
- private VerticalPanel panel;
-
- @Override
- protected Widget doOnResourceLoad(Resource resource) {
- panel = new VerticalPanel();
- panel.setWidth("100%");
- loadData(resource);
- return panel;
- }
-
- private void loadData(Resource resource) {
- panel.add(new Loading());
- ResourceQuery query = ResourceQuery.createForMetrics(resource.getId().toString(), "lcom4", "lcom4_blocks");
- Sonar.getInstance().find(query, new AbstractCallback<Resource>() {
- @Override
- protected void doOnResponse(Resource resource) {
- panel.clear();
- panel.add(new Header(resource));
- if (resource != null && resource.getMeasure("lcom4_blocks") != null) {
- String json = resource.getMeasure("lcom4_blocks").getData();
- Data.Blocks blocks = Data.parse(json);
-
- Grid grid = new Grid(blocks.size(), 2);
- grid.setStyleName("lcom4blocks");
- grid.getColumnFormatter().setStyleName(0, "index");
-
- for (int indexBlock = 0; indexBlock < blocks.size(); indexBlock++) {
- Data.Block block = blocks.get(indexBlock);
- grid.setHTML(indexBlock, 0, "<div class='index'>" + (indexBlock + 1) + "</div>");
-
- VerticalPanel blockPanel = new VerticalPanel();
- blockPanel.setStyleName("lcom4block");
-
- for (int indexEntity = 0; indexEntity < block.size(); indexEntity++) {
- Data.Entity entity = block.get(indexEntity);
- HTML row = new HTML(Icons.forQualifier(entity.getQualifier()).getHTML() + " " + entity.getName());
- row.setStyleName("lcom4row");
- blockPanel.add(row);
- }
- grid.setWidget(indexBlock, 1, blockPanel);
-
- }
- panel.add(grid);
- }
- }
- });
- }
-
- private static class Header extends Composite {
- private FlowPanel header;
-
- public Header(Resource resource) {
- header = new FlowPanel();
- header.setStyleName("gwt-ViewerHeader");
-
- HorizontalPanel panel = new HorizontalPanel();
- HTML html = new HTML(Dictionary.getDictionary("l10n").get("lcom4.metric") + ": ");
- html.setStyleName("metric");
- panel.add(html);
-
- if (resource != null) {
- html = new HTML(resource.getMeasureFormattedValue("lcom4", "-"));
- html.setStyleName("value");
- panel.add(html);
- }
-
- header.add(panel);
- initWidget(header);
- }
- }
-}
diff --git a/plugins/sonar-design-plugin/src/main/resources/org/sonar/plugins/design/ui/lcom4/Lcom4Tab.gwt.xml b/plugins/sonar-design-plugin/src/main/resources/org/sonar/plugins/design/ui/lcom4/Lcom4Tab.gwt.xml
deleted file mode 100644
index 124aa37c47d..00000000000
--- a/plugins/sonar-design-plugin/src/main/resources/org/sonar/plugins/design/ui/lcom4/Lcom4Tab.gwt.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-<module>
- <inherits name="com.google.gwt.user.User"/>
- <inherits name="com.google.gwt.json.JSON"/>
- <inherits name="com.google.gwt.http.HTTP"/>
- <inherits name="org.sonar.Sonar"/>
- <stylesheet src="lcom4.css"/>
- <entry-point class="org.sonar.plugins.design.ui.lcom4.client.Lcom4Tab"/>
-</module>
diff --git a/plugins/sonar-design-plugin/src/main/resources/org/sonar/plugins/design/ui/lcom4/Lcom4TabDev.gwt.xml b/plugins/sonar-design-plugin/src/main/resources/org/sonar/plugins/design/ui/lcom4/Lcom4TabDev.gwt.xml
deleted file mode 100644
index c4f98f07a4c..00000000000
--- a/plugins/sonar-design-plugin/src/main/resources/org/sonar/plugins/design/ui/lcom4/Lcom4TabDev.gwt.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-<module rename-to="org.sonar.plugins.design.ui.lcom4.Lcom4Tab">
- <inherits name="org.sonar.plugins.design.ui.lcom4.Lcom4Tab"/>
- <inherits name="org.sonar.SonarDev"/>
-
- <entry-point class="org.sonar.plugins.design.ui.lcom4.client.Lcom4Tab"/>
-</module>
diff --git a/plugins/sonar-design-plugin/src/main/resources/org/sonar/plugins/design/ui/lcom4/public/lcom4.css b/plugins/sonar-design-plugin/src/main/resources/org/sonar/plugins/design/ui/lcom4/public/lcom4.css
deleted file mode 100644
index bbd35eb6237..00000000000
--- a/plugins/sonar-design-plugin/src/main/resources/org/sonar/plugins/design/ui/lcom4/public/lcom4.css
+++ /dev/null
@@ -1,23 +0,0 @@
-.lcom4blocks {
- width: 100%;
- margin-top: 10px;
-}
-.lcom4blocks td {
- vertical-align: top;
-}
-.lcom4blocks .index {
- font-size: 130%;
- text-align: center;
- width: 2em;
- margin-top: 3px;
-}
-.lcom4block {
- width: 100%;
- border: 1px solid #ccc;
- margin-bottom: 15px;
- background-color: #eee;
-}
-.lcom4row {
- padding: 2px 5px;
- word-wrap:break-word;
-} \ No newline at end of file
diff --git a/plugins/sonar-design-plugin/src/main/resources/org/sonar/plugins/design/ui/lcom4/public/lcom4.html b/plugins/sonar-design-plugin/src/main/resources/org/sonar/plugins/design/ui/lcom4/public/lcom4.html
deleted file mode 100644
index 8ae47cdd1c0..00000000000
--- a/plugins/sonar-design-plugin/src/main/resources/org/sonar/plugins/design/ui/lcom4/public/lcom4.html
+++ /dev/null
@@ -1,28 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
- "http://www.w3.org/TR/html4/loose.dtd">
-
-<html>
-<head>
- <meta http-equiv="content-type" content="text/html; charset=UTF-8">
- <meta name="gwt:property" content="locale=fr_CH">
-
- <title>LCOM4</title>
- <link href="http://localhost:9000/stylesheets/sonar.css" media="all" rel="Stylesheet" type="text/css" />
- <script src="http://localhost:9000/javascripts/sonar.js" type="text/javascript"></script>
-</head>
-
-<body>
-<h1>LCOM4</h1>
-<div id="gwtpage">
-</div>
-<script type="text/javascript">
-var config = {
- "sonar_url": "http://localhost:9000",
- "metric":"lcom4",
- "resource":[{"id":11, "key":"org.apache.struts:struts-core:org.apache.struts.action.Action","scope": "FIL", "qualifier": "CLA", "name": "ActionServlet", "lang":"java"}]
-};
- var modules = {};
-</script>
-<script type="text/javascript" language="javascript" src="org.sonar.plugins.design.ui.lcom4.Lcom4Tab.nocache.js"></script>
-</body>
-</html> \ No newline at end of file
diff --git a/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/core.properties b/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/core.properties
index 18c84fe77ab..dae06377828 100644
--- a/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/core.properties
+++ b/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/core.properties
@@ -299,6 +299,7 @@ users.page=Users
violations.page=Violations
violations_drilldown.page=Violations Drilldown
update_center.page=Update Center
+lcom4_viewer.page=LCOM4
# GWT pages
@@ -306,7 +307,6 @@ org.sonar.plugins.core.hotspots.GwtHotspots.page=Hotspots
org.sonar.plugins.design.ui.page.DesignPage.page=Design
org.sonar.plugins.design.ui.libraries.LibrariesPage.page=Libraries
org.sonar.plugins.design.ui.dependencies.DependenciesTab.page=Dependencies
-org.sonar.plugins.design.ui.lcom4.Lcom4Tab.page=LCOM4
#------------------------------------------------------------------------------