remove the core GWT components which are replaced by Ruby on Rails pages

This commit is contained in:
simonbrandhof 2011-03-04 17:38:45 +01:00
parent 81f87bdb33
commit cf20a05a05
31 changed files with 0 additions and 1700 deletions

View File

@ -58,11 +58,7 @@
<execution>
<configuration>
<modules>
<module>org.sonar.plugins.core.ui.pageselector.PageSelector${gwt.permutationSuffix}</module>
<module>org.sonar.plugins.core.clouds.GwtClouds${gwt.permutationSuffix}</module>
<module>org.sonar.plugins.core.violationsviewer.ViolationsViewer${gwt.permutationSuffix}</module>
<module>org.sonar.plugins.core.coverageviewer.CoverageViewer${gwt.permutationSuffix}</module>
<module>org.sonar.plugins.core.defaultsourceviewer.GwtDefaultSourceViewer${gwt.permutationSuffix}</module>
<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>

View File

@ -1,40 +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.coverageviewer;
import org.sonar.api.measures.CoreMetrics;
import org.sonar.api.resources.Resource;
import org.sonar.api.web.*;
@ResourceQualifier(Resource.QUALIFIER_CLASS)
@NavigationSection(NavigationSection.RESOURCE_TAB)
@DefaultTab(metrics={CoreMetrics.COVERAGE_KEY, CoreMetrics.LINES_TO_COVER_KEY, CoreMetrics.UNCOVERED_LINES_KEY, CoreMetrics.LINE_COVERAGE_KEY, CoreMetrics.CONDITIONS_TO_COVER_KEY, CoreMetrics.UNCOVERED_CONDITIONS_KEY, CoreMetrics.BRANCH_COVERAGE_KEY})
@UserRole(UserRole.CODEVIEWER)
public class CoverageViewerDefinition extends GwtPage {
public String getTitle() {
return "Coverage";
}
public String getGwtId() {
return "org.sonar.plugins.core.coverageviewer.CoverageViewer";
}
}

View File

@ -1,123 +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.coverageviewer.client;
import org.sonar.gwt.Metrics;
import org.sonar.gwt.ui.SourcePanel;
import org.sonar.wsclient.gwt.AbstractCallback;
import org.sonar.wsclient.gwt.Sonar;
import org.sonar.wsclient.services.Resource;
import org.sonar.wsclient.services.ResourceQuery;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class CoveragePanel extends SourcePanel {
private Map<Integer, String> hitsByLine = new HashMap<Integer, String>();
private Map<Integer, String> branchHitsByLine = new HashMap<Integer, String>();
public CoveragePanel(Resource resource) {
super(resource);
loadCoverageHits(resource);
}
private void loadCoverageHits(Resource resource) {
ResourceQuery query = ResourceQuery.createForResource(resource, Metrics.COVERAGE_LINE_HITS_DATA, Metrics.BRANCH_COVERAGE_HITS_DATA);
Sonar.getInstance().find(query, new AbstractCallback<Resource>() {
@Override
protected void doOnResponse(Resource resource) {
handleResponse(resource, Metrics.COVERAGE_LINE_HITS_DATA, hitsByLine);
handleResponse(resource, Metrics.BRANCH_COVERAGE_HITS_DATA, branchHitsByLine);
setStarted();
}
});
}
private void handleResponse(Resource resource, String metric, Map<Integer, String> values) {
if (resource==null || resource.getMeasure(metric)==null) {
return;
}
values.clear();
String linesValue = resource.getMeasure(metric).getData();
String[] lineWithValueArray;
if (linesValue.contains(",")) {
// deprecated - format before 1.9
lineWithValueArray = linesValue.split(",");
} else {
lineWithValueArray = linesValue.split(";");
}
for (String lineWithValue : lineWithValueArray) {
String[] elt = lineWithValue.split("=");
if (elt != null && elt.length == 2) {
values.put(Integer.parseInt(elt[0]), elt[1]);
}
}
}
@Override
protected boolean shouldDecorateLine(int index) {
return index > 0;
}
@Override
protected List<Row> decorateLine(int index, String source) {
Row row = new Row().setLineIndex(index, "");
String hits = hitsByLine.get(index);
String branchHits = branchHitsByLine.get(index);
boolean hasLineCoverage = (null != hits);
boolean hasBranchCoverage = (null != branchHits);
boolean lineIsCovered = (hasLineCoverage && Integer.parseInt(hits) > 0);
boolean branchIsCovered = (hasBranchCoverage && "100%".equals(branchHits));
row.setSource(source, "");
row.setValue("&nbsp;", "");
row.setValue2("&nbsp;", "");
if (lineIsCovered) {
if (branchIsCovered) {
row.setValue(hits, "green");
row.setValue2(branchHits, "green");
} else if (hasBranchCoverage) {
row.setValue(hits, "orange");
row.setValue2(branchHits, "orange");
row.setSource(source, "orange");
} else {
row.setValue(hits, "green");
}
} else if (hasLineCoverage) {
row.setValue(hits, "red");
row.setSource(source, "red");
if (hasBranchCoverage) {
row.setValue2(branchHits, "red");
} else {
row.setValue2("&nbsp;", "red");
}
}
return Arrays.asList(row);
}
}

View File

@ -1,64 +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.coverageviewer.client;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.HorizontalPanel;
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 CoverageViewer extends Page {
@Override
protected Widget doOnResourceLoad(Resource resource) {
FlowPanel panel = new FlowPanel();
panel.setWidth("100%");
panel.add(new CoverageHeader(resource));
panel.add(new CoveragePanel(resource));
return panel;
}
private static class CoverageHeader extends ViewerHeader {
public CoverageHeader(Resource resource) {
super(resource, new String[]{Metrics.COVERAGE, Metrics.LINE_COVERAGE, Metrics.UNCOVERED_LINES, Metrics.BRANCH_COVERAGE, Metrics.UNCOVERED_CONDITIONS});
}
@Override
protected void display(FlowPanel header, Resource resource) {
HorizontalPanel panel = new HorizontalPanel();
header.add(panel);
Measure measure = resource.getMeasure(Metrics.COVERAGE);
if (measure == null) {
addBigCell(panel, "-");
} else {
addBigCell(panel, measure.getFormattedValue());
}
addCell(panel, resource.getMeasure(Metrics.LINE_COVERAGE));
addCell(panel, resource.getMeasure(Metrics.UNCOVERED_LINES));
addCell(panel, resource.getMeasure(Metrics.BRANCH_COVERAGE));
addCell(panel, resource.getMeasure(Metrics.UNCOVERED_CONDITIONS));
}
}
}

