diff options
Diffstat (limited to 'plugins')
3 files changed, 56 insertions, 92 deletions
diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/dashboards/HotspotsDashboard.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/dashboards/HotspotsDashboard.java index 03f71f62496..f6625d8854c 100644 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/dashboards/HotspotsDashboard.java +++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/dashboards/HotspotsDashboard.java @@ -19,72 +19,49 @@ */ package org.sonar.plugins.core.dashboards; -import org.sonar.api.web.AbstractDashboard; -import org.sonar.api.web.Dashboard; -import org.sonar.api.web.DashboardLayouts; -import org.sonar.api.web.DashboardWidget; -import org.sonar.api.web.DashboardWidgets; -import org.sonar.api.web.WidgetProperty; -import org.sonar.api.web.WidgetPropertyType; +import org.sonar.api.web.dashboard.Dashboard; +import org.sonar.api.web.dashboard.DashboardLayouts; +import org.sonar.api.web.dashboard.DashboardTemplate; +import org.sonar.api.web.dashboard.Widget; -@DashboardWidgets ({ - @DashboardWidget(id="hotspot_most_violated_rules", columnIndex=1, rowIndex=1), - @DashboardWidget(id="hotspot_metric", columnIndex=1, rowIndex=2, - properties={ - @WidgetProperty(key = "metric", type = WidgetPropertyType.METRIC, defaultValue = "test_execution_time"), - @WidgetProperty(key = "title", type = WidgetPropertyType.STRING, defaultValue = "Longest unit tests") +/** + * Hotspot dashboard for Sonar + */ +public class HotspotsDashboard extends DashboardTemplate { - }), - @DashboardWidget(id="hotspot_metric", columnIndex=1, rowIndex=3, - properties={ - @WidgetProperty(key = "metric", type = WidgetPropertyType.METRIC, defaultValue = "complexity"), - @WidgetProperty(key = "title", type = WidgetPropertyType.STRING, defaultValue = "Highest complexity") + @Override + public org.sonar.api.web.dashboard.Dashboard createDashboard() { + Dashboard dashboard = Dashboard.createDashboard("sonar-hotspots", "Hotspots", DashboardLayouts.TWO_COLUMNS); - }), - @DashboardWidget(id="hotspot_metric", columnIndex=1, rowIndex=4, - properties={ - @WidgetProperty(key = "metric", type = WidgetPropertyType.METRIC, defaultValue = "duplicated_lines"), - @WidgetProperty(key = "title", type = WidgetPropertyType.STRING, defaultValue = "Highest duplications") + Widget widget = dashboard.addWidget("hotspot_most_violated_rules", 1, 1); - }), - @DashboardWidget(id="hotspot_most_violated_resources", columnIndex=2, rowIndex=1), - @DashboardWidget(id="hotspot_metric", columnIndex=2, rowIndex=2, - properties={ - @WidgetProperty(key = "metric", type = WidgetPropertyType.METRIC, defaultValue = "uncovered_lines"), - @WidgetProperty(key = "title", type = WidgetPropertyType.STRING, defaultValue = "Highest untested lines") + widget = dashboard.addWidget("hotspot_metric", 1, 2); + widget.addProperty("metric", "test_execution_time"); + widget.addProperty("title", "Longest unit tests"); - }), - @DashboardWidget(id="hotspot_metric", columnIndex=2, rowIndex=3, - properties={ - @WidgetProperty(key = "metric", type = WidgetPropertyType.METRIC, defaultValue = "function_complexity"), - @WidgetProperty(key = "title", type = WidgetPropertyType.STRING, defaultValue = "Highest average method complexity") + widget = dashboard.addWidget("hotspot_metric", 1, 3); + widget.addProperty("metric", "complexity"); + widget.addProperty("title", "Highest complexity"); - }), - @DashboardWidget(id="hotspot_metric", columnIndex=2, rowIndex=4, - properties={ - @WidgetProperty(key = "metric", type = WidgetPropertyType.METRIC, defaultValue = "public_undocumented_api"), - @WidgetProperty(key = "title", type = WidgetPropertyType.STRING, defaultValue = "Most undocumented APIs") + widget = dashboard.addWidget("hotspot_metric", 1, 4); + widget.addProperty("metric", "duplicated_lines"); + widget.addProperty("title", "Highest duplications"); - }) -}) -/** - * Hotspot dashboard for Sonar - */ -public class HotspotsDashboard extends AbstractDashboard implements Dashboard { + widget = dashboard.addWidget("hotspot_most_violated_resources", 2, 1); - @Override - public String getId() { - return "sonar-hotspots-dashboard"; - } + widget = dashboard.addWidget("hotspot_metric", 2, 2); + widget.addProperty("metric", "uncovered_lines"); + widget.addProperty("title", "Highest untested lines"); - @Override - public String getName() { - return "Hotspots"; - } - - @Override - public String getLayout() { - return DashboardLayouts.TWO_COLUMNS; + widget = dashboard.addWidget("hotspot_metric", 2, 3); + widget.addProperty("metric", "function_complexity"); + widget.addProperty("title", "Highest average method complexity"); + + widget = dashboard.addWidget("hotspot_metric", 2, 4); + widget.addProperty("metric", "public_undocumented_api"); + widget.addProperty("title", "Most undocumented APIs"); + + return dashboard; } }
\ No newline at end of file diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/dashboards/SonarMainDashboard.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/dashboards/SonarMainDashboard.java index 820419a462d..8b81c8b747e 100644 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/dashboards/SonarMainDashboard.java +++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/dashboards/SonarMainDashboard.java @@ -19,43 +19,30 @@ */ package org.sonar.plugins.core.dashboards; -import org.sonar.api.web.AbstractDashboard; -import org.sonar.api.web.Dashboard; -import org.sonar.api.web.DashboardLayouts; -import org.sonar.api.web.DashboardWidget; -import org.sonar.api.web.DashboardWidgets; +import org.sonar.api.web.dashboard.Dashboard; +import org.sonar.api.web.dashboard.DashboardLayouts; +import org.sonar.api.web.dashboard.DashboardTemplate; -@DashboardWidgets ({ - @DashboardWidget(id="size", columnIndex=1, rowIndex=1), - @DashboardWidget(id="comments_duplications", columnIndex=1, rowIndex=2), - @DashboardWidget(id="complexity", columnIndex=1, rowIndex=3), - @DashboardWidget(id="code_coverage", columnIndex=1, rowIndex=4), - @DashboardWidget(id="events", columnIndex=1, rowIndex=5), - @DashboardWidget(id="description", columnIndex=1, rowIndex=6), - @DashboardWidget(id="rules", columnIndex=2, rowIndex=1), - @DashboardWidget(id="alerts", columnIndex=2, rowIndex=2), - @DashboardWidget(id="file_design", columnIndex=2, rowIndex=3), - @DashboardWidget(id="package_design", columnIndex=2, rowIndex=4), - @DashboardWidget(id="ckjm", columnIndex=2, rowIndex=5) -}) /** * Default dashboard for Sonar */ -public class SonarMainDashboard extends AbstractDashboard implements Dashboard { +public class SonarMainDashboard extends DashboardTemplate { @Override - public String getId() { - return "sonar-main-dashboard"; - } - - @Override - public String getName() { - return "Dashboard"; - } - - @Override - public String getLayout() { - return DashboardLayouts.TWO_COLUMNS; + public org.sonar.api.web.dashboard.Dashboard createDashboard() { + Dashboard dashboard = Dashboard.createDashboard("sonar-main", "Dashboard", DashboardLayouts.TWO_COLUMNS); + dashboard.addWidget("size", 1, 1); + dashboard.addWidget("comments_duplications", 1, 2); + dashboard.addWidget("complexity", 1, 3); + dashboard.addWidget("code_coverage", 1, 4); + dashboard.addWidget("events", 1, 5); + dashboard.addWidget("description", 1, 6); + dashboard.addWidget("rules", 2, 1); + dashboard.addWidget("alerts", 2, 2); + dashboard.addWidget("file_design", 2, 3); + dashboard.addWidget("package_design", 2, 4); + dashboard.addWidget("ckjm", 2, 5); + return dashboard; } }
\ 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 60f4c525a91..78585d8bd10 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 @@ -449,11 +449,11 @@ property.category.server_id=Server ID # #------------------------------------------------------------------------------ -dashboard.sonar-main-dashboard.name=Dashboard -dashboard.sonar-main-dashboard.description=Default dashboard +dashboard.sonar-main.name=Dashboard +dashboard.sonar-main.description=Default dashboard -dashboard.sonar-hotspots-dashboard.name=Hotspots -dashboard.sonar-hotspots-dashboard.description=Most useful hotspots widgets +dashboard.sonar-hotspots.name=Hotspots +dashboard.sonar-hotspots.description=Most useful hotspots widgets #------------------------------------------------------------------------------ |