diff options
author | Fabrice Bellingard <bellingard@gmail.com> | 2011-10-26 19:47:20 +0200 |
---|---|---|
committer | Fabrice Bellingard <bellingard@gmail.com> | 2011-10-26 19:47:20 +0200 |
commit | 911c66cab3137ba840b856a4750088ea6709064f (patch) | |
tree | 08a88b2635bca5782e4c6e891e2b29f78231abbe /plugins/sonar-core-gwt | |
parent | eb20690f5b006f2e9a1bcb39b5797db19b1c75b2 (diff) | |
download | sonarqube-911c66cab3137ba840b856a4750088ea6709064f.tar.gz sonarqube-911c66cab3137ba840b856a4750088ea6709064f.zip |
SONAR-2733 Fix unit test and remove useless code
Diffstat (limited to 'plugins/sonar-core-gwt')
7 files changed, 0 insertions, 366 deletions
diff --git a/plugins/sonar-core-gwt/pom.xml b/plugins/sonar-core-gwt/pom.xml index 75e85715f22..ee0d9c4cd20 100644 --- a/plugins/sonar-core-gwt/pom.xml +++ b/plugins/sonar-core-gwt/pom.xml @@ -59,7 +59,6 @@ <execution> <configuration> <modules> - <module>org.sonar.plugins.core.duplicationsviewer.DuplicationsViewer${gwt.permutationSuffix}</module> <module>org.sonar.plugins.core.testdetailsviewer.TestsViewer${gwt.permutationSuffix}</module> <module>org.sonar.plugins.core.hotspots.GwtHotspots${gwt.permutationSuffix}</module> </modules> diff --git a/plugins/sonar-core-gwt/src/main/java/org/sonar/plugins/core/duplicationsviewer/client/DuplicationsPanel.java b/plugins/sonar-core-gwt/src/main/java/org/sonar/plugins/core/duplicationsviewer/client/DuplicationsPanel.java deleted file mode 100644 index 681205f4679..00000000000 --- a/plugins/sonar-core-gwt/src/main/java/org/sonar/plugins/core/duplicationsviewer/client/DuplicationsPanel.java +++ /dev/null @@ -1,174 +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.core.duplicationsviewer.client; - -import com.google.gwt.i18n.client.Dictionary; -import org.sonar.gwt.Metrics; -import org.sonar.gwt.ui.DefaultSourcePanel; -import org.sonar.gwt.ui.ExpandCollapseLink; -import org.sonar.gwt.ui.Loading; -import org.sonar.gwt.ui.SourcePanel; - -import com.google.gwt.gen2.table.override.client.FlexTable; -import com.google.gwt.gen2.table.override.client.FlexTable.FlexCellFormatter; -import com.google.gwt.user.client.ui.Composite; -import com.google.gwt.user.client.ui.Panel; -import com.google.gwt.user.client.ui.VerticalPanel; -import com.google.gwt.xml.client.Document; -import com.google.gwt.xml.client.Element; -import com.google.gwt.xml.client.NodeList; -import com.google.gwt.xml.client.XMLParser; -import org.sonar.wsclient.gwt.AbstractCallback; -import org.sonar.wsclient.gwt.Sonar; -import org.sonar.wsclient.services.Measure; -import org.sonar.wsclient.services.Resource; -import org.sonar.wsclient.services.ResourceQuery; - -public class DuplicationsPanel extends Composite { - - private final Panel panel; - private Loading loading; - - public DuplicationsPanel(Resource resource) { - panel = new VerticalPanel(); - loading = new Loading(); - panel.add(loading); - initWidget(panel); - setStyleName("gwt-DuplicationsPanel"); - getElement().setId("gwt-DuplicationsPanel"); - - loadDuplications(resource); - } - - public void loadDuplications(Resource resource) { - ResourceQuery query = ResourceQuery.createForResource(resource, Metrics.DUPLICATIONS_DATA); - Sonar.getInstance().find(query, new DuplicationCallback()); - } - - private class DuplicationCallback extends AbstractCallback<Resource> { - - public DuplicationCallback() { - super(loading); - } - - @Override - protected void doOnResponse(Resource resource) { - loading.removeFromParent(); - String duplications = null; - if (resource != null) { - Measure data = resource.getMeasure(Metrics.DUPLICATIONS_DATA); - if (data != null) { - duplications = data.getData(); - } - } - if (duplications != null) { - processDuplications(duplications, resource); - } - } - - private void processDuplications(String duplicationXMLData, Resource resource) { - Document parsed = XMLParser.parse(duplicationXMLData); - NodeList duplicationsXML = parsed.getElementsByTagName("duplication"); - - FlexTable table = getDuplicationsTable(); - - panel.add(table); - int rowCounter = 1; - - String projectKey = resource.getKey().substring(0, resource.getKey().lastIndexOf(':')); - for (int i = 0; i < duplicationsXML.getLength(); i++) { - Element duplicationXML = (Element) duplicationsXML.item(i); - String lines = duplicationXML.getAttribute("lines"); - String startLine = duplicationXML.getAttribute("start"); - String targetStartLine = duplicationXML.getAttribute("target-start"); - String targetResourceKey = duplicationXML.getAttribute("target-resource"); - renderDuplication(rowCounter, i, table, lines, startLine, targetStartLine, targetResourceKey, resource, projectKey); - rowCounter+=2; - } - } - - private FlexTable getDuplicationsTable() { - Dictionary l10n = Dictionary.getDictionary("l10n"); - FlexTable table = new FlexTable(); - table.setStylePrimaryName("duplicationsTable"); - table.setText(0, 0, ""); - table.setText(0, 1, l10n.get("dupl.colSize")); - table.setText(0, 2, l10n.get("dupl.colFromLine")); - table.setText(0, 3, l10n.get("dupl.colFile")); - table.setText(0, 4, l10n.get("dupl.colFromLine")); - - table.getCellFormatter().getElement(0, 0).setId("expandCollapseCol"); - table.getCellFormatter().getElement(0, 1).setId("nbLineCol"); - table.getCellFormatter().getElement(0, 2).setId("lineFromCol"); - table.getCellFormatter().getElement(0, 3).setId("fileCol"); - - setRowStyle(0, table, "header", false); - return table; - } - - private void renderDuplication(int row, int duplicationCounter, FlexTable table, String lines, String startLine, String targetStartLine, String targetResourceKey, final Resource resource, String projectKey) { - String style = (duplicationCounter % 2 == 0) ? "odd" : "even"; - - SourcePanel src = new DefaultSourcePanel(resource, new Integer(startLine), new Integer(lines)); - src.getElement().setId("source-panel-" + targetResourceKey.replace('.', '_')); - src.setVisible(false); - - ExpandCollapseLink link = new ExpandCollapseLink(src); - - table.setWidget(row, 0, link); - table.setText(row, 1, lines); - table.setText(row, 2, startLine); - if (targetResourceKey.equals(resource.getKey())) { - targetResourceKey = "Same file"; - } - if (targetResourceKey.contains(":")) { - int i = targetResourceKey.lastIndexOf(':'); - String targetProjectKey = targetResourceKey.substring(0, i); - String targetFileKey = targetResourceKey.substring(i + 1); - if (targetProjectKey.equals(projectKey)) { - // same project - targetResourceKey = targetFileKey; - } else { - // another project - targetResourceKey = targetProjectKey + "<br/>" + targetFileKey; - } - } - table.setHTML(row, 3, targetResourceKey); - table.setText(row, 4, targetStartLine); - setRowStyle(row, table, style, false); - - FlexCellFormatter frmt = (FlexCellFormatter)table.getCellFormatter(); - frmt.setColSpan(row + 1, 1, 4); - table.setWidget(row + 1, 1, src); - setRowStyle(row + 1, table, style, true); - - } - - private void setRowStyle(int row, FlexTable table, String style, boolean isPanelRow) { - table.getCellFormatter().setStyleName(row, 0, style); - table.getCellFormatter().setStyleName(row, 1, style); - if (!isPanelRow) { - table.getCellFormatter().setStyleName(row, 2, style); - table.getCellFormatter().setStyleName(row, 3, style); - table.getCellFormatter().setStyleName(row, 4, style); - } - } - } -} diff --git a/plugins/sonar-core-gwt/src/main/java/org/sonar/plugins/core/duplicationsviewer/client/DuplicationsViewer.java b/plugins/sonar-core-gwt/src/main/java/org/sonar/plugins/core/duplicationsviewer/client/DuplicationsViewer.java deleted file mode 100644 index a25c5888fa3..00000000000 --- a/plugins/sonar-core-gwt/src/main/java/org/sonar/plugins/core/duplicationsviewer/client/DuplicationsViewer.java +++ /dev/null @@ -1,81 +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.core.duplicationsviewer.client; - -import com.google.gwt.i18n.client.Dictionary; -import com.google.gwt.user.client.ui.FlowPanel; -import com.google.gwt.user.client.ui.HorizontalPanel; -import com.google.gwt.user.client.ui.Panel; -import com.google.gwt.user.client.ui.Widget; -import org.sonar.gwt.Metrics; -import org.sonar.gwt.ui.Page; -import org.sonar.gwt.ui.ViewerHeader; -import org.sonar.wsclient.services.Measure; -import org.sonar.wsclient.services.Resource; - -public class DuplicationsViewer extends Page { - - public static final String GWT_ID = "org.sonar.plugins.core.duplicationsviewer.DuplicationsViewer"; - - @Override - protected Widget doOnResourceLoad(Resource resource) { - FlowPanel panel = new FlowPanel(); - panel.setWidth("100%"); - panel.add(new DuplicationsHeader(resource)); - panel.add(new DuplicationsPanel(resource)); - return panel; - } - - private static class DuplicationsHeader extends ViewerHeader { - public DuplicationsHeader(Resource resource) { - super(resource, new String[]{Metrics.DUPLICATED_LINES_DENSITY, Metrics.LINES, Metrics.DUPLICATED_LINES, Metrics.DUPLICATED_BLOCKS}); - } - - @Override - protected void display(FlowPanel header, Resource resource) { - Panel panel = new HorizontalPanel(); - header.add(panel); - - Measure measure = resource.getMeasure(Metrics.DUPLICATED_LINES_DENSITY); - if (measure == null) { - addBigCell(panel, "0"); - } else { - addBigCell(panel, measure.getFormattedValue()); - } - - Dictionary l10n = Dictionary.getDictionary("l10n"); - addCell(panel, getDefaultMeasure(resource, Metrics.LINES, l10n.get("dupl.lines"))); - addCell(panel, getDefaultMeasure(resource, Metrics.DUPLICATED_LINES, l10n.get("dupl.duplicated_lines"))); - addCell(panel, getDefaultMeasure(resource, Metrics.DUPLICATED_BLOCKS, l10n.get("dupl.duplicated_blocks"))); - } - - private Measure getDefaultMeasure(Resource resource, String metric, String label) { - Measure measure = resource.getMeasure(metric); - if (measure == null || measure.getValue() == null) { - measure = new Measure(); - measure.setMetricName(label); - measure.setValue(0.0); - measure.setFormattedValue("0"); - } - return measure; - } - } - -} diff --git a/plugins/sonar-core-gwt/src/main/resources/org/sonar/plugins/core/duplicationsviewer/DuplicationsViewer.gwt.xml b/plugins/sonar-core-gwt/src/main/resources/org/sonar/plugins/core/duplicationsviewer/DuplicationsViewer.gwt.xml deleted file mode 100644 index b480cc0b418..00000000000 --- a/plugins/sonar-core-gwt/src/main/resources/org/sonar/plugins/core/duplicationsviewer/DuplicationsViewer.gwt.xml +++ /dev/null @@ -1,13 +0,0 @@ -<module> - <inherits name="com.google.gwt.xml.XML"/> - <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"/> - <inherits name="com.google.gwt.gen2.table.Table"/> - - <stylesheet src="DuplicationsViewer.css"/> - - <entry-point class="org.sonar.plugins.core.duplicationsviewer.client.DuplicationsViewer"/> - -</module> diff --git a/plugins/sonar-core-gwt/src/main/resources/org/sonar/plugins/core/duplicationsviewer/DuplicationsViewerDev.gwt.xml b/plugins/sonar-core-gwt/src/main/resources/org/sonar/plugins/core/duplicationsviewer/DuplicationsViewerDev.gwt.xml deleted file mode 100644 index d3a0ffd3806..00000000000 --- a/plugins/sonar-core-gwt/src/main/resources/org/sonar/plugins/core/duplicationsviewer/DuplicationsViewerDev.gwt.xml +++ /dev/null @@ -1,6 +0,0 @@ -<module rename-to="org.sonar.plugins.core.duplicationsviewer.DuplicationsViewer"> - <inherits name="org.sonar.plugins.core.duplicationsviewer.DuplicationsViewer"/> - <inherits name="org.sonar.SonarDev"/> - - <entry-point class="org.sonar.plugins.core.duplicationsviewer.client.DuplicationsViewer"/> -</module> diff --git a/plugins/sonar-core-gwt/src/main/resources/org/sonar/plugins/core/duplicationsviewer/public/DuplicationsViewer.css b/plugins/sonar-core-gwt/src/main/resources/org/sonar/plugins/core/duplicationsviewer/public/DuplicationsViewer.css deleted file mode 100644 index 2cc0ced131c..00000000000 --- a/plugins/sonar-core-gwt/src/main/resources/org/sonar/plugins/core/duplicationsviewer/public/DuplicationsViewer.css +++ /dev/null @@ -1,48 +0,0 @@ -.gwt-DuplicationsPanel { - width: 100%; -} - -.duplicationsTable { - border: 1px solid #C0C0C0; - width: 100%; - vertical-align: top; -} - -.duplicationsTable td { - vertical-align: top; - text-align: left; - padding: 3px; - white-space: nowrap; -} - -.duplicationsTable #expandCollapseCol { - width: 60px; -} - -.duplicationsTable #nbLineCol { - width: 80px; -} - -.duplicationsTable #lineFromCol { - width: 80px; -} - -.duplicationsTable #fileCol { - width: 80px; -} - -.duplicationsTable .header { - background-color: #EFEFEF; - font-weight: bold; - color: #333; - vertical-align: top; -} - -.expandCollapseLink { - margin-left: 5px; -} - -.gwt-SourcePanel table.sources td { - vertical-align: top; - padding: 0px; -}
\ No newline at end of file diff --git a/plugins/sonar-core-gwt/src/main/resources/org/sonar/plugins/core/duplicationsviewer/public/test.html b/plugins/sonar-core-gwt/src/main/resources/org/sonar/plugins/core/duplicationsviewer/public/test.html deleted file mode 100644 index 37b1bb43253..00000000000 --- a/plugins/sonar-core-gwt/src/main/resources/org/sonar/plugins/core/duplicationsviewer/public/test.html +++ /dev/null @@ -1,43 +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"> - <title>Duplications</title> - <link href="http://localhost:9000/dev/stylesheets/yui-2.6.0.css" media="all" rel="Stylesheet" type="text/css"/> - <link href="http://localhost:9000/dev/stylesheets/style.css" media="all" rel="Stylesheet" type="text/css"/> - <script src="http://localhost:9000/dev/javascripts/application.js" type="text/javascript"></script> - <script src="http://localhost:9000/dev/javascripts/prototype.js" type="text/javascript"></script> - <script src="http://localhost:9000/dev/javascripts/scriptaculous.js" type="text/javascript"></script> -</head> - -<body> -<script type="text/javascript"> - var registeredTabs = []; - var config = { - "sonar_url": "http://localhost:9000/dev", - "viewer_resource_key" : "org.sonar.tests:reference:org.sonar.samples.duplicated_lines_within_same_class.DuplicatedLinesInSameClass" - }; - - -</script> -<div class="error" id="error" style="display:none"><span id="errormsg"></span> [<a href="#" - onclick="javascript:$('error').hide();return false;">hide</a>] -</div> -<div class="warning" id="warning" style="display:none"><span id="warningmsg"></span> [<a href="#" - onclick="javascript:$('warning').hide();return false;">hide</a>] -</div> -<div class="notice" id="info" style="display:none"><span id="infomsg"></span> [<a href="#" - onclick="javascript:$('info').hide();return false;">hide</a>] -</div> - -<div id="resource_viewers"> - <div id='loading'></div> -</div> -<script type="text/javascript" language="javascript" - src="org.sonar.plugins.core.duplicationsviewer.DuplicationsViewer.nocache.js"></script> - -<a href="#" onclick="load_org_sonar_plugins_core_duplicationsviewer_DuplicationsViewer();">load</a> -</body> -</html>
\ No newline at end of file |