View File

@ -1,39 +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.defaultsourceviewer;
import org.sonar.api.resources.Resource;
import org.sonar.api.web.*;
import org.sonar.plugins.core.defaultsourceviewer.client.GwtDefaultSourceViewer;
@ResourceScope(Resource.SCOPE_ENTITY)
@NavigationSection(NavigationSection.RESOURCE_TAB)
@DefaultTab
@UserRole(UserRole.CODEVIEWER)
public class DefaultSourceViewer extends GwtPage {
public String getTitle() {
return "Sources";
}
public String getGwtId() {
return GwtDefaultSourceViewer.GWT_ID;
}
}

View File

@ -1,113 +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.defaultsourceviewer.client;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.Widget;
import org.sonar.gwt.Metrics;
import org.sonar.gwt.ui.DefaultSourcePanel;
import org.sonar.gwt.ui.Page;
import org.sonar.gwt.ui.ViewerHeader;
import org.sonar.wsclient.services.Resource;
public class GwtDefaultSourceViewer extends Page {
public static final String GWT_ID = "org.sonar.plugins.core.defaultsourceviewer.GwtDefaultSourceViewer";
@Override
protected Widget doOnResourceLoad(Resource resource) {
FlowPanel panel = new FlowPanel();
panel.setWidth("100%");
panel.add(new SimpleHeader(resource));
panel.add(new DefaultSourcePanel(resource));
return panel;
}
private static class SimpleHeader extends ViewerHeader {
public SimpleHeader(Resource resource) {
super(resource, new String[]{
Metrics.LINES,
Metrics.NCLOC,
Metrics.FUNCTIONS,
Metrics.ACCESSORS,
Metrics.PARAGRAPHS,
Metrics.STATEMENTS,
Metrics.COMPLEXITY,
Metrics.FUNCTION_COMPLEXITY,
Metrics.PARAGRAPH_COMPLEXITY,
Metrics.COMMENT_LINES_DENSITY,
Metrics.COMMENT_LINES,
Metrics.COMMENTED_OUT_CODE_LINES,
Metrics.COMMENT_BLANK_LINES,
Metrics.PUBLIC_DOCUMENTED_API_DENSITY,
Metrics.PUBLIC_UNDOCUMENTED_API,
Metrics.PUBLIC_API,
Metrics.CLASSES,
Metrics.NUMBER_OF_CHILDREN,
Metrics.DEPTH_IN_TREE,
Metrics.RFC
}
);
}
@Override
protected void display(FlowPanel header, Resource resource) {
HorizontalPanel panel = new HorizontalPanel();
addCell(panel,
resource.getMeasure(Metrics.LINES),
resource.getMeasure(Metrics.NCLOC),
resource.getMeasure(Metrics.FUNCTIONS),
resource.getMeasure(Metrics.ACCESSORS),
resource.getMeasure(Metrics.PARAGRAPHS));
addCell(panel,
resource.getMeasure(Metrics.STATEMENTS),
resource.getMeasure(Metrics.COMPLEXITY),
resource.getMeasure(Metrics.FUNCTION_COMPLEXITY),
resource.getMeasure(Metrics.PARAGRAPH_COMPLEXITY));
addCell(panel,
resource.getMeasure(Metrics.COMMENT_LINES_DENSITY),
resource.getMeasure(Metrics.COMMENT_LINES),
resource.getMeasure(Metrics.COMMENTED_OUT_CODE_LINES),
resource.getMeasure(Metrics.COMMENT_BLANK_LINES));
addCell(panel,
resource.getMeasure(Metrics.PUBLIC_DOCUMENTED_API_DENSITY),
resource.getMeasure(Metrics.PUBLIC_UNDOCUMENTED_API),
resource.getMeasure(Metrics.PUBLIC_API));
addCell(panel,
resource.getMeasure(Metrics.CLASSES),
resource.getMeasure(Metrics.NUMBER_OF_CHILDREN),
resource.getMeasure(Metrics.DEPTH_IN_TREE),
resource.getMeasure(Metrics.RFC));
if (panel.getWidgetCount() > 0) {
header.add(panel);
}
}
}
}

View File

@ -1,30 +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.ui.pageselector;
import org.sonar.api.web.GwtExtension;
import org.sonar.plugins.core.ui.pageselector.client.PageSelector;
public class GwtPageSelector implements GwtExtension {
public String getGwtId() {
return PageSelector.GWT_ID;
}
}

View File

@ -1,30 +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.ui.pageselector.client;
import com.google.gwt.core.client.GWT;
public interface I18nConstants extends com.google.gwt.i18n.client.Constants {
static I18nConstants INSTANCE = GWT.create(I18nConstants.class);
@DefaultStringValue("New window")
String newWindow();
}

View File

