From da60f0621e41a441bc67e522ac2ead3648bd06ad Mon Sep 17 00:00:00 2001 From: Evgeny Mandrikov Date: Fri, 2 Sep 2011 12:07:41 +0400 Subject: [PATCH] SONAR-2752 Improve UI to show duplications with other projects --- .../client/DuplicationsPanel.java | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) 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 index cad1b96cbc3..681205f4679 100644 --- 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 @@ -91,13 +91,15 @@ public class DuplicationsPanel extends Composite { 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); + renderDuplication(rowCounter, i, table, lines, startLine, targetStartLine, targetResourceKey, resource, projectKey); rowCounter+=2; } } @@ -121,7 +123,7 @@ public class DuplicationsPanel extends Composite { return table; } - private void renderDuplication(int row, int duplicationCounter, FlexTable table, String lines, String startLine, String targetStartLine, String targetResourceKey, final Resource resource) { + 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)); @@ -137,9 +139,18 @@ public class DuplicationsPanel extends Composite { targetResourceKey = "Same file"; } if (targetResourceKey.contains(":")) { - targetResourceKey = targetResourceKey.substring(targetResourceKey.lastIndexOf(':') + 1); + 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 + "
" + targetFileKey; + } } - table.setText(row, 3, targetResourceKey); + table.setHTML(row, 3, targetResourceKey); table.setText(row, 4, targetStartLine); setRowStyle(row, table, style, false); -- 2.39.5