001 /* 002 * Sonar, open source software quality management tool. 003 * Copyright (C) 2008-2011 SonarSource 004 * mailto:contact AT sonarsource DOT com 005 * 006 * Sonar is free software; you can redistribute it and/or 007 * modify it under the terms of the GNU Lesser General Public 008 * License as published by the Free Software Foundation; either 009 * version 3 of the License, or (at your option) any later version. 010 * 011 * Sonar is distributed in the hope that it will be useful, 012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 014 * Lesser General Public License for more details. 015 * 016 * You should have received a copy of the GNU Lesser General Public 017 * License along with Sonar; if not, write to the Free Software 018 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 019 */ 020 package org.sonar.plugins.core.hotspots.client; 021 022 import com.google.gwt.gen2.table.override.client.Grid; 023 import com.google.gwt.i18n.client.Dictionary; 024 import com.google.gwt.user.client.ui.VerticalPanel; 025 import com.google.gwt.user.client.ui.Widget; 026 import org.sonar.gwt.Metrics; 027 import org.sonar.gwt.ui.Page; 028 import org.sonar.plugins.core.hotspots.client.widget.MetricHotspot; 029 import org.sonar.plugins.core.hotspots.client.widget.MostBadlyDesignedFiles; 030 import org.sonar.plugins.core.hotspots.client.widget.MostViolatedResources; 031 import org.sonar.plugins.core.hotspots.client.widget.MostViolatedRules; 032 import org.sonar.wsclient.services.Resource; 033 034 public class GwtHotspots extends Page { 035 @Override 036 protected Widget doOnResourceLoad(Resource resource) { 037 Grid grid = new Grid(1, 2); 038 grid.setStylePrimaryName("gwt-Hotspots"); 039 loadHotspots(grid, resource); 040 return grid; 041 } 042 043 044 private void loadHotspots(Grid grid, Resource resource) { 045 VerticalPanel column1 = new VerticalPanel(); 046 column1.setStyleName("hotspotcol"); 047 VerticalPanel column2 = new VerticalPanel(); 048 column2.setStyleName("hotspotcol"); 049 050 Dictionary l10n = Dictionary.getDictionary("l10n"); 051 column1.add(new MostViolatedRules(resource)); 052 column1.add(new MetricHotspot(resource, Metrics.TEST_EXECUTION_TIME, l10n.get("hotspot.titleLongestTests"))); 053 column1.add(new MetricHotspot(resource, Metrics.COMPLEXITY, l10n.get("hotspot.titleMostComplexResources"))); 054 column1.add(new MetricHotspot(resource, Metrics.DUPLICATED_LINES, l10n.get("hotspot.titleMostDuplicatedResources"))); 055 column1.add(new MostBadlyDesignedFiles(resource)); 056 057 column2.add(new MostViolatedResources(resource)); 058 column2.add(new MetricHotspot(resource, Metrics.UNCOVERED_LINES, l10n.get("hotspot.titleLessTested"))); 059 column2.add(new MetricHotspot(resource, Metrics.FUNCTION_COMPLEXITY, l10n.get("hotspot.titleMostComplexMethods"))); 060 column2.add(new MetricHotspot(resource, Metrics.PUBLIC_UNDOCUMENTED_API, l10n.get("hotspot.titleMostUndocumentedAPI"))); 061 062 grid.setWidget(0, 0, column1); 063 grid.setWidget(0, 1, column2); 064 } 065 066 }