@ -1,94 +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.ui.pageselector.client;
import com.google.gwt.core.client.JavaScriptObject;
public class PageDef extends JavaScriptObject {
// Overlay types always have protected, zero-arg ctors
protected PageDef() {
}
public final native boolean isGwt() /*-{ return this.gwt; }-*/;
public final native boolean isDefaultTab() /*-{ return this.d; }-*/;
public final native String getId() /*-{ return this.id; }-*/;
public final native String getUrl() /*-{ return this.url; }-*/;
public final native String getName() /*-{ return this.name; }-*/;
public final native StringArray getMetrics() /*-{ return this.m || []; }-*/;
public final native StringArray getLanguages() /*-{ return this.l || []; }-*/;
public final native StringArray getScopes() /*-{ return this.s || []; }-*/;
public final native StringArray getQualifiers() /*-{ return this.q || []; }-*/;
public final boolean acceptLanguage(String language) {
return hasValue(getLanguages(), language);
}
public final boolean acceptScope(String scope) {
return hasValue(getScopes(), scope);
}
public final boolean acceptQualifier(String qualifier) {
return hasValue(getQualifiers(), qualifier);
}
public final boolean acceptMetric(String metric) {
StringArray metrics = getMetrics();
for (int index = 0; index < metrics.length(); index++) {
if (metric.equals(metrics.get(index))) {
return true;
}
}
return false;
}
private boolean hasValue(StringArray array, String value) {
if (array == null || array.length() == 0) {
return true;
}
if (value != null) {
for (int index = 0; index < array.length(); index++) {
if (value.equals(array.get(index))) {
return true;
}
}
}
return false;
}
}
class StringArray extends JavaScriptObject {
protected StringArray() {
}
public final native int length() /*-{ return this.length; }-*/;
public final native String get(int i) /*-{ return this[i]; }-*/;
}

View File

@ -1,156 +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.ui.pageselector.client;
import com.google.gwt.http.client.*;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.SimplePanel;
import org.sonar.api.web.gwt.client.Utils;
import org.sonar.gwt.Configuration;
import org.sonar.gwt.Links;
import org.sonar.gwt.ui.Loading;
public class PagePanel extends SimplePanel {
private PageDef def;
private String rootPanelId;
private String currentResourceId = null;
public PagePanel(PageDef def) {
this.def = def;
rootPanelId = "gwtpage-" + def.getId();
add(new HTML("<div id=\"" + rootPanelId + "\"> </div>"));
}
public void display() {
String resourceId = Configuration.getResourceId();
if (resourceId != null && !resourceId.equals(currentResourceId)) {
currentResourceId = resourceId;
if (def.isGwt()) {
loadGwt(Links.baseUrl(), Configuration.getSonarVersion(), def.getId());
} else {
loadEmbeddedPage(resourceId);
}
}
}
private native void loadGwt(final String serverUrl, final String sonarVersion, final String gwtId) /*-{
if ($wnd.modules[gwtId]!=null) {
$wnd.modules[gwtId]();
return;
}
// Create the script tag to be used for importing the GWT script loader.
var script = $doc.createElement('script');
script.type = 'text/javascript';
script.src = serverUrl + '/deploy/gwt/' + gwtId + '/' + gwtId + '.nocache.js?' + sonarVersion;
// The default GWT script loader calls document.write() twice which prevents loading scripts
// on demand, after the document has been loaded. To overcome this we have to overwrite the document.write()
// method before the GWT script loader is executed and restore it after.
// NOTE: The GWT script loader uses document.write() to compute the URL from where it is loaded.
var counter = 0;
var limit = 2;
var oldWrite = $doc.write;
var newWrite = function(html) {
if (counter < limit) {
counter++;
// Fail silently if the script element hasn't been attached to the document.
if (!script.parentNode) {
return;
}
// Create a DIV and put the HTML inside.
var div = $doc.createElement('div');
// We have to replace all the script tags because otherwise IE drops them.
div.innerHTML = html.replace(/<script\b([\s\S]*?)<\/script>/gi, "<pre script=\"script\"$1</pre>");
// Move DIV contents after the GWT script loader.
var nextSibling = script.nextSibling;
while(div.firstChild) {
var child = div.firstChild;
// Recover the script tags.
if (child.nodeName.toLowerCase() == 'pre' && child.getAttribute('script') == 'script') {
var pre = child;
pre.removeAttribute('script');
// Create the script tag.
child = $doc.createElement('script');
// Copy all the attributes.
for (var i = 0; i < pre.attributes.length; i++) {
var attrNode = pre.attributes[i];
// In case of IE we have to copy only the specified attributes.
if (typeof attrNode.specified == 'undefined'
|| (typeof attrNode.specified == 'boolean' && attrNode.specified)) {
child.setAttribute(attrNode.nodeName, attrNode.nodeValue);
}
}
// Copy the script text.
child.text = typeof pre.innerText == 'undefined' ? pre.textContent : pre.innerText;
// Don't forget to remove the placeholder.
div.removeChild(pre);
}
if (nextSibling) {
script.parentNode.insertBefore(child, nextSibling);
} else {
script.parentNode.appendChild(child);
}
}
}
if (counter >= limit) {
$doc.write = oldWrite;
oldWrite = undefined;
script = undefined;
counter = undefined;
}
};
// Append the script tag to the head.
var heads = $doc.getElementsByTagName('head');
if (heads.length > 0) {
$doc.write = newWrite;
heads[0].appendChild(script);
}
}-*/;
private void loadEmbeddedPage(String resourceId) {
final RootPanel panel = RootPanel.get(rootPanelId);
panel.add(new Loading());
String url = def.getUrl();
if (url == null) {
url = "/plugins/resource/" + resourceId + "?page=" + def.getId() + "&layout=false&hd=false";
} else {
url += resourceId;
}
RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, URL.encode(Links.baseUrl() + url));
try {
builder.sendRequest(null, new RequestCallback() {
public void onError(Request request, Throwable exception) {
Utils.showError("Can not load the page " + request.toString());
}
public void onResponseReceived(Request request, Response response) {
panel.clear();
panel.add(new HTML(response.getText()));
}
});
} catch (RequestException e) {
Utils.showError("Can not connect to server: " + url);
}
}
}

View File

@ -1,224 +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.ui.pageselector.client;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.client.JavaScriptObject;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.logical.shared.SelectionEvent;
import com.google.gwt.event.logical.shared.SelectionHandler;
import com.google.gwt.user.client.ui.*;
import org.sonar.gwt.Configuration;
import org.sonar.gwt.Links;
import org.sonar.gwt.Utils;
import org.sonar.gwt.ui.Icons;
import org.sonar.gwt.ui.Loading;
import org.sonar.wsclient.gwt.Callback;
import org.sonar.wsclient.gwt.Sonar;
import org.sonar.wsclient.services.Resource;
import org.sonar.wsclient.services.ResourceQuery;
import java.util.ArrayList;
import java.util.List;
public class PageSelector implements EntryPoint {
public static final String GWT_ID = "org.sonar.plugins.core.ui.pageselector.PageSelector";
public static final String HTML_ROOT_ID = "pageselector";
private VerticalPanel container = null;
private String currentResourceId = null;
private PageDefs pageDefs = null;
public void onModuleLoad() {
pageDefs = loadPageDefs();
exportNativeJavascript(this);
if (Configuration.getResourceId() != null) {
selectResource(Configuration.getResourceId());
}
}
private VerticalPanel createContainer() {
if (container == null) {
container = new VerticalPanel();
container.getElement().setId("rvs");
RootPanel.get(HTML_ROOT_ID).add(container);
}
return container;
}
public static native void exportNativeJavascript(Object obj) /*-{
$wnd.sr=function(resourceIdOrKey) {
obj.@org.sonar.plugins.core.ui.pageselector.client.PageSelector::selectResource(Ljava/lang/String;)(resourceIdOrKey);
};
}-*/;
public void selectResource(final String resourceIdOrKey) {
createContainer().add(new Loading());
currentResourceId = resourceIdOrKey;
Sonar.getInstance().find(new ResourceQuery(resourceIdOrKey), new Callback<Resource>() {
public void onResponse(Resource resource, JavaScriptObject json) {
if (resourceIdOrKey != null && resourceIdOrKey.equals(currentResourceId)) {
if (resource == null) {
displayResourceNotFound();
} else {
saveResource(resource.getId().toString(), json);
displayResource(resource);
}
} // else too late, user has selected another resource
}
public void onTimeout() {
Utils.showError("Can not load data (timeout)");
}
public void onError(int errorCode, String errorMessage) {
Utils.showError("Can not load data: error " + errorCode + ", message: " + errorMessage);
}
});
}
private void displayResource(final Resource resource) {
List<PageDef> pages = selectPages(resource);
PageDef selectedPage = selectPage(pages);
Title title = new Title(resource);
final TabPanel tabs = new TabPanel();
tabs.setWidth("100%");
int selectedTabIndex = -1;
for (int tabIndex = 0; tabIndex < pages.size(); tabIndex++) {
PageDef page = pages.get(tabIndex);
tabs.add(new PagePanel(page), page.getName());
if (page == selectedPage) {
selectedTabIndex = tabIndex;
}
}
container.clear(); // remove the loading icon
container.add(title);
container.add(tabs);
tabs.addSelectionHandler(new SelectionHandler<Integer>() {
public void onSelection(SelectionEvent<Integer> tabId) {
((PagePanel) tabs.getWidget(tabId.getSelectedItem())).display();
}
});
if (selectedTabIndex > -1) {
tabs.selectTab(selectedTabIndex);
}
}
private PageDef selectPage(List<PageDef> pages) {
String pageId = Configuration.getRequestParameter("page");
if (pageId != null) {
for (PageDef page : pages) {
if (pageId.equals(page.getId())) {
return page;
}
}
}
String metric = Configuration.getParameter("metric");
if (metric != null) {
for (PageDef page : pages) {
if (page.acceptMetric(metric)) {
return page;
}
}
}
for (PageDef page : pages) {
if (page.isDefaultTab()) {
return page;
}
}
return null;
}
private native void saveResource(String resourceId, JavaScriptObject json) /*-{
$wnd.config['resource_key']=resourceId;
$wnd.config['resource']=json;
}-*/;
/**
* Never return null.
*/
private List<PageDef> selectPages(final Resource resource) {
List<PageDef> pages = new ArrayList<PageDef>();
for (int index = 0; index < pageDefs.length(); index++) {
PageDef page = pageDefs.get(index);
if (page.acceptLanguage(resource.getLanguage()) &&
page.acceptQualifier(resource.getQualifier()) &&
page.acceptScope(resource.getScope())) {
pages.add(page);
}
}
return pages;
}
private void displayResourceNotFound() {
container.clear(); // remove the loading icon
}
static class Title extends Composite {
Title(final Resource resource) {
Grid grid = new Grid(1, 2);
grid.getElement().setId("rvstitle");
grid.setHTML(0, 0, Icons.forQualifier(resource.getQualifier()).getHTML() + " <span class='name'>" + resource.getName(true) + "</span>");
if (!"true".equals(Configuration.getParameter("popup"))) {
Hyperlink newWindow = new Hyperlink();
newWindow.setText(I18nConstants.INSTANCE.newWindow());
newWindow.setStyleName("command");
newWindow.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent clickEvent) {
Links.openMeasurePopup(resource.getKey(), Configuration.getParameter("metric"));
}
});
grid.setWidget(0, 1, newWindow);
}
grid.getColumnFormatter().setStyleName(1, "right");
initWidget(grid);
}
}
private native PageDefs loadPageDefs() /*-{
return $wnd.pages;
}-*/;
// An overlay type
static class PageDefs extends JavaScriptObject {
protected PageDefs() {
}
public final native int length() /*-{ return this.length; }-*/;
public final native PageDef get(int i) /*-{ return this[i]; }-*/;
}
}

View File

@ -1,41 +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.violationsviewer;
import org.sonar.api.measures.CoreMetrics;
import org.sonar.api.resources.Resource;
import org.sonar.api.web.*;
import org.sonar.plugins.core.violationsviewer.client.ViolationsViewer;
@NavigationSection(NavigationSection.RESOURCE_TAB)
@DefaultTab(metrics={CoreMetrics.VIOLATIONS_DENSITY_KEY, CoreMetrics.WEIGHTED_VIOLATIONS_KEY, CoreMetrics.VIOLATIONS_KEY, CoreMetrics.BLOCKER_VIOLATIONS_KEY, CoreMetrics.CRITICAL_VIOLATIONS_KEY, CoreMetrics.MAJOR_VIOLATIONS_KEY, CoreMetrics.MINOR_VIOLATIONS_KEY, CoreMetrics.INFO_VIOLATIONS_KEY})
@ResourceQualifier({Resource.QUALIFIER_CLASS,Resource.QUALIFIER_FILE})
@UserRole(UserRole.CODEVIEWER)
public class ViolationsViewerDefinition extends GwtPage {
public String getTitle() {
return "Violations";
}
public String getGwtId() {
return ViolationsViewer.GWT_ID;
}
}

View File

@ -1,42 +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.violationsviewer.client;
import com.google.gwt.core.client.GWT;
public interface I18nConstants extends com.google.gwt.i18n.client.Constants {
static I18nConstants INSTANCE = GWT.create(I18nConstants.class);
@DefaultStringValue("Filter:")
String filter();
@DefaultStringValue("No filters")
String noFilters();
@DefaultStringValue("Time changes...")
String addedPeriod();
@DefaultStringValue("Expand:")
String expand();
@DefaultStringValue("Loading...")
String loading();
}

View File

@ -1,187 +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.violationsviewer.client;
import com.google.gwt.user.client.Window;
import org.sonar.gwt.Links;
import org.sonar.gwt.Utils;
import org.sonar.gwt.ui.Icons;
import org.sonar.gwt.ui.SourcePanel;
import org.sonar.wsclient.gwt.AbstractListCallback;
import org.sonar.wsclient.gwt.Sonar;
import org.sonar.wsclient.services.Resource;
import org.sonar.wsclient.services.Violation;
import org.sonar.wsclient.services.ViolationQuery;
import java.util.*;
public class ViolationsPanel extends SourcePanel {
private boolean expand = false;
private List<Violation> violations;
private Map<Integer, List<Violation>> filteredViolationsByLine = new HashMap<Integer, List<Violation>>();
private final static Date now = new Date();
public ViolationsPanel(Resource resource, String filter, Date fromDate) {
super(resource);
loadViolations(resource, filter, fromDate);
}
protected void loadViolations(final Resource resource, final String filter, final Date fromDate) {
Sonar.getInstance().findAll(ViolationQuery.createForResource(resource), new AbstractListCallback<Violation>() {
@Override
protected void doOnResponse(List<Violation> violations) {
ViolationsPanel.this.violations = violations;
filter(filter, fromDate);
setStarted();
}
});
}
public boolean isExpand() {
return expand;
}
public void setExpand(boolean expand) {
this.expand = expand;
}
public void filter(String filter, Date fromDate) {
filteredViolationsByLine.clear();
for (Violation violation : violations) {
if (// check text filter
(filter == null || filter.equals("") || violation.getRuleKey().equals(filter) || violation.getSeverity().equals(filter)) &&
// check date filter
(fromDate == null || violation.isCreatedAfter(fromDate))) {
Integer line = 0;
if (violation.getLine() != null) {
line = violation.getLine();
}
List<Violation> lineViolations = filteredViolationsByLine.get(line);
if (lineViolations == null) {
lineViolations = new ArrayList<Violation>();
filteredViolationsByLine.put(line, lineViolations);
}
lineViolations.add(violation);
}
}
}
@Override
public boolean shouldDecorateLine(int index) {
if (expand) {
return true;
}
for (int i = index - 5; i < index + 5; i++) {
if (hasViolations(i)) {
return true;
}
}
return false;
}
@Override
protected List<Row> decorateLine(int index, String source) {
List<Row> rows = new ArrayList<Row>();
List<Violation> lineViolations = filteredViolationsByLine.get(index);
boolean hasViolations = lineViolations != null && !lineViolations.isEmpty();
if (index > 0) {
String style = (hasViolations ? "red" : "");
Row row = new Row().setLineIndex(index, style).unsetValue().setSource(source, style);
rows.add(row);
}
if (hasViolations) {
for (Violation violation : lineViolations) {
rows.add(new ViolationRow(violation));
}
}
return rows;
}
public static class ViolationRow extends Row {
private Violation violation;
public ViolationRow(Violation violation) {
this.violation = violation;
}
@Override
public String getColumn1() {
return "<div class=\"bigln\">&nbsp;</div>";
}
@Override
public String getColumn2() {
return "";
}
@Override
public String getColumn3() {
return "";
}
@Override
public String getColumn4() {
String age = "";
if (violation.getCreatedAt() != null) {
if (sameDay(now, violation.getCreatedAt())) {
age = " <span class='note'>(today)</span>";
} else {
age = " <span class='note'>(" + diffInDays(violation.getCreatedAt(), now) + " days)</span>";
}
}
return "<div class=\"warn\">" + Icons.forPriority(violation.getPriority()).getHTML() + "</img> "
+ " <a href=\"" + Links.urlForRule(violation.getRuleKey(), false)
+ "\" onclick=\"window.open(this.href,'rule','height=800,width=900,scrollbars=1,resizable=1');return false;\" title=\""
+ violation.getRuleKey() + "\"><b>"
+ Utils.escapeHtml(violation.getRuleName()) + "</b></a> : "
+ Utils.escapeHtml(violation.getMessage()) + age + "</div>";
}
@SuppressWarnings("deprecation")
static boolean sameDay(Date d1, Date d2) {
return d1.getDate() == d2.getDate() && d1.getMonth() == d2.getMonth() && d1.getYear() == d2.getYear();
}
@SuppressWarnings(value = "deprecation")
static int diffInDays(Date d1, Date d2) {
int difference = 0;
int endDateOffset = -(d1.getTimezoneOffset() * 60 * 1000);
long endDateInstant = d1.getTime() + endDateOffset;
int startDateOffset = -(d2.getTimezoneOffset() * 60 * 1000);
long startDateInstant = d2.getTime() + startDateOffset;
double differenceDouble = (double) Math.abs(endDateInstant - startDateInstant) / (1000.0 * 60 * 60 * 24);
differenceDouble = Math.max(1.0D, differenceDouble);
difference = (int) differenceDouble;
return difference;
}
}
private boolean hasViolations(int lineIndex) {
if (lineIndex < 0) {
return false;
}
List<Violation> list = filteredViolationsByLine.get(lineIndex);
return list != null && !list.isEmpty();
}
}

View File

@ -1,257 +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.violationsviewer.client;
import com.google.gwt.event.dom.client.ChangeEvent;
import com.google.gwt.event.dom.client.ChangeHandler;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.gen2.table.override.client.Grid;
import com.google.gwt.user.client.ui.*;
import org.sonar.gwt.Configuration;
import org.sonar.gwt.JsonUtils;
import org.sonar.gwt.Metrics;
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.Measure;
import org.sonar.wsclient.services.Resource;
import org.sonar.wsclient.services.ResourceQuery;
import java.util.*;
public class ViolationsViewer extends Page {
public static final String GWT_ID = "org.sonar.plugins.core.violationsviewer.ViolationsViewer";
private Resource resource;
private final Panel mainPanel = new VerticalPanel();
private final Loading loading = new Loading(I18nConstants.INSTANCE.loading());
// header
private Grid header = null;
private ListBox filterBox = null, periodBox = null;
private List<Date> dateFilters = new ArrayList<Date>();
private CheckBox expandCheckbox = null;
// source
private ViolationsPanel sourcePanel;
private boolean resourceHasViolations = false;
@Override
protected Widget doOnResourceLoad(Resource resource) {
this.resource = resource;
mainPanel.clear();
mainPanel.add(loading);
mainPanel.setWidth("100%");
mainPanel.setStyleName("gwt-Violations");
sourcePanel = null; // reload sources when selecting a new file
header = new Grid(1, 5);
header.setWidth("100%");
header.setStylePrimaryName("gwt-ViewerHeader");
header.getCellFormatter().setStyleName(0, 0, "thin left");
header.getCellFormatter().setStyleName(0, 1, "right");
initFilters();
if (periodBox.getItemCount() > 1) {
header.setWidget(0, 1, periodBox);
header.getCellFormatter().setStyleName(0, 1, "thin cell right");
}
header.setWidget(0, 2, filterBox);
header.getCellFormatter().setStyleName(0, 2, "thin cell right");
header.setHTML(0, 3, "<div class='note'>" + I18nConstants.INSTANCE.expand() + "</div>");
header.getCellFormatter().setStyleName(0, 3, "thin right");
expandCheckbox = new CheckBox();
expandCheckbox.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
loadSources();
sourcePanel.setExpand(expandCheckbox.getValue());
sourcePanel.refresh();
}
});
header.setWidget(0, 4, expandCheckbox);
header.getCellFormatter().setStyleName(0, 4, "thin cell left");
loadRuleSeverities();
return mainPanel;
}
private void initFilters() {
initFilterBox();
initPeriodBox();
ChangeHandler changeHandler = new ChangeHandler() {
public void onChange(ChangeEvent event) {
loadSources();
sourcePanel.filter(getCurrentRuleFilter(), getCurrentDateFilter());
sourcePanel.refresh();
}
};
filterBox.addChangeHandler(changeHandler);
periodBox.addChangeHandler(changeHandler);
}
private void initFilterBox() {
filterBox = new ListBox();
filterBox.addItem(I18nConstants.INSTANCE.noFilters(), "");
filterBox.setStyleName("small");
}
private void initPeriodBox() {
periodBox = new ListBox();
periodBox.setStyleName("small");
periodBox.addItem(I18nConstants.INSTANCE.addedPeriod());
initPeriod(1);
initPeriod(2);
initPeriod(3);
initPeriod(4);
initPeriod(5);
String period = Configuration.getRequestParameter("period");
if (period != null && !"".equals(period)) {
periodBox.setSelectedIndex(Integer.valueOf(period));
}
}
private void initPeriod(int periodIndex) {
String period = Configuration.getParameter("period" + periodIndex);
if (period != null) {
Date date = JsonUtils.parseDateTime(Configuration.getParameter("period" + periodIndex + "_date"));
if (date != null) {
periodBox.addItem("Added " + period);
dateFilters.add(date);
}
}
}
private Date getCurrentDateFilter() {
Date dateFilter = null;
if (periodBox.getSelectedIndex() > 0) {
dateFilter = dateFilters.get(periodBox.getSelectedIndex() - 1);
}
return dateFilter;
}
private String getCurrentRuleFilter() {
return filterBox.getValue(filterBox.getSelectedIndex());
}
private void loadRuleSeverities() {
final ResourceQuery query = ResourceQuery.createForResource(resource, Metrics.BLOCKER_VIOLATIONS,
Metrics.CRITICAL_VIOLATIONS, Metrics.MAJOR_VIOLATIONS, Metrics.MINOR_VIOLATIONS, Metrics.INFO_VIOLATIONS);
Sonar.getInstance().find(query, new AbstractCallback<Resource>(loading) {
@Override
protected void doOnResponse(Resource resource) {
String defaultFilter = Configuration.getRequestParameter("rule");
if (defaultFilter == null) {
defaultFilter = Configuration.getRequestParameter("priority");
}
setResourceHasViolations(resource);
displayRuleSeverities(resource, defaultFilter);
loadRules(resource, defaultFilter);
}
});
}
private void displayRuleSeverities(Resource resource, String defaultFilter) {
final Grid grid = new Grid(1, 10);
header.setWidget(0, 0, grid);
displayRuleSeverity(grid, 0, "BLOCKER", defaultFilter, resource.getMeasure(Metrics.BLOCKER_VIOLATIONS));
displayRuleSeverity(grid, 2, "CRITICAL", defaultFilter, resource.getMeasure(Metrics.CRITICAL_VIOLATIONS));
displayRuleSeverity(grid, 4, "MAJOR", defaultFilter, resource.getMeasure(Metrics.MAJOR_VIOLATIONS));
displayRuleSeverity(grid, 6, "MINOR", defaultFilter, resource.getMeasure(Metrics.MINOR_VIOLATIONS));
displayRuleSeverity(grid, 8, "INFO", defaultFilter, resource.getMeasure(Metrics.INFO_VIOLATIONS));
}
private void displayRuleSeverity(final Grid grid, final int column, final String severity, final String defaultFilter, final Measure measure) {
String value = "0";
if (measure != null) {
value = measure.getFormattedValue();
filterBox.addItem(severity + " (" + value + ")", severity);
if (severity.equals(defaultFilter)) {
filterBox.setSelectedIndex(filterBox.getItemCount() - 1);
}
}
grid.setHTML(0, column, Icons.forSeverity(severity).getHTML());
grid.setHTML(0, column + 1, value);
grid.getCellFormatter().setStyleName(0, column, "thin metric right");
grid.getCellFormatter().setStyleName(0, column + 1, "thin left value");
}
private void loadRules(final Resource resource, final String defaultFilter) {
final ResourceQuery query = ResourceQuery.createForResource(resource, Metrics.VIOLATIONS)
.setExcludeRules(false);
Sonar.getInstance().find(query, new AbstractCallback<Resource>(loading) {
@Override
protected void doOnResponse(Resource resource) {
setResourceHasViolations(resource);
displayRules(resource, defaultFilter);
loadSources();
}
});
}
private void setResourceHasViolations(Resource resource) {
resourceHasViolations = resource != null && resource.getMeasure(Metrics.VIOLATIONS) != null;
}
private void displayRules(final Resource resource, final String defaultFilter) {
Collections.sort(resource.getMeasures(), new Comparator<Measure>() {
public int compare(Measure m1, Measure m2) {
return m1.getRuleName().compareTo(m2.getRuleName());
}
});
filterBox.addItem("", "");
for (Measure measure : resource.getMeasures()) {
filterBox.addItem(measure.getRuleName() + " (" + measure.getFormattedValue() + ")", measure.getRuleKey());
if (measure.getRuleKey().equals(defaultFilter)) {
filterBox.setSelectedIndex(filterBox.getItemCount() - 1);
}
}
loading.removeFromParent();
mainPanel.add(header);
}
private void loadSources() {
if (sourcePanel == null) {
sourcePanel = new ViolationsPanel(resource, getCurrentRuleFilter(), getCurrentDateFilter());
mainPanel.add(sourcePanel);
} else {
mainPanel.remove(sourcePanel);
if (resourceHasViolations || expandCheckbox.getValue()) {
mainPanel.add(sourcePanel);
}
}
}
}

View File

@ -1,10 +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"/>
<inherits name="com.google.gwt.gen2.table.Table"/>
<entry-point class="org.sonar.plugins.core.coverageviewer.client.CoverageViewer"/>
</module>

View File

@ -1,6 +0,0 @@
<module rename-to="org.sonar.plugins.core.coverageviewer.CoverageViewer">
<inherits name="org.sonar.plugins.core.coverageviewer.CoverageViewer"/>
<inherits name="org.sonar.SonarDev"/>
<entry-point class="org.sonar.plugins.core.coverageviewer.client.CoverageViewer"/>
</module>

View File

@ -1,41 +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>Code coverage</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.apache.struts:struts-core:org.apache.struts.action.ActionServlet"
};
</script>
<div class="error" id="error" style="display:none"><span id="errormsg"></span> &nbsp;&nbsp;[<a href="#"
onclick="javascript:$('error').hide();return false;">hide</a>]
</div>
<div class="warning" id="warning" style="display:none"><span id="warningmsg"></span> &nbsp;&nbsp;[<a href="#"
onclick="javascript:$('warning').hide();return false;">hide</a>]
</div>
<div class="notice" id="info" style="display:none"><span id="infomsg"></span> &nbsp;&nbsp;[<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.coverageviewer.CoverageViewer.nocache.js"></script>
<a href="#" onclick="load_org_sonar_plugins_core_coverageviewer_CoverageViewer();">load</a>
</body>
</html>

View File

@ -1,10 +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"/>
<inherits name="com.google.gwt.gen2.table.Table"/>
<entry-point class="org.sonar.plugins.core.defaultsourceviewer.client.GwtDefaultSourceViewer"/>
</module>

View File

@ -1,6 +0,0 @@
<module rename-to="org.sonar.plugins.core.defaultsourceviewer.GwtDefaultSourceViewer">
<inherits name="org.sonar.plugins.core.defaultsourceviewer.GwtDefaultSourceViewer"/>
<inherits name="org.sonar.SonarDev"/>
<entry-point class="org.sonar.plugins.core.defaultsourceviewer.client.GwtDefaultSourceViewer"/>
</module>

View File

@ -1,26 +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>Sources</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>
<div id="gwtpage"></div>
<script type="text/javascript">
var config = {
"sonar_url": "http://localhost:9000",
"resource":[{"id":97, "key":"org.apache.struts:struts-core:org.apache.struts.config.ConfigRuleSet","scope": "FIL", "qualifier": "CLA", "name": "Struts Core", "lang":"java"}]
};
var modules = {};
var rp = {};
</script>
<script type="text/javascript" language="javascript" src="org.sonar.plugins.core.defaultsourceviewer.GwtDefaultSourceViewer.nocache.js"></script>
</body>
</html>

View File

@ -1,12 +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.api.web.gwt.Sonar"/>
<inherits name="org.sonar.Sonar"/>
<stylesheet src="pageselector.css" />
<entry-point class="org.sonar.plugins.core.ui.pageselector.client.PageSelector"/>
<extend-property name="locale" values="fr"/>
</module>

View File

@ -1,6 +0,0 @@
<module rename-to="org.sonar.plugins.core.ui.pageselector.PageSelector">
<inherits name="org.sonar.plugins.core.ui.pageselector.PageSelector"/>
<inherits name="org.sonar.SonarDev"/>
<entry-point class="org.sonar.plugins.core.ui.pageselector.client.PageSelector"/>
</module>

View File

@ -1,2 +0,0 @@
# This file must use UTF-8 encoding
newWindow=Nouvelle fenêtre

View File

@ -1,25 +0,0 @@
/* #rvs is "resource viewer selector" */
#rvs {
width: 100%;
margin-top: 10px;
border: 1px solid #CCC;
}
#rvstitle {
width: 100%;
margin: 5px;
}
#rvstitle .name {
}
#rvstitle .right {
float: none;
text-align: right;
}
#rvs .command {
text-align: right;
cursor: pointer;
margin-right: 15px;
}
#rvs .command a {
color: #444;
text-decoration: underline;
}

View File

@ -1,41 +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>Page selector</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>
<script type="text/javascript">
var config = {
"sonar_url": "http://localhost:9000",
"version": "2.0",
"metric": "ncloc",
"resource" : null
};
var pages = [
{"id": "org.sonar.plugins.foo.Foo", "gwt": false, "url": "http://localhost:9000/project/index/1", "metrics":[], "scopes":["PRJ"], "qualifiers": ["TRK", "BRC"], "langs": ["java"]},
{"id": "org.sonar.plugins.core.clouds.GwtClouds", "gwt": true, "metrics":["lcom4","noc"], "scopes":["PRJ"], "qualifiers": ["TRK", "BRC"], "langs": ["java"]},
{"id": "org.sonar.plugins.Overview", "gwt": true, "metrics":[], "scopes":[], "qualifiers": [], "langs": []},
{"id": "org.sonar.plugins.Rails", "gwt": false, "metrics":["clirr"], "scopes":[], "qualifiers": ["FIL"], "langs": []}
];
var entrypoints = {}
</script>
<div class="error" id="error" style="display:none"><span id="errormsg"></span> &nbsp;&nbsp;[<a href="#" onclick="javascript:$('error').hide();return false;">hide</a>]</div>
<div class="warning" id="warning" style="display:none"><span id="warningmsg"></span> &nbsp;&nbsp;[<a href="#" onclick="javascript:$('warning').hide();return false;">hide</a>]</div>
<div class="notice" id="info" style="display:none"><span id="infomsg"></span> &nbsp;&nbsp;[<a href="#" onclick="javascript:$('info').hide();return false;">hide</a>]</div>
<a href="#" onclick="sr('org.apache.struts:struts-parent');">load struts</a>
<div id="pageselector"> </div>
<script type="text/javascript" language="javascript" src="org.sonar.plugins.core.ui.pageselector.PageSelector.nocache.js"></script>
</body>
</html>

View File

@ -1,12 +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"/>
<inherits name="com.google.gwt.gen2.table.Table"/>
<inherits name="com.google.gwt.i18n.I18N"/>
<entry-point class="org.sonar.plugins.core.violationsviewer.client.ViolationsViewer"/>
<extend-property name="locale" values="fr"/>
</module>

View File

@ -1,6 +0,0 @@
<module rename-to="org.sonar.plugins.core.violationsviewer.ViolationsViewer">
<inherits name="org.sonar.plugins.core.violationsviewer.ViolationsViewer"/>
<inherits name="org.sonar.SonarDev"/>
<entry-point class="org.sonar.plugins.core.violationsviewer.client.ViolationsViewer"/>
</module>

View File

@ -1,5 +0,0 @@
# This file must use UTF-8 encoding
filter=Filtre:
noFilters=Aucun filtre
expand=Développer:
loading=En cours de chargement...

View File

@ -1,47 +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>Violations</title>
<link href="http://localhost:9000/stylesheets/yui-2.6.0.css" media="all" rel="Stylesheet" type="text/css"/>
<link href="http://localhost:9000/stylesheets/style.css" media="all" rel="Stylesheet" type="text/css"/>
<script src="http://localhost:9000/javascripts/application.js" type="text/javascript"></script>
<script src="http://localhost:9000/javascripts/prototype.js" type="text/javascript"></script>
<script src="http://localhost:9000/javascripts/scriptaculous.js" type="text/javascript"></script>
</head>
<body>
<script type="text/javascript">
var registeredTabs = [];
var modules={};
var config = {
"sonar_url": "http://localhost:9000",
"resource":[{"id": 369, "key":"org.sonar.tests:violations-timemachine:org.sonar.tests.violationstimemachine.Hello","scope": "FIL", "qualifier": "CLA", "name": "Hello", "lang":"java"}],
"viewer_resource_key": "org.sonar.tests:violations-timemachine:org.sonar.tests.violationstimemachine.Hello",
"period1" : "Violations created after previous analysis",
"period1_date" : "2010-11-03T00:01:00+0200"
};
var request_parameters = {"priority": "BLOCKER"}
</script>
<div class="error" id="error" style="display:none"><span id="errormsg"></span> &nbsp;&nbsp;[<a href="#"
onclick="javascript:$('error').hide();return false;">hide</a>]
</div>
<div class="warning" id="warning" style="display:none"><span id="warningmsg"></span> &nbsp;&nbsp;[<a href="#"
onclick="javascript:$('warning').hide();return false;">hide</a>]
</div>
<div class="notice" id="info" style="display:none"><span id="infomsg"></span> &nbsp;&nbsp;[<a href="#"
onclick="javascript:$('info').hide();return false;">hide</a>]
</div>
<div id="resource_viewers">
</div>
<div id="gwtpage">
</div>
<script type="text/javascript" language="javascript"
src="org.sonar.plugins.core.violationsviewer.ViolationsViewer.nocache.js"></script>
<a href="#" onclick="load_org_sonar_plugins_core_violationsviewer_ViolationsViewer();">load</a>
</body>
</html>

View File

@ -33,7 +33,6 @@ import org.sonar.plugins.core.charts.DistributionBarChart;
import org.sonar.plugins.core.charts.XradarChart;
import org.sonar.plugins.core.clouds.Clouds;
import org.sonar.plugins.core.colorizers.JavaColorizerFormat;
import org.sonar.plugins.core.coverageviewer.CoverageViewerDefinition;
import org.sonar.plugins.core.duplicationsviewer.DuplicationsViewerDefinition;
import org.sonar.plugins.core.hotspots.Hotspots;
import org.sonar.plugins.core.metrics.UserManagedMetrics;