From: Simon Brandhof Date: Tue, 26 May 2015 21:24:27 +0000 (+0200) Subject: SONAR-6370 move server extensions out of core plugin X-Git-Tag: 5.2-RC1~1806 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=d228fadfa0c0cc7284d4920c9bb485049ff3f68f;p=sonarqube.git SONAR-6370 move server extensions out of core plugin --- diff --git a/plugins/sonar-core-plugin/pom.xml b/plugins/sonar-core-plugin/pom.xml index f81408953c1..3df82a92539 100644 --- a/plugins/sonar-core-plugin/pom.xml +++ b/plugins/sonar-core-plugin/pom.xml @@ -68,11 +68,6 @@ mockito-core test - - org.reflections - reflections - test - org.dbunit dbunit @@ -100,35 +95,7 @@ - - - ${basedir}/src/main/resources - - - ${basedir}/src/test/resources - - - - - org.codehaus.sonar - sonar-dev-maven-plugin - - - trim - process-resources - - trim - - - ${project.build.outputDirectory} - - **/*.erb - - - - - org.codehaus.sonar sonar-packaging-maven-plugin diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/CorePlugin.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/CorePlugin.java index 7a6fdb979a2..0b1883d954b 100644 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/CorePlugin.java +++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/CorePlugin.java @@ -20,21 +20,14 @@ package org.sonar.plugins.core; import com.google.common.collect.ImmutableList; +import java.util.List; import org.sonar.api.CoreProperties; import org.sonar.api.Properties; import org.sonar.api.Property; import org.sonar.api.PropertyType; import org.sonar.api.SonarPlugin; -import org.sonar.plugins.core.charts.DistributionAreaChart; -import org.sonar.plugins.core.charts.DistributionBarChart; -import org.sonar.plugins.core.dashboards.GlobalDefaultDashboard; -import org.sonar.plugins.core.dashboards.ProjectDefaultDashboard; -import org.sonar.plugins.core.dashboards.ProjectIssuesDashboard; -import org.sonar.plugins.core.dashboards.ProjectTimeMachineDashboard; import org.sonar.plugins.core.issue.CountFalsePositivesDecorator; import org.sonar.plugins.core.issue.CountUnresolvedIssuesDecorator; -import org.sonar.plugins.core.measurefilters.MyFavouritesFilter; -import org.sonar.plugins.core.measurefilters.ProjectFilter; import org.sonar.plugins.core.notifications.alerts.NewAlerts; import org.sonar.plugins.core.security.ApplyProjectRolesDecorator; import org.sonar.plugins.core.sensors.BranchCoverageDecorator; @@ -57,38 +50,6 @@ import org.sonar.plugins.core.timemachine.NewItCoverageFileAnalyzer; import org.sonar.plugins.core.timemachine.NewOverallCoverageFileAnalyzer; import org.sonar.plugins.core.timemachine.TimeMachineConfigurationPersister; import org.sonar.plugins.core.timemachine.VariationDecorator; -import org.sonar.plugins.core.widgets.AlertsWidget; -import org.sonar.plugins.core.widgets.BubbleChartWidget; -import org.sonar.plugins.core.widgets.ComplexityWidget; -import org.sonar.plugins.core.widgets.CoverageWidget; -import org.sonar.plugins.core.widgets.CustomMeasuresWidget; -import org.sonar.plugins.core.widgets.DebtOverviewWidget; -import org.sonar.plugins.core.widgets.DescriptionWidget; -import org.sonar.plugins.core.widgets.DocumentationCommentsWidget; -import org.sonar.plugins.core.widgets.DuplicationsWidget; -import org.sonar.plugins.core.widgets.EventsWidget; -import org.sonar.plugins.core.widgets.HotspotMetricWidget; -import org.sonar.plugins.core.widgets.ItCoverageWidget; -import org.sonar.plugins.core.widgets.ProjectFileCloudWidget; -import org.sonar.plugins.core.widgets.SizeWidget; -import org.sonar.plugins.core.widgets.TechnicalDebtPyramidWidget; -import org.sonar.plugins.core.widgets.TimeMachineWidget; -import org.sonar.plugins.core.widgets.TimelineWidget; -import org.sonar.plugins.core.widgets.TreemapWidget; -import org.sonar.plugins.core.widgets.WelcomeWidget; -import org.sonar.plugins.core.widgets.issues.ActionPlansWidget; -import org.sonar.plugins.core.widgets.issues.IssueFilterWidget; -import org.sonar.plugins.core.widgets.issues.IssueTagCloudWidget; -import org.sonar.plugins.core.widgets.issues.IssuesWidget; -import org.sonar.plugins.core.widgets.issues.ProjectIssueFilterWidget; -import org.sonar.plugins.core.widgets.measures.MeasureFilterAsBubbleChartWidget; -import org.sonar.plugins.core.widgets.measures.MeasureFilterAsCloudWidget; -import org.sonar.plugins.core.widgets.measures.MeasureFilterAsHistogramWidget; -import org.sonar.plugins.core.widgets.measures.MeasureFilterAsPieChartWidget; -import org.sonar.plugins.core.widgets.measures.MeasureFilterAsTreemapWidget; -import org.sonar.plugins.core.widgets.measures.MeasureFilterListWidget; - -import java.util.List; @Properties({ @Property( @@ -258,55 +219,9 @@ public final class CorePlugin extends SonarPlugin { DefaultResourceTypes.class, UserManagedMetrics.class, - // measure filters - ProjectFilter.class, - MyFavouritesFilter.class, - - // widgets - AlertsWidget.class, - CoverageWidget.class, - ItCoverageWidget.class, - DescriptionWidget.class, - ComplexityWidget.class, - IssuesWidget.class, - SizeWidget.class, - EventsWidget.class, - CustomMeasuresWidget.class, - TimelineWidget.class, - BubbleChartWidget.class, - TimeMachineWidget.class, - HotspotMetricWidget.class, - TreemapWidget.class, - MeasureFilterListWidget.class, - MeasureFilterAsTreemapWidget.class, - WelcomeWidget.class, - DocumentationCommentsWidget.class, - DuplicationsWidget.class, - TechnicalDebtPyramidWidget.class, - MeasureFilterAsPieChartWidget.class, - MeasureFilterAsCloudWidget.class, - MeasureFilterAsHistogramWidget.class, - MeasureFilterAsBubbleChartWidget.class, - ProjectFileCloudWidget.class, - DebtOverviewWidget.class, - - // dashboards - ProjectDefaultDashboard.class, - ProjectIssuesDashboard.class, - ProjectTimeMachineDashboard.class, - GlobalDefaultDashboard.class, - - // chart - DistributionBarChart.class, - DistributionAreaChart.class, - // issues CountUnresolvedIssuesDecorator.class, CountFalsePositivesDecorator.class, - ActionPlansWidget.class, - IssueFilterWidget.class, - ProjectIssueFilterWidget.class, - IssueTagCloudWidget.class, // batch UnitTestDecorator.class, diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/charts/DistributionAreaChart.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/charts/DistributionAreaChart.java deleted file mode 100644 index 3687c85df9a..00000000000 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/charts/DistributionAreaChart.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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 this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.plugins.core.charts; - -import org.apache.commons.lang.StringUtils; -import org.jfree.chart.axis.CategoryAxis; -import org.jfree.chart.axis.NumberAxis; -import org.jfree.chart.plot.CategoryPlot; -import org.jfree.chart.plot.Plot; -import org.jfree.chart.renderer.category.AreaRenderer; -import org.jfree.data.category.DefaultCategoryDataset; -import org.sonar.api.charts.AbstractChart; -import org.sonar.api.charts.ChartParameters; - -import java.text.NumberFormat; - -public class DistributionAreaChart extends AbstractChart { - private static final String PARAM_COLORS = "c"; - - @Override - public String getKey() { - return "distarea"; - } - - @Override - protected Plot getPlot(ChartParameters params) { - DefaultCategoryDataset dataset = createDataset(params); - - CategoryAxis domainAxis = new CategoryAxis(); - domainAxis.setCategoryMargin(0.0); - domainAxis.setLowerMargin(0.0); - domainAxis.setUpperMargin(0.0); - - NumberAxis rangeAxis = new NumberAxis(); - rangeAxis.setNumberFormatOverride(NumberFormat.getIntegerInstance(params.getLocale())); - rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); - - AreaRenderer renderer = new AreaRenderer(); - CategoryPlot plot = new CategoryPlot(dataset, domainAxis, rangeAxis, renderer); - plot.setForegroundAlpha(0.5f); - plot.setDomainGridlinesVisible(true); - configureColors(dataset, plot, params.getValues(PARAM_COLORS, ",")); - return plot; - } - - private DefaultCategoryDataset createDataset(ChartParameters params) { - DefaultCategoryDataset dataset = new DefaultCategoryDataset(); - - String[] series = params.getValues("v", "|", true); - int index = 0; - while (index < series.length) { - String[] pairs = StringUtils.split(series[index], ";"); - if (pairs.length == 0) { - dataset.addValue((Number)0.0, index, "0"); - - } else { - for (String pair : pairs) { - String[] keyValue = StringUtils.split(pair, "="); - double val = Double.parseDouble(keyValue[1]); - dataset.addValue((Number) val, index, keyValue[0]); - } - } - index++; - } - return dataset; - } -} diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/charts/DistributionBarChart.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/charts/DistributionBarChart.java deleted file mode 100644 index ef021132555..00000000000 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/charts/DistributionBarChart.java +++ /dev/null @@ -1,130 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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 this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.plugins.core.charts; - -import org.apache.commons.lang.StringUtils; -import org.jfree.chart.axis.CategoryAxis; -import org.jfree.chart.axis.NumberAxis; -import org.jfree.chart.plot.CategoryPlot; -import org.jfree.chart.plot.Plot; -import org.jfree.chart.renderer.category.BarRenderer; -import org.jfree.data.category.DefaultCategoryDataset; -import org.sonar.api.charts.AbstractChart; -import org.sonar.api.charts.ChartParameters; - -import java.awt.*; -import java.text.DecimalFormat; - -public class DistributionBarChart extends AbstractChart { - - - public static final String PARAM_VALUES = "v"; - public static final String PARAM_COLORS = "c"; - public static final String PARAM_Y_SUFFIX = "ysuf"; - public static final String PARAM_X_SUFFIX = "xsuf"; - public static final String PARAM_FONT_SIZE = "fs"; - - @Override - public String getKey() { - return "distbar"; - } - - @Override - public Plot getPlot(ChartParameters params) { - CategoryPlot plot = generateJFreeChart(params); - plot.setOutlinePaint(OUTLINE_COLOR); - plot.setDomainGridlinePaint(GRID_COLOR); - plot.setRangeGridlinePaint(GRID_COLOR); - return plot; - } - - private CategoryPlot generateJFreeChart(ChartParameters params) { - DefaultCategoryDataset dataset = new DefaultCategoryDataset(); - CategoryPlot plot = new CategoryPlot(); - - Font font = getFont(params.getValue(PARAM_FONT_SIZE)); - configureDomainAxis(plot, font); - configureRangeAxis(plot, params.getValue(PARAM_Y_SUFFIX, "", true), font); - configureRenderer(plot); - configureValues(dataset, params.getValues(PARAM_VALUES, "|", true), params.getValue(PARAM_X_SUFFIX, "", true)); - configureColors(dataset, plot, params.getValues(PARAM_COLORS, ",")); - - plot.setDataset(dataset); - return plot; - } - - static void configureValues(DefaultCategoryDataset dataset, String[] series, String xSuffix) { - int index = 0; - while (index < series.length) { - String[] pairs = StringUtils.split(series[index], ";"); - if (pairs.length == 0) { - dataset.addValue((Number) 0.0, index, "0"); - - } else { - for (String pair : pairs) { - String[] keyValue = StringUtils.split(pair, "="); - double val = Double.parseDouble(keyValue[1]); - dataset.addValue((Number) val, index, keyValue[0] + xSuffix); - } - } - index++; - } - - } - - private void configureRenderer(CategoryPlot plot) { - BarRenderer renderer = new BarRenderer(); - renderer.setDrawBarOutline(true); - renderer.setSeriesItemLabelsVisible(0, true); - renderer.setItemMargin(0); - plot.setRenderer(renderer); - } - - private void configureDomainAxis(CategoryPlot plot, Font font) { - CategoryAxis categoryAxis = new CategoryAxis(); - categoryAxis.setTickMarksVisible(true); - categoryAxis.setTickLabelFont(font); - categoryAxis.setTickLabelPaint(OUTLINE_COLOR); - plot.setDomainAxis(categoryAxis); - plot.setDomainGridlinesVisible(false); - } - - private Font getFont(String fontSize) { - int size = FONT_SIZE; - if (!StringUtils.isBlank(fontSize)) { - size = Integer.parseInt(fontSize); - } - return new Font("SansSerif", Font.PLAIN, size); - } - - private void configureRangeAxis(CategoryPlot plot, String valueLabelSuffix, Font font) { - NumberAxis numberAxis = new NumberAxis(); - numberAxis.setUpperMargin(0.3); - numberAxis.setTickLabelFont(font); - numberAxis.setTickLabelPaint(OUTLINE_COLOR); - String suffix = ""; - if (valueLabelSuffix != null && !"".equals(valueLabelSuffix)) { - suffix = new StringBuilder().append("'").append(valueLabelSuffix).append("'").toString(); - } - numberAxis.setNumberFormatOverride(new DecimalFormat("0" + suffix)); - numberAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); - plot.setRangeAxis(numberAxis); - } -} diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/charts/package-info.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/charts/package-info.java deleted file mode 100644 index 6d9fc80d519..00000000000 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/charts/package-info.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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 this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -@ParametersAreNonnullByDefault -package org.sonar.plugins.core.charts; - -import javax.annotation.ParametersAreNonnullByDefault; diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/dashboards/GlobalDefaultDashboard.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/dashboards/GlobalDefaultDashboard.java deleted file mode 100644 index 5e204b18537..00000000000 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/dashboards/GlobalDefaultDashboard.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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 this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.plugins.core.dashboards; - -import org.sonar.api.web.Dashboard; -import org.sonar.api.web.DashboardLayout; -import org.sonar.api.web.DashboardTemplate; -import org.sonar.core.measure.db.MeasureFilterDao; -import org.sonar.core.measure.db.MeasureFilterDto; -import org.sonar.plugins.core.measurefilters.MyFavouritesFilter; -import org.sonar.plugins.core.measurefilters.ProjectFilter; -import org.sonar.plugins.core.widgets.WelcomeWidget; -import org.sonar.plugins.core.widgets.measures.MeasureFilterAsTreemapWidget; -import org.sonar.plugins.core.widgets.measures.MeasureFilterListWidget; - -/** - * Projects global dashboard for Sonar - * - * @since 3.1 - */ -public final class GlobalDefaultDashboard extends DashboardTemplate { - - private MeasureFilterDao filterDao; - - public GlobalDefaultDashboard(MeasureFilterDao filterDao) { - this.filterDao = filterDao; - } - - @Override - public Dashboard createDashboard() { - Dashboard dashboard = Dashboard.create() - .setGlobal(true) - .setLayout(DashboardLayout.TWO_COLUMNS); - - dashboard.addWidget(WelcomeWidget.ID, 1); - addMyFavouritesWidget(dashboard); - addProjectsWidgets(dashboard); - - return dashboard; - } - - private void addMyFavouritesWidget(Dashboard dashboard) { - MeasureFilterDto filter = findSystemFilter(MyFavouritesFilter.NAME); - if (filter != null) { - dashboard - .addWidget(MeasureFilterListWidget.ID, 1) - .setProperty(MeasureFilterListWidget.FILTER_PROPERTY, filter.getId().toString()) - .setProperty(MeasureFilterListWidget.PAGE_SIZE_PROPERTY, "50"); - } - } - - private void addProjectsWidgets(Dashboard dashboard) { - MeasureFilterDto filter = findSystemFilter(ProjectFilter.NAME); - if (filter != null) { - dashboard - .addWidget(MeasureFilterListWidget.ID, 2) - .setProperty(MeasureFilterListWidget.FILTER_PROPERTY, filter.getId().toString()) - .setProperty(MeasureFilterListWidget.PAGE_SIZE_PROPERTY, "20"); - - dashboard - .addWidget(MeasureFilterAsTreemapWidget.ID, 2) - .setProperty(MeasureFilterListWidget.FILTER_PROPERTY, filter.getId().toString()) - .setProperty(MeasureFilterAsTreemapWidget.SIZE_METRIC_PROPERTY, "ncloc") - .setProperty(MeasureFilterAsTreemapWidget.COLOR_METRIC_PROPERTY, "coverage"); - } - } - - @Override - public String getName() { - return "Home"; - } - - private MeasureFilterDto findSystemFilter(String name) { - return filterDao.findSystemFilterByName(name); - } -} diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/dashboards/ProjectDefaultDashboard.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/dashboards/ProjectDefaultDashboard.java deleted file mode 100644 index 61d88fa3f59..00000000000 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/dashboards/ProjectDefaultDashboard.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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 this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.plugins.core.dashboards; - -import org.sonar.api.web.Dashboard; -import org.sonar.api.web.DashboardLayout; -import org.sonar.api.web.DashboardTemplate; - -/** - * Default dashboard - * - * @since 2.13 - */ -public final class ProjectDefaultDashboard extends DashboardTemplate { - - @Override - public String getName() { - return "Dashboard"; - } - - @Override - public Dashboard createDashboard() { - Dashboard dashboard = Dashboard.create(); - dashboard.setLayout(DashboardLayout.TWO_COLUMNS); - addFirstColumn(dashboard); - addSecondColumn(dashboard); - return dashboard; - } - - private void addFirstColumn(Dashboard dashboard) { - dashboard.addWidget("size", 1); - dashboard.addWidget("duplications", 1); - dashboard.addWidget("complexity", 1); - dashboard.addWidget("events", 1); - dashboard.addWidget("description", 1); - } - - private void addSecondColumn(Dashboard dashboard) { - dashboard.addWidget("debt_overview", 2); - dashboard.addWidget("rules", 2); - dashboard.addWidget("alerts", 2); - dashboard.addWidget("code_coverage", 2); - } - -} diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/dashboards/ProjectIssuesDashboard.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/dashboards/ProjectIssuesDashboard.java deleted file mode 100644 index 810211751ad..00000000000 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/dashboards/ProjectIssuesDashboard.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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 this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.plugins.core.dashboards; - -import com.google.common.base.Preconditions; -import org.sonar.api.web.Dashboard; -import org.sonar.api.web.DashboardLayout; -import org.sonar.api.web.DashboardTemplate; -import org.sonar.core.issue.db.IssueFilterDao; -import org.sonar.core.issue.db.IssueFilterDto; -import org.sonar.plugins.core.widgets.issues.ProjectIssueFilterWidget; - -/** - * Issues dashboard for Sonar - * - * @since 3.6 - */ -public final class ProjectIssuesDashboard extends DashboardTemplate { - - private final IssueFilterDao issueFilterDao; - - public ProjectIssuesDashboard(IssueFilterDao issueFilterDao) { - this.issueFilterDao = issueFilterDao; - } - - @Override - public String getName() { - return "Issues"; - } - - @Override - public Dashboard createDashboard() { - Dashboard dashboard = Dashboard.create(); - dashboard.setLayout(DashboardLayout.TWO_COLUMNS); - - IssueFilterDto unresolvedIssues = getIssueFilterByName("Unresolved Issues"); - IssueFilterDto hiddenDebt = getIssueFilterByName("False Positive and Won't Fix Issues"); - IssueFilterDto myUnresolvedIssues = getIssueFilterByName("My Unresolved Issues"); - - addFirstColumn(dashboard, unresolvedIssues); - addSecondColumn(dashboard, unresolvedIssues, hiddenDebt, myUnresolvedIssues); - return dashboard; - } - - private IssueFilterDto getIssueFilterByName(String name) { - IssueFilterDto filter = issueFilterDao.selectProvidedFilterByName(name); - Preconditions.checkState(filter != null, String.format("Could not find a provided issue filter with name '%s'", name)); - return filter; - } - - private void addFirstColumn(Dashboard dashboard, IssueFilterDto unresolvedIssues) { - // Unresolved issues by status - dashboard.addWidget(ProjectIssueFilterWidget.ID, 1) - .setProperty(ProjectIssueFilterWidget.FILTER_PROPERTY, Long.toString(unresolvedIssues.getId())) - .setProperty(ProjectIssueFilterWidget.DISTRIBUTION_AXIS_PROPERTY, "statuses"); - // Action plans - dashboard.addWidget("action_plans", 1); - } - - private void addSecondColumn(Dashboard dashboard, IssueFilterDto unresolvedIssues, IssueFilterDto hiddenDebt, IssueFilterDto myUnresolvedIssues) { - // Unresolved issues by assignee - dashboard.addWidget(ProjectIssueFilterWidget.ID, 2) - .setProperty(ProjectIssueFilterWidget.FILTER_PROPERTY, Long.toString(unresolvedIssues.getId())) - .setProperty(ProjectIssueFilterWidget.DISTRIBUTION_AXIS_PROPERTY, "assignees"); - // My unresolved issues - dashboard.addWidget(ProjectIssueFilterWidget.ID, 2) - .setProperty("filter", Long.toString(myUnresolvedIssues.getId())); - // False positive and won't fix issues by resolution - dashboard.addWidget(ProjectIssueFilterWidget.ID, 2) - .setProperty(ProjectIssueFilterWidget.FILTER_PROPERTY, Long.toString(hiddenDebt.getId())) - .setProperty(ProjectIssueFilterWidget.DISTRIBUTION_AXIS_PROPERTY, "resolutions"); - } - -} diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/dashboards/ProjectTimeMachineDashboard.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/dashboards/ProjectTimeMachineDashboard.java deleted file mode 100644 index e0024db1509..00000000000 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/dashboards/ProjectTimeMachineDashboard.java +++ /dev/null @@ -1,127 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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 this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.plugins.core.dashboards; - -import org.sonar.api.measures.CoreMetrics; -import org.sonar.api.web.Dashboard; -import org.sonar.api.web.Dashboard.Widget; -import org.sonar.api.web.DashboardLayout; -import org.sonar.api.web.DashboardTemplate; - -/** - * Time Machine dashboard for Sonar - * - * @since 3.0 - */ -public final class ProjectTimeMachineDashboard extends DashboardTemplate { - - private static final String METRIC1 = "metric1"; - private static final String METRIC2 = "metric2"; - private static final String METRIC3 = "metric3"; - private static final String METRIC4 = "metric4"; - private static final String METRIC5 = "metric5"; - private static final String METRIC6 = "metric6"; - private static final String METRIC7 = "metric7"; - private static final String METRIC8 = "metric8"; - - @Override - public String getName() { - return "TimeMachine"; - } - - @Override - public Dashboard createDashboard() { - Dashboard dashboard = Dashboard.create(); - dashboard.setLayout(DashboardLayout.TWO_COLUMNS); - addFirstColumn(dashboard); - addSecondColumn(dashboard); - return dashboard; - } - - private void addFirstColumn(Dashboard dashboard) { - Widget timelineWidget = dashboard.addWidget("timeline", 1); - timelineWidget.setProperty(METRIC1, CoreMetrics.COMPLEXITY_KEY); - timelineWidget.setProperty(METRIC2, CoreMetrics.TECHNICAL_DEBT_KEY); - timelineWidget.setProperty(METRIC3, CoreMetrics.COVERAGE_KEY); - - Widget sizeTimeMachineWidget = addTimeMachineWidgetOnFirstColumn(dashboard); - sizeTimeMachineWidget.setProperty(METRIC1, CoreMetrics.NCLOC_KEY); - sizeTimeMachineWidget.setProperty(METRIC2, CoreMetrics.LINES_KEY); - sizeTimeMachineWidget.setProperty(METRIC3, CoreMetrics.STATEMENTS_KEY); - sizeTimeMachineWidget.setProperty(METRIC4, CoreMetrics.FILES_KEY); - sizeTimeMachineWidget.setProperty(METRIC5, CoreMetrics.CLASSES_KEY); - sizeTimeMachineWidget.setProperty(METRIC6, CoreMetrics.FUNCTIONS_KEY); - sizeTimeMachineWidget.setProperty(METRIC7, CoreMetrics.ACCESSORS_KEY); - - Widget commentsTimeMachineWidget = addTimeMachineWidgetOnFirstColumn(dashboard); - commentsTimeMachineWidget.setProperty(METRIC1, CoreMetrics.COMMENT_LINES_DENSITY_KEY); - commentsTimeMachineWidget.setProperty(METRIC2, CoreMetrics.COMMENT_LINES_KEY); - commentsTimeMachineWidget.setProperty(METRIC3, CoreMetrics.PUBLIC_DOCUMENTED_API_DENSITY_KEY); - commentsTimeMachineWidget.setProperty(METRIC4, CoreMetrics.PUBLIC_UNDOCUMENTED_API_KEY); - - Widget duplicationTimeMachineWidget = addTimeMachineWidgetOnFirstColumn(dashboard); - duplicationTimeMachineWidget.setProperty(METRIC1, CoreMetrics.DUPLICATED_LINES_DENSITY_KEY); - duplicationTimeMachineWidget.setProperty(METRIC2, CoreMetrics.DUPLICATED_LINES_KEY); - duplicationTimeMachineWidget.setProperty(METRIC3, CoreMetrics.DUPLICATED_BLOCKS_KEY); - duplicationTimeMachineWidget.setProperty(METRIC4, CoreMetrics.DUPLICATED_FILES_KEY); - } - - private void addSecondColumn(Dashboard dashboard) { - Widget rulesTimeMachineWidget = addTimeMachineWidgetOnSecondColumn(dashboard); - rulesTimeMachineWidget.setProperty(METRIC1, CoreMetrics.VIOLATIONS_KEY); - rulesTimeMachineWidget.setProperty(METRIC2, CoreMetrics.BLOCKER_VIOLATIONS_KEY); - rulesTimeMachineWidget.setProperty(METRIC3, CoreMetrics.CRITICAL_VIOLATIONS_KEY); - rulesTimeMachineWidget.setProperty(METRIC4, CoreMetrics.MAJOR_VIOLATIONS_KEY); - rulesTimeMachineWidget.setProperty(METRIC5, CoreMetrics.MINOR_VIOLATIONS_KEY); - rulesTimeMachineWidget.setProperty(METRIC6, CoreMetrics.INFO_VIOLATIONS_KEY); - rulesTimeMachineWidget.setProperty(METRIC7, CoreMetrics.TECHNICAL_DEBT_KEY); - - Widget complexityTimeMachineWidget = addTimeMachineWidgetOnSecondColumn(dashboard); - complexityTimeMachineWidget.setProperty(METRIC1, CoreMetrics.COMPLEXITY_KEY); - complexityTimeMachineWidget.setProperty(METRIC2, CoreMetrics.FUNCTION_COMPLEXITY_KEY); - complexityTimeMachineWidget.setProperty(METRIC3, CoreMetrics.CLASS_COMPLEXITY_KEY); - complexityTimeMachineWidget.setProperty(METRIC4, CoreMetrics.FILE_COMPLEXITY_KEY); - - Widget testsTimeMachineWidget = addTimeMachineWidgetOnSecondColumn(dashboard); - testsTimeMachineWidget.setProperty(METRIC1, CoreMetrics.COVERAGE_KEY); - testsTimeMachineWidget.setProperty(METRIC2, CoreMetrics.LINE_COVERAGE_KEY); - testsTimeMachineWidget.setProperty(METRIC3, CoreMetrics.BRANCH_COVERAGE_KEY); - testsTimeMachineWidget.setProperty(METRIC4, CoreMetrics.TEST_SUCCESS_DENSITY_KEY); - testsTimeMachineWidget.setProperty(METRIC5, CoreMetrics.TEST_FAILURES_KEY); - testsTimeMachineWidget.setProperty(METRIC6, CoreMetrics.TEST_ERRORS_KEY); - testsTimeMachineWidget.setProperty(METRIC7, CoreMetrics.TESTS_KEY); - testsTimeMachineWidget.setProperty(METRIC8, CoreMetrics.TEST_EXECUTION_TIME_KEY); - } - - private Widget addTimeMachineWidgetOnFirstColumn(Dashboard dashboard) { - return addTimeMachineWidget(dashboard, 1); - } - - private Widget addTimeMachineWidgetOnSecondColumn(Dashboard dashboard) { - return addTimeMachineWidget(dashboard, 2); - } - - private Widget addTimeMachineWidget(Dashboard dashboard, int columnIndex) { - Widget widget = dashboard.addWidget("time_machine", columnIndex); - widget.setProperty("displaySparkLine", "true"); - return widget; - } - -} diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/dashboards/package-info.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/dashboards/package-info.java deleted file mode 100644 index d901586ae25..00000000000 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/dashboards/package-info.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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 this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -@ParametersAreNonnullByDefault -package org.sonar.plugins.core.dashboards; - -import javax.annotation.ParametersAreNonnullByDefault; diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/measurefilters/MyFavouritesFilter.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/measurefilters/MyFavouritesFilter.java deleted file mode 100644 index f5fb03feb20..00000000000 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/measurefilters/MyFavouritesFilter.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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 this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.plugins.core.measurefilters; - -import org.sonar.api.measures.CoreMetrics; -import org.sonar.api.web.Filter; -import org.sonar.api.web.FilterColumn; -import org.sonar.api.web.FilterTemplate; - -/** - * Default filter for looking for user favourite resources. - * - * @since 3.1 - */ -public class MyFavouritesFilter extends FilterTemplate { - public static final String NAME = "My favourites"; - - @Override - public String getName() { - return NAME; - } - - @Override - public Filter createFilter() { - return Filter.create() - .setDisplayAs(Filter.LIST) - .setFavouritesOnly(true) - .add(FilterColumn.create("metric", CoreMetrics.ALERT_STATUS_KEY, FilterColumn.DESC, false)) - .add(FilterColumn.create("name", null, FilterColumn.ASC, false)) - .add(FilterColumn.create("date", null, FilterColumn.DESC, false)); - } -} diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/measurefilters/ProjectFilter.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/measurefilters/ProjectFilter.java deleted file mode 100644 index 19e33ac10dd..00000000000 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/measurefilters/ProjectFilter.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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 this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.plugins.core.measurefilters; - -import org.sonar.api.measures.CoreMetrics; -import org.sonar.api.resources.Qualifiers; -import org.sonar.api.web.Criterion; -import org.sonar.api.web.Filter; -import org.sonar.api.web.FilterColumn; -import org.sonar.api.web.FilterTemplate; - -/** - * Default projects filter. - * - * @since 3.1 - */ -public class ProjectFilter extends FilterTemplate { - public static final String NAME = "Projects"; - - @Override - public String getName() { - return NAME; - } - - @Override - public Filter createFilter() { - return Filter.create() - .setDisplayAs(Filter.LIST) - .add(Criterion.createForQualifier(Qualifiers.PROJECT)) - .add(FilterColumn.create("metric", CoreMetrics.ALERT_STATUS_KEY, FilterColumn.DESC, false)) - .add(FilterColumn.create("name", null, FilterColumn.ASC, false)) - .add(FilterColumn.create("version", null, FilterColumn.DESC, false)) - .add(FilterColumn.create("metric", CoreMetrics.NCLOC_KEY, FilterColumn.DESC, false)) - .add(FilterColumn.create("metric", CoreMetrics.TECHNICAL_DEBT_KEY, FilterColumn.DESC, false)) - .add(FilterColumn.create("date", null, FilterColumn.DESC, false)); - } -} diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/measurefilters/package-info.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/measurefilters/package-info.java deleted file mode 100644 index 4700c0a28ef..00000000000 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/measurefilters/package-info.java +++ /dev/null @@ -1,21 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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 this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -@javax.annotation.ParametersAreNonnullByDefault -package org.sonar.plugins.core.measurefilters; diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/AlertsWidget.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/AlertsWidget.java deleted file mode 100644 index c794e898573..00000000000 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/AlertsWidget.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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 this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.plugins.core.widgets; - -import org.sonar.api.web.*; - -@WidgetProperties({ - @WidgetProperty(key = "show_ok", type = WidgetPropertyType.BOOLEAN, defaultValue = "false"), -}) -@WidgetLayout(WidgetLayoutType.NONE) -public class AlertsWidget extends CoreWidget { - - public AlertsWidget() { - super("alerts", "Alerts", "/org/sonar/plugins/core/widgets/alerts.html.erb"); - } - -} diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/BubbleChartWidget.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/BubbleChartWidget.java deleted file mode 100644 index f583d6e24ea..00000000000 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/BubbleChartWidget.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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 this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.plugins.core.widgets; - -import org.sonar.api.measures.CoreMetrics; -import org.sonar.api.web.WidgetProperties; -import org.sonar.api.web.WidgetProperty; -import org.sonar.api.web.WidgetPropertyType; - -@WidgetProperties({ - @WidgetProperty(key = "chartTitle", type = WidgetPropertyType.STRING), - @WidgetProperty(key = "chartHeight", type = WidgetPropertyType.INTEGER, defaultValue = "300"), - @WidgetProperty(key = "xMetric", type = WidgetPropertyType.METRIC, defaultValue = CoreMetrics.NCLOC_KEY, options = {WidgetConstants.FILTER_OUT_NEW_METRICS}), - @WidgetProperty(key = "yMetric", type = WidgetPropertyType.METRIC, defaultValue = CoreMetrics.VIOLATIONS_KEY, options = {WidgetConstants.FILTER_OUT_NEW_METRICS}), - @WidgetProperty(key = "sizeMetric", type = WidgetPropertyType.METRIC, defaultValue = CoreMetrics.TECHNICAL_DEBT_KEY, options = {WidgetConstants.FILTER_OUT_NEW_METRICS}), - @WidgetProperty(key = "xLogarithmic", type = WidgetPropertyType.BOOLEAN), - @WidgetProperty(key = "yLogarithmic", type = WidgetPropertyType.BOOLEAN) -}) -public class BubbleChartWidget extends CoreWidget { - public BubbleChartWidget() { - super("bubble_chart", "Project File Bubble Chart", "/org/sonar/plugins/core/widgets/bubbleChart.html.erb"); - } -} diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/ComplexityWidget.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/ComplexityWidget.java deleted file mode 100644 index d04a79d5249..00000000000 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/ComplexityWidget.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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 this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.plugins.core.widgets; - -public class ComplexityWidget extends CoreWidget { - - public ComplexityWidget() { - super("complexity", "Complexity", "/org/sonar/plugins/core/widgets/complexity.html.erb"); - } -} diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/CoreWidget.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/CoreWidget.java deleted file mode 100644 index f01a23a57cc..00000000000 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/CoreWidget.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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 this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.plugins.core.widgets; - -import org.sonar.api.web.AbstractRubyTemplate; -import org.sonar.api.web.RubyRailsWidget; - -public abstract class CoreWidget extends AbstractRubyTemplate implements RubyRailsWidget { - private String id, title, templatePath; - - protected CoreWidget(String id, String title, String templatePath) { - this.id = id; - this.title = title; - this.templatePath = templatePath; - } - - @Override - public String getId() { - return id; - } - - @Override - public String getTitle() { - return title; - } - - @Override - protected String getTemplatePath() { - return templatePath; - } -} diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/CoverageWidget.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/CoverageWidget.java deleted file mode 100644 index 273487dbca5..00000000000 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/CoverageWidget.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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 this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.plugins.core.widgets; - -import org.sonar.api.web.UserRole; -import org.sonar.api.web.WidgetCategory; - -@WidgetCategory("Tests") -@UserRole(UserRole.USER) -public class CoverageWidget extends CoreWidget { - - public CoverageWidget() { - super("code_coverage", "Code coverage", "/org/sonar/plugins/core/widgets/coverage.html.erb"); - } -} diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/CustomMeasuresWidget.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/CustomMeasuresWidget.java deleted file mode 100644 index d8b149c8422..00000000000 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/CustomMeasuresWidget.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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 this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.plugins.core.widgets; - -import org.sonar.api.web.WidgetProperties; -import org.sonar.api.web.WidgetProperty; -import org.sonar.api.web.WidgetPropertyType; - -@WidgetProperties({ - @WidgetProperty(key = "metric1", type = WidgetPropertyType.METRIC), - @WidgetProperty(key = "metric2", type = WidgetPropertyType.METRIC), - @WidgetProperty(key = "metric3", type = WidgetPropertyType.METRIC), - @WidgetProperty(key = "metric4", type = WidgetPropertyType.METRIC), - @WidgetProperty(key = "metric5", type = WidgetPropertyType.METRIC), - @WidgetProperty(key = "metric6", type = WidgetPropertyType.METRIC), - @WidgetProperty(key = "metric7", type = WidgetPropertyType.METRIC), - @WidgetProperty(key = "metric8", type = WidgetPropertyType.METRIC), - @WidgetProperty(key = "metric9", type = WidgetPropertyType.METRIC), - @WidgetProperty(key = "metric10", type = WidgetPropertyType.METRIC) -}) -public class CustomMeasuresWidget extends CoreWidget { - public CustomMeasuresWidget() { - super("custom_measures", "Custom Measures", "/org/sonar/plugins/core/widgets/custom_measures.html.erb"); - } -} diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/DebtOverviewWidget.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/DebtOverviewWidget.java deleted file mode 100644 index 9af75bbbdd3..00000000000 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/DebtOverviewWidget.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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 this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -package org.sonar.plugins.core.widgets; - -import org.sonar.api.web.UserRole; -import org.sonar.api.web.WidgetCategory; - -@UserRole(UserRole.USER) -@WidgetCategory("Technical Debt") -public final class DebtOverviewWidget extends CoreWidget { - - public DebtOverviewWidget() { - super("debt_overview", "Technical Debt Overview", "/org/sonar/plugins/core/widgets/debt_overview.erb"); - } -} diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/DescriptionWidget.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/DescriptionWidget.java deleted file mode 100644 index 89baad496c4..00000000000 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/DescriptionWidget.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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 this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.plugins.core.widgets; - -import org.sonar.api.web.WidgetLayout; -import org.sonar.api.web.WidgetLayoutType; - -@WidgetLayout(WidgetLayoutType.NONE) -public class DescriptionWidget extends CoreWidget { - - public DescriptionWidget() { - super("description", "Description", "/org/sonar/plugins/core/widgets/description.html.erb"); - } -} diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/DocumentationCommentsWidget.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/DocumentationCommentsWidget.java deleted file mode 100644 index 38a6a50a2a4..00000000000 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/DocumentationCommentsWidget.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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 this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.plugins.core.widgets; - - -public class DocumentationCommentsWidget extends CoreWidget { - - public DocumentationCommentsWidget() { - super("documentation_comments", "Documentation Metrics", "/org/sonar/plugins/core/widgets/documentation_comments_widget.html.erb"); - } - -} diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/DuplicationsWidget.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/DuplicationsWidget.java deleted file mode 100644 index 30371c07a2b..00000000000 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/DuplicationsWidget.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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 this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.plugins.core.widgets; - -/** - * @author Patroklos PAPAPETROU - */ - -public class DuplicationsWidget extends CoreWidget { - - public DuplicationsWidget() { - super("duplications", "Duplications", "/org/sonar/plugins/core/widgets/duplications_widget.html.erb"); - } - -} diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/EventsWidget.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/EventsWidget.java deleted file mode 100644 index 8cf081d045b..00000000000 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/EventsWidget.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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 this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.plugins.core.widgets; - -public class EventsWidget extends CoreWidget { - - public EventsWidget() { - super("events", "Events", "/org/sonar/plugins/core/widgets/events.html.erb"); - } -} diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/HotspotMetricWidget.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/HotspotMetricWidget.java deleted file mode 100644 index 11986e6f558..00000000000 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/HotspotMetricWidget.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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 this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.plugins.core.widgets; - -import org.sonar.api.web.WidgetCategory; -import org.sonar.api.web.WidgetProperties; -import org.sonar.api.web.WidgetProperty; -import org.sonar.api.web.WidgetPropertyType; - -@WidgetCategory({ "Hotspots" }) -@WidgetProperties({ - @WidgetProperty(key = "title", type = WidgetPropertyType.STRING), - @WidgetProperty(key = "metric", type = WidgetPropertyType.METRIC, defaultValue = "ncloc", options = {WidgetConstants.FILTER_OUT_NEW_METRICS}), - @WidgetProperty(key = "numberOfLines", type = WidgetPropertyType.INTEGER, defaultValue = "5") -}) -public class HotspotMetricWidget extends CoreWidget { - public HotspotMetricWidget() { - super("hotspot_metric", "Metric hotspot", "/org/sonar/plugins/core/widgets/hotspots/hotspot_metric.html.erb"); - } -} diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/ItCoverageWidget.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/ItCoverageWidget.java deleted file mode 100644 index 98f438751c0..00000000000 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/ItCoverageWidget.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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 this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.plugins.core.widgets; - -import org.sonar.api.web.UserRole; -import org.sonar.api.web.WidgetCategory; - -@WidgetCategory("Tests") -@UserRole(UserRole.USER) -public class ItCoverageWidget extends CoreWidget { - - public ItCoverageWidget() { - super("it-coverage", "Integration Test Coverage", "/org/sonar/plugins/core/widgets/it_coverage.html.erb"); - } -} diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/ProjectFileCloudWidget.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/ProjectFileCloudWidget.java deleted file mode 100644 index f712e68b0a1..00000000000 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/ProjectFileCloudWidget.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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 this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -package org.sonar.plugins.core.widgets; - -import org.sonar.api.measures.CoreMetrics; -import org.sonar.api.web.WidgetProperties; -import org.sonar.api.web.WidgetProperty; -import org.sonar.api.web.WidgetPropertyType; - -@WidgetProperties({ - @WidgetProperty(key = "chartTitle", type = WidgetPropertyType.STRING), - @WidgetProperty(key = "colorMetric", type = WidgetPropertyType.METRIC, defaultValue = CoreMetrics.COVERAGE_KEY, options = "type:PERCENT"), - @WidgetProperty(key = "sizeMetric", type = WidgetPropertyType.METRIC, defaultValue = CoreMetrics.COMPLEXITY_KEY, options = {WidgetConstants.FILTER_OUT_NEW_METRICS}), - @WidgetProperty(key = "maxItems", type = WidgetPropertyType.INTEGER, defaultValue = "100") -}) -public class ProjectFileCloudWidget extends CoreWidget { - public ProjectFileCloudWidget() { - super("project_file_cloud", "Project File Word Cloud", "/org/sonar/plugins/core/widgets/project_file_cloud.html.erb"); - } -} diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/SizeWidget.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/SizeWidget.java deleted file mode 100644 index b3330c7833f..00000000000 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/SizeWidget.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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 this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.plugins.core.widgets; - -public class SizeWidget extends CoreWidget { - - public SizeWidget() { - super("size", "Size metrics", "/org/sonar/plugins/core/widgets/size.html.erb"); - } -} diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/TechnicalDebtPyramidWidget.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/TechnicalDebtPyramidWidget.java deleted file mode 100644 index d1c2bcf762c..00000000000 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/TechnicalDebtPyramidWidget.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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 this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.plugins.core.widgets; - -import org.sonar.api.web.UserRole; -import org.sonar.api.web.WidgetCategory; - -@UserRole(UserRole.USER) -@WidgetCategory("Technical Debt") -public final class TechnicalDebtPyramidWidget extends CoreWidget { - - public TechnicalDebtPyramidWidget() { - super("technical_debt_pyramid", "Technical Debt Pyramid", "/org/sonar/plugins/core/widgets/technical_debt_pyramid.html.erb"); - } -} diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/TimeMachineWidget.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/TimeMachineWidget.java deleted file mode 100644 index 7a494b4ea5f..00000000000 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/TimeMachineWidget.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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 this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.plugins.core.widgets; - -import org.sonar.api.web.WidgetCategory; -import org.sonar.api.web.WidgetProperties; -import org.sonar.api.web.WidgetProperty; -import org.sonar.api.web.WidgetPropertyType; - -@WidgetCategory("History") -@WidgetProperties({ - @WidgetProperty(key = "title", type = WidgetPropertyType.STRING), - @WidgetProperty(key = "numberOfColumns", type = WidgetPropertyType.INTEGER, defaultValue = "3"), - @WidgetProperty(key = "displaySparkLine", type = WidgetPropertyType.BOOLEAN), - @WidgetProperty(key = "metric1", type = WidgetPropertyType.METRIC, defaultValue = "ncloc", options = {WidgetConstants.FILTER_OUT_NEW_METRICS}), - @WidgetProperty(key = "metric2", type = WidgetPropertyType.METRIC, options = {WidgetConstants.FILTER_OUT_NEW_METRICS}), - @WidgetProperty(key = "metric3", type = WidgetPropertyType.METRIC, options = {WidgetConstants.FILTER_OUT_NEW_METRICS}), - @WidgetProperty(key = "metric4", type = WidgetPropertyType.METRIC, options = {WidgetConstants.FILTER_OUT_NEW_METRICS}), - @WidgetProperty(key = "metric5", type = WidgetPropertyType.METRIC, options = {WidgetConstants.FILTER_OUT_NEW_METRICS}), - @WidgetProperty(key = "metric6", type = WidgetPropertyType.METRIC, options = {WidgetConstants.FILTER_OUT_NEW_METRICS}), - @WidgetProperty(key = "metric7", type = WidgetPropertyType.METRIC, options = {WidgetConstants.FILTER_OUT_NEW_METRICS}), - @WidgetProperty(key = "metric8", type = WidgetPropertyType.METRIC, options = {WidgetConstants.FILTER_OUT_NEW_METRICS}), - @WidgetProperty(key = "metric9", type = WidgetPropertyType.METRIC, options = {WidgetConstants.FILTER_OUT_NEW_METRICS}), - @WidgetProperty(key = "metric10", type = WidgetPropertyType.METRIC, options = {WidgetConstants.FILTER_OUT_NEW_METRICS}) -}) -public class TimeMachineWidget extends CoreWidget { - public TimeMachineWidget() { - super("time_machine", "History Table", "/org/sonar/plugins/core/widgets/time_machine.html.erb"); - } -} diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/TimelineWidget.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/TimelineWidget.java deleted file mode 100644 index 26533d23f40..00000000000 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/TimelineWidget.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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 this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.plugins.core.widgets; - -import org.sonar.api.web.WidgetCategory; -import org.sonar.api.web.WidgetProperties; -import org.sonar.api.web.WidgetProperty; -import org.sonar.api.web.WidgetPropertyType; - -@WidgetCategory("History") -@WidgetProperties({ - @WidgetProperty(key = "chartTitle", type = WidgetPropertyType.STRING), - @WidgetProperty(key = "metric1", type = WidgetPropertyType.METRIC, defaultValue = "ncloc", options = {WidgetConstants.FILTER_OUT_NEW_METRICS}), - @WidgetProperty(key = "metric2", type = WidgetPropertyType.METRIC, options = {WidgetConstants.FILTER_OUT_NEW_METRICS}), - @WidgetProperty(key = "metric3", type = WidgetPropertyType.METRIC, options = {WidgetConstants.FILTER_OUT_NEW_METRICS}), - @WidgetProperty(key = "hideEvents", type = WidgetPropertyType.BOOLEAN), - @WidgetProperty(key = "chartHeight", type = WidgetPropertyType.INTEGER, defaultValue = "180") -}) -public class TimelineWidget extends CoreWidget { - public TimelineWidget() { - super("timeline", "Timeline", "/org/sonar/plugins/core/widgets/timeline.html.erb"); - } -} diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/TreemapWidget.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/TreemapWidget.java deleted file mode 100644 index e0787c4c5a8..00000000000 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/TreemapWidget.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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 this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -package org.sonar.plugins.core.widgets; - -import org.sonar.api.measures.CoreMetrics; -import org.sonar.api.web.WidgetProperties; -import org.sonar.api.web.WidgetProperty; -import org.sonar.api.web.WidgetPropertyType; - -@WidgetProperties({ - @WidgetProperty(key = "chartTitle", type = WidgetPropertyType.STRING), - @WidgetProperty(key = "sizeMetric", type = WidgetPropertyType.METRIC, defaultValue = CoreMetrics.NCLOC_KEY, options = {WidgetConstants.FILTER_OUT_NEW_METRICS}), - @WidgetProperty(key = "colorMetric", type = WidgetPropertyType.METRIC, defaultValue = CoreMetrics.COVERAGE_KEY, - options = {WidgetConstants.FILTER_OUT_NEW_METRICS, "type:PERCENT,RATING,LEVEL"}), - @WidgetProperty(key = "heightInPercents", type = WidgetPropertyType.INTEGER, optional = true, defaultValue = "55"), - @WidgetProperty(key = "maxItems", type = WidgetPropertyType.INTEGER, defaultValue = "100") -}) -public class TreemapWidget extends CoreWidget { - public TreemapWidget() { - super("treemap-widget", "Treemap of Components", "/org/sonar/plugins/core/widgets/treemap.html.erb"); - } -} diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/WelcomeWidget.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/WelcomeWidget.java deleted file mode 100644 index 936e8cdcc07..00000000000 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/WelcomeWidget.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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 this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.plugins.core.widgets; - -import org.sonar.api.web.WidgetScope; - -import static org.sonar.api.web.WidgetScope.GLOBAL; - -@WidgetScope(GLOBAL) -public class WelcomeWidget extends CoreWidget { - - public static final String ID = "welcome"; - - public WelcomeWidget() { - super(ID, "Welcome", "/org/sonar/plugins/core/widgets/welcome.html.erb"); - } -} diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/WidgetConstants.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/WidgetConstants.java deleted file mode 100644 index 0a74fa3d754..00000000000 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/WidgetConstants.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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 this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.plugins.core.widgets; - -/** - * Constants shared accross multiple widgets - */ -public interface WidgetConstants { - - /** - * Widget property option used to filter out all the metrics which keys start with "new_". - * - * @see org.sonar.api.web.WidgetProperty#options() - */ - String FILTER_OUT_NEW_METRICS = "key:^(?!new_).*"; -} diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/issues/ActionPlansWidget.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/issues/ActionPlansWidget.java deleted file mode 100644 index e2bee019b6f..00000000000 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/issues/ActionPlansWidget.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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 this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.plugins.core.widgets.issues; - -import org.sonar.api.web.WidgetCategory; -import org.sonar.api.web.WidgetProperties; -import org.sonar.api.web.WidgetProperty; -import org.sonar.api.web.WidgetPropertyType; -import org.sonar.plugins.core.widgets.CoreWidget; - -@WidgetCategory({"Issues"}) -@WidgetProperties({ - @WidgetProperty(key = "showResolvedIssues", type = WidgetPropertyType.BOOLEAN, defaultValue = "true") -}) -public class ActionPlansWidget extends CoreWidget { - public ActionPlansWidget() { - super("action_plans", "Issues action plans", "/org/sonar/plugins/core/widgets/issues/action_plans.html.erb"); - } -} diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/issues/IssueFilterWidget.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/issues/IssueFilterWidget.java deleted file mode 100644 index f02fda9677d..00000000000 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/issues/IssueFilterWidget.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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 this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.plugins.core.widgets.issues; - -import org.sonar.api.web.*; -import org.sonar.plugins.core.widgets.CoreWidget; - -import static org.sonar.api.web.WidgetScope.GLOBAL; - -@WidgetCategory({"Filters", "Issues"}) -@WidgetScope(GLOBAL) -@WidgetProperties({ - @WidgetProperty(key = IssueFilterWidget.FILTER_PROPERTY, type = WidgetPropertyType.ISSUE_FILTER, optional = false), - @WidgetProperty(key = IssueFilterWidget.DISTRIBUTION_AXIS_PROPERTY, type = WidgetPropertyType.SINGLE_SELECT_LIST, defaultValue = "severities", - options = {"severities", "resolutions", "statuses", "rules", "tags", "projectUuids", "assignees", "reporters", - "authors", "languages", "actionPlans", "createdAt"}), - @WidgetProperty(key = IssueFilterWidget.DISPLAY_FILTER_DESCRIPTION, type = WidgetPropertyType.BOOLEAN, defaultValue = "false") -}) -public class IssueFilterWidget extends CoreWidget { - - public static final String FILTER_PROPERTY = "filter"; - public static final String DISTRIBUTION_AXIS_PROPERTY = "distributionAxis"; - public static final String DISPLAY_FILTER_DESCRIPTION = "displayFilterDescription"; - public static final String ID = "issue_filter"; - - public IssueFilterWidget() { - super(ID, "Issue Filter", "/org/sonar/plugins/core/widgets/issues/issue_filter.html.erb"); - } -} diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/issues/IssueTagCloudWidget.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/issues/IssueTagCloudWidget.java deleted file mode 100644 index cba0aa3f835..00000000000 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/issues/IssueTagCloudWidget.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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 this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.plugins.core.widgets.issues; - -import org.sonar.api.web.WidgetCategory; -import org.sonar.api.web.WidgetProperties; -import org.sonar.api.web.WidgetProperty; -import org.sonar.api.web.WidgetPropertyType; -import org.sonar.api.web.WidgetScope; -import org.sonar.plugins.core.widgets.CoreWidget; - -import static org.sonar.api.web.WidgetScope.PROJECT; - -@WidgetCategory({"Issues"}) -@WidgetScope(PROJECT) -@WidgetProperties({ - @WidgetProperty(key = "maxItems", type = WidgetPropertyType.INTEGER, defaultValue = "100") -}) -public class IssueTagCloudWidget extends CoreWidget { - - public IssueTagCloudWidget() { - super("issue_tag_cloud", "Issue Tag Cloud", "/org/sonar/plugins/core/widgets/issues/issue_tag_cloud.html.erb"); - } - -} diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/issues/IssuesWidget.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/issues/IssuesWidget.java deleted file mode 100644 index f92d9ab4e73..00000000000 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/issues/IssuesWidget.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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 this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.plugins.core.widgets.issues; - -import org.sonar.api.web.WidgetCategory; -import org.sonar.plugins.core.widgets.CoreWidget; - -@WidgetCategory({"Issues", "Technical Debt"}) -public class IssuesWidget extends CoreWidget { - - public IssuesWidget() { - super("rules", "Issues and Technical Debt", "/org/sonar/plugins/core/widgets/issues/issues.html.erb"); - } -} diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/issues/ProjectIssueFilterWidget.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/issues/ProjectIssueFilterWidget.java deleted file mode 100644 index 5e45af9272a..00000000000 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/issues/ProjectIssueFilterWidget.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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 this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.plugins.core.widgets.issues; - -import org.sonar.api.web.*; -import org.sonar.plugins.core.widgets.CoreWidget; - -import static org.sonar.api.web.WidgetScope.PROJECT; - -@WidgetCategory({"Filters", "Issues"}) -@WidgetScope(PROJECT) -@WidgetProperties({ - @WidgetProperty(key = ProjectIssueFilterWidget.FILTER_PROPERTY, type = WidgetPropertyType.ISSUE_FILTER, optional = false), - @WidgetProperty(key = ProjectIssueFilterWidget.DISTRIBUTION_AXIS_PROPERTY, type = WidgetPropertyType.SINGLE_SELECT_LIST, defaultValue = "severities", - options = {"severities", "resolutions", "statuses", "rules", "tags", "assignees", "reporters", "authors", - "languages", "actionPlans", "createdAt"}), - @WidgetProperty(key = ProjectIssueFilterWidget.DISPLAY_FILTER_DESCRIPTION, type = WidgetPropertyType.BOOLEAN, defaultValue = "false") -}) -public class ProjectIssueFilterWidget extends CoreWidget { - - public static final String FILTER_PROPERTY = "filter"; - public static final String DISTRIBUTION_AXIS_PROPERTY = "distributionAxis"; - public static final String DISPLAY_FILTER_DESCRIPTION = "displayFilterDescription"; - public static final String ID = "project_issue_filter"; - - public ProjectIssueFilterWidget() { - super(ID, "Project Issue Filter", "/org/sonar/plugins/core/widgets/issues/project_issue_filter.html.erb"); - } -} diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/issues/package-info.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/issues/package-info.java deleted file mode 100644 index 528f5fa3dae..00000000000 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/issues/package-info.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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 this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -@ParametersAreNonnullByDefault -package org.sonar.plugins.core.widgets.issues; - -import javax.annotation.ParametersAreNonnullByDefault; diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/measures/MeasureFilterAsBubbleChartWidget.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/measures/MeasureFilterAsBubbleChartWidget.java deleted file mode 100644 index bac50919643..00000000000 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/measures/MeasureFilterAsBubbleChartWidget.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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 this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.plugins.core.widgets.measures; - -import org.sonar.api.measures.CoreMetrics; -import org.sonar.api.web.*; -import org.sonar.plugins.core.widgets.CoreWidget; -import org.sonar.plugins.core.widgets.WidgetConstants; - -import static org.sonar.api.web.WidgetScope.GLOBAL; - -@WidgetCategory({"Filters"}) -@WidgetScope(GLOBAL) -@WidgetProperties({ - @WidgetProperty(key = "chartTitle", type = WidgetPropertyType.STRING), - @WidgetProperty(key = "chartHeight", type = WidgetPropertyType.INTEGER, defaultValue = "300"), - @WidgetProperty(key = "filter", type = WidgetPropertyType.FILTER, optional = false), - @WidgetProperty(key = "xMetric", type = WidgetPropertyType.METRIC, defaultValue = CoreMetrics.NCLOC_KEY, options = {WidgetConstants.FILTER_OUT_NEW_METRICS}), - @WidgetProperty(key = "yMetric", type = WidgetPropertyType.METRIC, defaultValue = CoreMetrics.VIOLATIONS_KEY, options = {WidgetConstants.FILTER_OUT_NEW_METRICS}), - @WidgetProperty(key = "sizeMetric", type = WidgetPropertyType.METRIC, defaultValue = CoreMetrics.TECHNICAL_DEBT_KEY, options = {WidgetConstants.FILTER_OUT_NEW_METRICS}), - @WidgetProperty(key = "xLogarithmic", type = WidgetPropertyType.BOOLEAN), - @WidgetProperty(key = "yLogarithmic", type = WidgetPropertyType.BOOLEAN), - @WidgetProperty(key = "maxItems", type = WidgetPropertyType.INTEGER) -}) -public class MeasureFilterAsBubbleChartWidget extends CoreWidget { - - public MeasureFilterAsBubbleChartWidget() { - super("measure_filter_bubble_chart", "Measure Filter as Bubble Chart", "/org/sonar/plugins/core/widgets/measures/measure_filter_bubble_chart.html.erb"); - } - -} diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/measures/MeasureFilterAsCloudWidget.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/measures/MeasureFilterAsCloudWidget.java deleted file mode 100644 index 9bb13aa4225..00000000000 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/measures/MeasureFilterAsCloudWidget.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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 this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.plugins.core.widgets.measures; - -import org.sonar.api.measures.CoreMetrics; -import org.sonar.api.web.*; -import org.sonar.plugins.core.widgets.CoreWidget; -import org.sonar.plugins.core.widgets.WidgetConstants; - -import static org.sonar.api.web.WidgetScope.GLOBAL; - -@WidgetCategory({"Filters"}) -@WidgetScope(GLOBAL) -@WidgetProperties({ - @WidgetProperty(key = "filter", type = WidgetPropertyType.FILTER, optional = false), - @WidgetProperty(key = "chartTitle", type = WidgetPropertyType.STRING), - @WidgetProperty(key = "sizeMetric", type = WidgetPropertyType.METRIC, defaultValue = CoreMetrics.COMPLEXITY_KEY, options = {WidgetConstants.FILTER_OUT_NEW_METRICS}), - @WidgetProperty(key = "colorMetric", type = WidgetPropertyType.METRIC, defaultValue = CoreMetrics.COVERAGE_KEY, - options = { WidgetConstants.FILTER_OUT_NEW_METRICS, "type:PERCENT" }), - @WidgetProperty(key = "maxItems", type = WidgetPropertyType.INTEGER, defaultValue = "100") -}) -public class MeasureFilterAsCloudWidget extends CoreWidget { - - public MeasureFilterAsCloudWidget() { - super("measure_filter_cloud", "Measure Filter as Cloud", "/org/sonar/plugins/core/widgets/measures/measure_filter_cloud.html.erb"); - } - -} diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/measures/MeasureFilterAsHistogramWidget.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/measures/MeasureFilterAsHistogramWidget.java deleted file mode 100644 index 8dafd420381..00000000000 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/measures/MeasureFilterAsHistogramWidget.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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 this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.plugins.core.widgets.measures; - -import org.sonar.api.measures.CoreMetrics; -import org.sonar.api.web.*; -import org.sonar.plugins.core.widgets.CoreWidget; -import org.sonar.plugins.core.widgets.WidgetConstants; - -import static org.sonar.api.web.WidgetScope.GLOBAL; - -@WidgetCategory({"Filters"}) -@WidgetScope(GLOBAL) -@WidgetProperties({ - @WidgetProperty(key = "chartTitle", type = WidgetPropertyType.STRING), - @WidgetProperty(key = "filter", type = WidgetPropertyType.FILTER, optional = false), - @WidgetProperty(key = "metric", type = WidgetPropertyType.METRIC, defaultValue = CoreMetrics.TECHNICAL_DEBT_KEY, options = {WidgetConstants.FILTER_OUT_NEW_METRICS}), - @WidgetProperty(key = "maxItems", type = WidgetPropertyType.INTEGER, defaultValue = "40"), - @WidgetProperty(key = "reverseOrder", type = WidgetPropertyType.BOOLEAN, defaultValue = "false"), - @WidgetProperty(key = "relativeScale", type = WidgetPropertyType.BOOLEAN, defaultValue = "false") -}) -public class MeasureFilterAsHistogramWidget extends CoreWidget { - - public MeasureFilterAsHistogramWidget() { - super("measure_filter_histogram", "Measure Filter as Histogram", "/org/sonar/plugins/core/widgets/measures/measure_filter_histogram.html.erb"); - } - -} diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/measures/MeasureFilterAsPieChartWidget.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/measures/MeasureFilterAsPieChartWidget.java deleted file mode 100644 index f3a057b4fe9..00000000000 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/measures/MeasureFilterAsPieChartWidget.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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 this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.plugins.core.widgets.measures; - -import org.sonar.api.measures.CoreMetrics; -import org.sonar.api.web.*; -import org.sonar.plugins.core.widgets.CoreWidget; -import org.sonar.plugins.core.widgets.WidgetConstants; - -import static org.sonar.api.web.WidgetScope.GLOBAL; - -@WidgetCategory({"Filters"}) -@WidgetScope(GLOBAL) -@WidgetProperties({ - @WidgetProperty(key = "chartTitle", type = WidgetPropertyType.STRING), - @WidgetProperty(key = "chartHeight", type = WidgetPropertyType.INTEGER, defaultValue = "300"), - @WidgetProperty(key = "filter", type = WidgetPropertyType.FILTER, optional = false), - @WidgetProperty(key = "mainMetric", type = WidgetPropertyType.METRIC, defaultValue = CoreMetrics.TECHNICAL_DEBT_KEY, options = {WidgetConstants.FILTER_OUT_NEW_METRICS}), - @WidgetProperty(key = "extraMetric1", type = WidgetPropertyType.METRIC, defaultValue = CoreMetrics.NCLOC_KEY, options = {WidgetConstants.FILTER_OUT_NEW_METRICS}), - @WidgetProperty(key = "extraMetric2", type = WidgetPropertyType.METRIC, options = {WidgetConstants.FILTER_OUT_NEW_METRICS}), - @WidgetProperty(key = "maxItems", type = WidgetPropertyType.INTEGER, defaultValue = "20") -}) -public class MeasureFilterAsPieChartWidget extends CoreWidget { - - public MeasureFilterAsPieChartWidget() { - super("measure_filter_pie_chart", "Measure Filter as Donut Chart", "/org/sonar/plugins/core/widgets/measures/measure_filter_pie_chart.html.erb"); - } - -} diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/measures/MeasureFilterAsTreemapWidget.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/measures/MeasureFilterAsTreemapWidget.java deleted file mode 100644 index ba0c06d891a..00000000000 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/measures/MeasureFilterAsTreemapWidget.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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 this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.plugins.core.widgets.measures; - -import org.sonar.api.measures.CoreMetrics; -import org.sonar.api.web.WidgetCategory; -import org.sonar.api.web.WidgetProperties; -import org.sonar.api.web.WidgetProperty; -import org.sonar.api.web.WidgetPropertyType; -import org.sonar.api.web.WidgetScope; -import org.sonar.plugins.core.widgets.CoreWidget; -import org.sonar.plugins.core.widgets.WidgetConstants; - -import static org.sonar.api.web.WidgetScope.GLOBAL; - -@WidgetCategory({"Filters"}) -@WidgetScope(GLOBAL) -@WidgetProperties({ - @WidgetProperty(key = MeasureFilterAsTreemapWidget.FILTER_PROPERTY, type = WidgetPropertyType.FILTER, - optional = false), - @WidgetProperty(key = MeasureFilterAsTreemapWidget.CHART_TITLE_PROPERTY, type = WidgetPropertyType.STRING), - @WidgetProperty(key = MeasureFilterAsTreemapWidget.SIZE_METRIC_PROPERTY, type = WidgetPropertyType.METRIC, - defaultValue = CoreMetrics.NCLOC_KEY, options = {WidgetConstants.FILTER_OUT_NEW_METRICS}), - @WidgetProperty(key = MeasureFilterAsTreemapWidget.COLOR_METRIC_PROPERTY, type = WidgetPropertyType.METRIC, - defaultValue = CoreMetrics.COVERAGE_KEY, - options = {WidgetConstants.FILTER_OUT_NEW_METRICS, "type:PERCENT,RATING,LEVEL"}), - @WidgetProperty(key = MeasureFilterAsTreemapWidget.HEIGHT_PERCENTS_PROPERTY, type = WidgetPropertyType.INTEGER, - optional = true, defaultValue = "55", description = "Height in percents of width"), - @WidgetProperty(key = MeasureFilterAsTreemapWidget.MAX_ITEMS_PROPERTY, type = WidgetPropertyType.INTEGER, - defaultValue = "30") -}) -public class MeasureFilterAsTreemapWidget extends CoreWidget { - public static final String FILTER_PROPERTY = "filter"; - public static final String SIZE_METRIC_PROPERTY = "sizeMetric"; - public static final String COLOR_METRIC_PROPERTY = "colorMetric"; - public static final String HEIGHT_PERCENTS_PROPERTY = "heightInPercents"; - public static final String CHART_TITLE_PROPERTY = "chartTitle"; - public static final String MAX_ITEMS_PROPERTY = "maxItems"; - public static final String ID = "measure_filter_treemap"; - - public MeasureFilterAsTreemapWidget() { - super(ID, "Measure Filter as Treemap", "/org/sonar/plugins/core/widgets/measures/measure_filter_treemap.html.erb"); - } -} diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/measures/MeasureFilterListWidget.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/measures/MeasureFilterListWidget.java deleted file mode 100644 index e8b3eaf583a..00000000000 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/measures/MeasureFilterListWidget.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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 this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.plugins.core.widgets.measures; - -import org.sonar.api.web.*; -import org.sonar.plugins.core.widgets.CoreWidget; - -import static org.sonar.api.web.WidgetScope.GLOBAL; - -@WidgetCategory({"Filters"}) -@WidgetScope(GLOBAL) -@WidgetProperties({ - @WidgetProperty(key = MeasureFilterListWidget.FILTER_PROPERTY, type = WidgetPropertyType.FILTER, optional = false), - @WidgetProperty(key = MeasureFilterListWidget.PAGE_SIZE_PROPERTY, type = WidgetPropertyType.INTEGER, defaultValue = "30"), - @WidgetProperty(key = MeasureFilterListWidget.DISPLAY_FILTER_DESCRIPTION, type = WidgetPropertyType.BOOLEAN, defaultValue = "false") -}) -public class MeasureFilterListWidget extends CoreWidget { - public static final String FILTER_PROPERTY = "filter"; - public static final String PAGE_SIZE_PROPERTY = "pageSize"; - public static final String DISPLAY_FILTER_DESCRIPTION = "displayFilterDescription"; - public static final String ID = "measure_filter_list"; - - public MeasureFilterListWidget() { - super(ID, "Measure Filter as List", "/org/sonar/plugins/core/widgets/measure_filter_list.html.erb"); - } -} diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/measures/package-info.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/measures/package-info.java deleted file mode 100644 index d781bea9c69..00000000000 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/measures/package-info.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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 this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -@ParametersAreNonnullByDefault -package org.sonar.plugins.core.widgets.measures; - -import javax.annotation.ParametersAreNonnullByDefault; diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/package-info.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/package-info.java deleted file mode 100644 index dc52f477867..00000000000 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/package-info.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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 this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -@ParametersAreNonnullByDefault -package org.sonar.plugins.core.widgets; - -import javax.annotation.ParametersAreNonnullByDefault; diff --git a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/_complexity_chart.html.erb b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/_complexity_chart.html.erb deleted file mode 100644 index b75db5d24fd..00000000000 --- a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/_complexity_chart.html.erb +++ /dev/null @@ -1,18 +0,0 @@ -<% dist_measure = measure(metric) - if dist_measure && !dist_measure.data.blank? -%> -
"> -<% - query="ck=distbar&c=777777&v=" + u(dist_measure.data) - small_size_query=query + '&w=220&h=100&fs=8&bgc=ffffff' - big_size_query=query + '&w=300&h=150&fs=12&bgc=CAE3F2' -%><%= chart(small_size_query, :id => 'chart_img_' + metric, :alt => title) -%> - - -
-<% end %> \ No newline at end of file diff --git a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/alerts.html.erb b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/alerts.html.erb deleted file mode 100644 index d50c712836a..00000000000 --- a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/alerts.html.erb +++ /dev/null @@ -1,95 +0,0 @@ -<% m=measure(Metric::QUALITY_GATE_DETAILS) - if m && !m.data.blank? - details = JSON.parse m.data - m.alert_status = details['level'] - raw_conditions = details['conditions'] - conditions = [] - missing_metric = false - raw_conditions.each do |condition| - if metric(condition['metric']).nil? - missing_metric = true - else - conditions << condition - end - end - alert_metric = metric(Metric::ALERT_STATUS) - - warn_message = message('measure_filter.criteria.alert.warn') - error_message = message('measure_filter.criteria.alert.error') - - css_class = "color_#{m.alert_status}" - if m.alert_status==Metric::TYPE_LEVEL_OK - label = "#{message('widget.alerts.no_alert')}." - elsif m.alert_status==Metric::TYPE_LEVEL_WARN - label = "#{message('widget.alerts.warnings')}" - else - label = "#{message('widget.alerts.errors')}" - end --%>
-
<%= format_measure(measure(Metric::ALERT_STATUS)) -%> <%= label -%>
- <% if conditions.any? {|condition| condition['level'] != 'OK'} || widget_properties['show_ok'] && !conditions.empty? -%> - <% conditions.sort_by {|condition| [ -condition['level'].length, metric(condition['metric']).short_name] }.each do |condition| - - level = condition['level'] - condition_metric = metric(condition['metric']) - operator = message("quality_gates.operator.#{condition['op']}.short") - period = condition['period'] - warning_value = condition['warning'] - error_value = condition['error'] - actual_value = condition['actual'] - - detail_measure = ProjectMeasure.new :metric => alert_metric, :alert_status => level - - drilldown_url = period.blank? ? url_for_drilldown(condition_metric) : url_for_drilldown(condition_metric, :period => period) - - actual_measure = ProjectMeasure.new :metric => condition_metric, :value => actual_value, :alert_status => level - warning_measure = ProjectMeasure.new :metric => condition_metric, :value => warning_value - error_measure = ProjectMeasure.new :metric => condition_metric, :value => error_value - - is_difference_measure = condition_metric.name.start_with?('new_') - is_issue_measure = get_issue_metrics.include? condition_metric.name - is_not_difference_measure_with_period = !is_difference_measure && !period.blank? && !is_issue_measure - - tooltip = message('widget.as_calculated_on_x', :params => l(@snapshot.created_at)) - - - unless level == 'OK' && !widget_properties['show_ok'] - -%> -
-

<%= condition_metric.short_name -%>

- <% if is_not_difference_measure_with_period %> - <%= format_measure(actual_measure) -%> - <% else %> - <%= format_measure(actual_measure, :url => drilldown_url) -%> - <% end %> - <% if level == 'WARN' -%><%= operator -%> <%= format_measure(warning_measure) -%><% end -%> - <% if level == 'ERROR' -%><%= operator -%> <%= format_measure(error_measure) -%><% end -%> - <% if level == 'OK' -%> - <% unless warning_value.blank? -%><%= warn_message -%> <%= operator -%> <%= format_measure(warning_measure) -%> <%= '|' unless error_value.blank? -%><% end -%> - <% unless error_value.blank? -%><%= error_message -%> <%= operator -%> <%= format_measure(error_measure) -%><% end -%> - <% end -%> -

<%= period_label(@snapshot, period) unless period.blank? -%>

-
- <% end - end - end - if missing_metric -%> -
<%= message('widget.alerts.missing_metric') -%>
- <% end -%> -
-<% else -%> -<% m=measure(Metric::ALERT_STATUS) - if m && !m.alert_status.blank? - css_class = "widget color_#{m.alert_status}" - if m.alert_status==Metric::TYPE_LEVEL_OK - label = "#{message('widget.alerts.no_alert')}." - elsif m.alert_status==Metric::TYPE_LEVEL_WARN - label = "#{message('widget.alerts.warnings')}#{h(m.alert_text)}." - else - label = "#{message('widget.alerts.errors')}#{h(m.alert_text)}." - end --%>
-
<%= format_measure(m) -%> <%= label -%>
-
-<% end -end -%> diff --git a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/bubbleChart.html.erb b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/bubbleChart.html.erb deleted file mode 100644 index e0188194dd2..00000000000 --- a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/bubbleChart.html.erb +++ /dev/null @@ -1,88 +0,0 @@ -<% - containerId = 'bubble-chart-widget' + widget.id.to_s - xMetric = widget_properties["xMetric"] - yMetric = widget_properties["yMetric"] - sizeMetric = widget_properties["sizeMetric"] - xLog = !!widget_properties["xLogarithmic"] - yLog = !!widget_properties["yLogarithmic"] - chartHeight = widget_properties["chartHeight"] - chartTitle = widget_properties["chartTitle"] -%> - -
- - - - <% if chartTitle %> -

<%= h(chartTitle) -%>

- <% end %> - -
- - - - diff --git a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/complexity.html.erb b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/complexity.html.erb deleted file mode 100644 index 62832d2335a..00000000000 --- a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/complexity.html.erb +++ /dev/null @@ -1,115 +0,0 @@ -<% - file_complexity=measure('file_complexity') - function_complexity=measure('function_complexity') - class_complexity=measure('class_complexity') - - if file_complexity || function_complexity || class_complexity - complexity=measure('complexity') -%> - -
-
-
- <% if complexity %> -

- <%= message('metric.complexity.name') %> - - <%= format_measure(complexity, :url => url_for_drilldown(complexity)) %> - <%= format_variation(complexity) if dashboard_configuration.selected_period? -%> - -

- <% end %> - <% if function_complexity %> -

- <%= message('widget.complexity.per_method.suffix') %> - - <%= format_measure(function_complexity, :url => url_for_drilldown(function_complexity)) %> - <%= format_variation(function_complexity) if dashboard_configuration.selected_period? -%> - -

- <% end %> - <% if class_complexity %> -

- <%= message('widget.complexity.per_class.suffix') %> - - <%= format_measure(class_complexity, :url => url_for_drilldown(class_complexity)) %> - <%= format_variation(class_complexity) if dashboard_configuration.selected_period? -%> - -

- <% end %> - <% if file_complexity %> -

- <%= message('widget.complexity.per_file.suffix') %> - - <%= format_measure(file_complexity, :url => url_for_drilldown(file_complexity)) %> - <%= format_variation(file_complexity) if dashboard_configuration.selected_period? -%> - -

- <% end %> -
-
- -
- <% - function_distribution=measure('function_complexity_distribution') - class_distribution=measure('class_complexity_distribution') - file_distribution=measure('file_complexity_distribution') - distributions=[function_distribution, class_distribution, file_distribution].compact - selected_distribution=nil - if distributions.size>0 - selected_distribution=distributions.first - end - if selected_distribution - %> -
- - - <% distributions.each do |distribution_measure| %> - <%= render :partial => 'project/widgets/complexity_chart', :locals => {:metric => distribution_measure.metric.key, :title => distribution_measure.metric.description, :visible => (selected_distribution==distribution_measure)} %> - <% end %> - -
- <% - count_dist=0 - if function_distribution - count_dist+=1 - %> - /> - - <% - end - if class_distribution - count_dist+=1 - %> - /> - <%= '
' if count_dist==2 %> - <% - end - if file_distribution - count_dist+=1 - %> - /> - - <% end %> - -
- -
- <% end %> -
-
-<% end %> diff --git a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/coverage.html.erb b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/coverage.html.erb deleted file mode 100644 index e293cfa0d56..00000000000 --- a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/coverage.html.erb +++ /dev/null @@ -1,156 +0,0 @@ -<% - code_coverage_measure=measure('coverage') - tests_measure=measure('tests') - execution_time=measure('test_execution_time') - success_percentage=measure('test_success_density') - - if code_coverage_measure || tests_measure -%> -
-
-
-
- <%= message('widget.code_coverage.name') -%> - - <%= format_measure(code_coverage_measure, :suffix => '', :url => url_for_drilldown('coverage'), :default => '-') %> - <%= format_variation(code_coverage_measure) if dashboard_configuration.selected_period? -%> - -
- <% - line_coverage=measure('line_coverage') - if line_coverage - %> -
- <%= message('widget.code_coverage.line_coverage.suffix') -%> - - <%= format_measure(line_coverage, :url => url_for_drilldown('uncovered_lines', :highlight => 'line_coverage')) %> - <%= format_variation(line_coverage) if dashboard_configuration.selected_period? -%> - -
- <% end %> - <% - branch_coverage=measure('branch_coverage') - if branch_coverage - %> -
- <%= message('widget.code_coverage.condition_coverage.suffix') -%> - - <%= format_measure(branch_coverage, :url => url_for_drilldown('uncovered_conditions', :highlight => 'branch_coverage')) %> - <%= format_variation(branch_coverage) if dashboard_configuration.selected_period? -%> - -
- <% end %> - - <% - if dashboard_configuration.selected_period? - new_lines_to_cover_measure=measure('new_lines_to_cover') - if new_lines_to_cover_measure - new_lines=new_lines_to_cover_measure.variation(dashboard_configuration.period_index) - if new_lines - new_coverage=measure('new_coverage') if variation_value('new_coverage') - new_line_coverage=measure('new_line_coverage') if variation_value('new_line_coverage') - new_branch_coverage=measure('new_branch_coverage') if variation_value('new_branch_coverage') - %> - <% if new_lines.to_i==0 %> -
- <%= message('widget.code_coverage.on_new_code') -%> -

<%= message('widget.code_coverage.no_new_lines_to_cover') -%>

-
- <% else %> - <% if new_coverage %> -
- <%= message('widget.code_coverage.on_new_code') -%> - <%= format_measure(new_coverage, - :period => dashboard_configuration.period_index, - :url => url_for_drilldown('new_coverage', :period => dashboard_configuration.period_index)) %> -
- <% end %> - <% if new_line_coverage %> -
- <%= message('widget.code_coverage.line_coverage.suffix') -%> - <%= format_measure(new_line_coverage, - :period => dashboard_configuration.period_index, - :url => url_for_drilldown('new_uncovered_lines', :highlight => 'new_line_coverage', :period => dashboard_configuration.period_index), - :default => '-') %> -
- <% end %> - <% if new_branch_coverage %> -
- <%= message('widget.code_coverage.condition_coverage.suffix') -%> - <%= format_measure(new_branch_coverage, - :period => dashboard_configuration.period_index, - :url => url_for_drilldown('new_uncovered_conditions', :highlight => 'new_branch_coverage', :period => dashboard_configuration.period_index), - :default => '-') %> -
- <% end %> - <% end %> - <% - end - end - end - %> -
-
-
- <% - if tests_measure - %> -
-
- <%= message('widget.code_coverage.test_success') -%> - - <%= format_measure(success_percentage, :url => url_for_drilldown(success_percentage)) %> - <%= format_variation(success_percentage) if dashboard_configuration.selected_period? -%> - -
- -
- <%= message('widget.code_coverage.failures.suffix') -%> - - <%= format_measure(Metric::TEST_FAILURES, :url => url_for_drilldown(Metric::TEST_FAILURES)) %> - <%= format_variation(Metric::TEST_FAILURES) if dashboard_configuration.selected_period? -%> - -
- -
- <%= message('widget.code_coverage.errors.suffix') -%> - - <%= format_measure(Metric::TEST_ERRORS, :url => url_for_drilldown(Metric::TEST_ERRORS)) %> - <%= format_variation(Metric::TEST_ERRORS) if dashboard_configuration.selected_period? -%> - -
- -
- <%= message('widget.code_coverage.tests.suffix') -%> - - <%= format_measure(tests_measure, :url => url_for_drilldown('tests')) %> - <%= format_variation(tests_measure) if dashboard_configuration.selected_period? -%> - -
- - <% skipped_measure=measure(Metric::SKIPPED_TESTS) - if dashboard_configuration.selected_period? || (skipped_measure && skipped_measure.value && skipped_measure.value>0) - %> -
- <%= message('widget.code_coverage.skipped.suffix') -%> - - <%= format_measure(skipped_measure, :url => url_for_drilldown(Metric::SKIPPED_TESTS)) %> - <%= format_variation(skipped_measure) if dashboard_configuration.selected_period? -%> - -
- <% end %> - -
- <%= message('widget.code_coverage.execution_time') -%> - - <%= format_measure(execution_time, :url => url_for_drilldown('test_execution_time')) %> - <%= format_variation(execution_time) if dashboard_configuration.selected_period? -%> - -
-
- <% end %> -
-
-<% end %> - - diff --git a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/custom_measures.html.erb b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/custom_measures.html.erb deleted file mode 100644 index c817403bc8c..00000000000 --- a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/custom_measures.html.erb +++ /dev/null @@ -1,36 +0,0 @@ -<% - measures=[] - (1..10).each do |index| - metric=widget_properties["metric#{index}"] - m=(metric ? measure(metric) : nil) - measures << m if m - end - period = params[:period] - unless measures.empty? || measures.none? { |measure| measure.visible?(period.to_i) } -%> -
- <% - measures.each do |measure| - if measure.visible?(period.to_i) - -%> -
-
-

- <%= measure.metric.short_name -%> - - <% if measure.value.nil? && measure.text_value.nil? -%> - <%= format_measure(measure, :url => url_for_drilldown(measure, :period => period), :period => period) -%> - <% else %> - <%= format_measure(measure, :url => url_for_drilldown(measure)) -%> - <%= format_variation(measure) if dashboard_configuration.selected_period? -%> - <% end -%> - -

-
-
- <% - end - end - -%> -
-<% end %> diff --git a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/debt_overview.erb b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/debt_overview.erb deleted file mode 100644 index 87cceb5ff3b..00000000000 --- a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/debt_overview.erb +++ /dev/null @@ -1,33 +0,0 @@ -<% - sqale_rating = @snapshot.measure('sqale_rating') - sqale_debt_ratio = @snapshot.measure('sqale_debt_ratio') - if sqale_rating && sqale_rating.text_value && sqale_debt_ratio -%> - <% if sqale_rating && sqale_rating.text_value %> -
-
-
-
- <%= message('metric.sqale_rating.name') -%> - - <%= format_measure(sqale_rating, :url => url_for_drilldown(sqale_rating)) %> - -
-
-
- <% end %> - <% if sqale_debt_ratio %> -
-
-
- <%= message('metric.sqale_debt_ratio.name') -%> - - <%= format_measure(sqale_debt_ratio, :url => url_for_drilldown(sqale_debt_ratio)) %> - <%= format_variation(sqale_debt_ratio) if dashboard_configuration.selected_period? -%> - -
-
-
-
- <% end %> -<% end %> diff --git a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/description.html.erb b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/description.html.erb deleted file mode 100644 index 6d587793407..00000000000 --- a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/description.html.erb +++ /dev/null @@ -1,90 +0,0 @@ -
-

- - <%= @project.name -%> -

- <%= h @project.key -%> - - <% if @project.description.present? %> -

<%= h @project.description -%>

- <% end %> - - <% - qprofiles_measure = measure(Metric::QUALITY_PROFILES) - if qprofiles_measure && !qprofiles_measure.data.blank? - qprofiles = JSON.parse qprofiles_measure.data - if qprofiles.size>0 - %> -

- <%= message('widget.description.profiles') -%>: - <% qprofiles.each_with_index do |profile, i| %> - - - <%= link_to profile['name'], {:controller => 'profiles', :action => 'show', :key => profile['key']}, :class => 'widget-link', :id => profile['language'] + '_profile_link' -%> - - - (<%= Api::Utils.language_name(profile['language']) -%>) - - <% if i < (qprofiles.size - 1) %>,<% end %> - - <% end - end %> -

- <% - else - profile_measure=@snapshot.measure('profile') - if profile_measure - %> -

- <%= message('widget.description.profile') -%>: - - <%= link_to profile_measure.data, {:controller => 'profiles', :action => 'show', :id => profile_measure.value.to_i}, :class => 'widget-link', :id => 'profile_link' -%> - -

- <% end - end %> - - <% - unless @resource.qualifier == 'DEV' or @resource.qualifier == 'VW' or @resource.qualifier == 'SVW' - using_default=false - quality_gate=Property.value('sonar.qualitygate', @resource && @resource.id, nil) - unless quality_gate - quality_gate=Property.value('sonar.qualitygate', nil, nil) - using_default=false || quality_gate - end - if quality_gate - qgate = Internal.quality_gates.get(quality_gate.to_i) - %> -

- - <%= message('widget.description.qualitygate') -%>: - <%= link_to qgate.getName(), (url_for :controller => '/quality_gates') + '#show/' + quality_gate, :class => 'widget-link', :id => 'qgate_link' -%> - <% if using_default %> - (<%= message('default') -%>) - <% end %> - -

- <% end end %> - - <% unless @project.project_links.empty? %> - - <% end %> -
diff --git a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/documentation_comments_widget.html.erb b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/documentation_comments_widget.html.erb deleted file mode 100644 index 06423d5c029..00000000000 --- a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/documentation_comments_widget.html.erb +++ /dev/null @@ -1,63 +0,0 @@ -<% - if measure(Metric::LINES) || measure(Metric::NCLOC) - public_api=measure('public_api') - public_documented_api_density=measure('public_documented_api_density') - public_undocumented_api=measure('public_undocumented_api') - comment_lines=measure('comment_lines') - comment_lines_density=measure('comment_lines_density') -%> -
-
- <% if public_documented_api_density || public_api || public_undocumented_api %> -
- <% - if public_documented_api_density - %> -
- <%= message('widget.documentation_comments.documentation') -%> - - <%= format_measure(public_documented_api_density, :url => url_for_drilldown(Metric::PUBLIC_UNDOCUMENTED_API, :highlight => Metric::PUBLIC_DOCUMENTED_API_DENSITY)) %> - <%= format_variation('public_documented_api_density') if dashboard_configuration.selected_period? -%> - -
- <% end %> -
- <%= message('metric.public_api.name') -%> - - <%= format_measure(public_api,:url => url_for_drilldown(public_api)) %> - <%= format_variation(public_api) if dashboard_configuration.selected_period? -%> - -
-
- <%= message('metric.public_undocumented_api.abbreviation') -%> - - <%= format_measure(public_undocumented_api,:url => url_for_drilldown(public_undocumented_api)) %> - <%= format_variation(public_undocumented_api) if dashboard_configuration.selected_period? -%> - -
-
- <% end %> -
- -
-
-
- <%= message('widget.documentation_comments.comments') -%> - - <%= format_measure(comment_lines_density,:url => url_for_drilldown(comment_lines_density))%> - <%= format_variation(comment_lines_density) if dashboard_configuration.selected_period? -%> - -
-
- <%= message('metric.comment_lines.name') -%> - - <%= format_measure(comment_lines,:url => url_for_drilldown(comment_lines)) %> - <%= format_variation(comment_lines) if dashboard_configuration.selected_period? -%> - -
-
-
-
-<% - end -%> diff --git a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/duplications_widget.html.erb b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/duplications_widget.html.erb deleted file mode 100644 index 99b487a57a7..00000000000 --- a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/duplications_widget.html.erb +++ /dev/null @@ -1,41 +0,0 @@ -<% - duplicated_lines_density=measure('duplicated_lines_density') - if duplicated_lines_density -%> -
-
-
- <%= message('widget.duplications.duplications') -%> - - <%= format_measure(duplicated_lines_density, :url => url_for_drilldown('duplicated_lines', :highlight => 'duplicated_lines_density')) %> - <%= format_variation('duplicated_lines_density') if dashboard_configuration.selected_period? -%> - -
- -
- <%= message('widget.duplications.lines.suffix') -%> - - <%= format_measure(measure('duplicated_lines'), :url => url_for_drilldown('duplicated_lines'))%> - <%= format_variation('duplicated_lines') if dashboard_configuration.selected_period? -%> - -
- -
- <%= message('widget.duplications.blocks.suffix') -%> - - <%= format_measure(measure('duplicated_blocks'), :url => url_for_drilldown('duplicated_blocks'))%> - <%= format_variation('duplicated_blocks') if dashboard_configuration.selected_period? -%> - -
- -
- <%= message('widget.duplications.files.suffix') -%> - - <%= format_measure(measure('duplicated_files'), :url => url_for_drilldown('duplicated_files'))%> - <%= format_variation('duplicated_files') if dashboard_configuration.selected_period? -%> - -
- -
-
-<% end %> diff --git a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/events.html.erb b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/events.html.erb deleted file mode 100644 index d6be1d2e667..00000000000 --- a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/events.html.erb +++ /dev/null @@ -1,120 +0,0 @@ -<% - if @resource.scope=='PRJ' - - conditions = "component_uuid=:component_uuid" - values = {:component_uuid => @resource.uuid} - # in order to not display events linked to deleted snapshot, we build the SQL request with 'NOT IN' as most of the time, there won't be unprocessed snapshots - snapshots_to_be_deleted = Snapshot.find(:all, :conditions => ["status='U' AND project_id=?", @resource.id]) - unless snapshots_to_be_deleted.empty? - conditions << " AND snapshot_id NOT IN (:sids)" - values[:sids] = snapshots_to_be_deleted.map { |s| s.id } - end - - events=Event.find(:all, :conditions => [conditions, values], :order => 'event_date desc') - - categories = EventCategory.categories(true) -%> - - - - -

<%= message('widget.events.title') -%>    - - - - - -

- - - - - - - - - -<% - events.each do |event| - categ = event.category - profile_data={} - if categ=='Profile' && event.event_data - profile_data=Hash[*(event.event_data.split(';').map { |elt| elt.split('=') }.flatten)] - end -%> - - - - - - -<% - end -%> - -
<%= l(event.event_date.to_date) %><%= h message('event.category.' + categ, :default => categ) %> - <%= link_to_if profile_data['key'] && profile_data['from'] && profile_data['to'], event.name, - :controller => 'profiles', :action => 'changelog', :key => profile_data['key'], - :since => profile_data['from'], :to => profile_data['to'] -%> - - <% unless event.description.blank? %> - - <% end %> -
- -
- <%= message('widget.events.no_event') -%> -
- -<%= message('widget.events.show_all') -%> - - - -<% end %> diff --git a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/hotspots/hotspot_metric.html.erb b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/hotspots/hotspot_metric.html.erb deleted file mode 100644 index bf2872762d8..00000000000 --- a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/hotspots/hotspot_metric.html.erb +++ /dev/null @@ -1,85 +0,0 @@ -<% - metric = widget_properties["metric"] || Metric.by_key('ncloc') - - if measure(metric) - - limit = widget_properties["numberOfLines"] - title = widget_properties["title"] - title = message('widget.hotspot_metric.hotspots_by_x', :params => metric.short_name) if title.blank? - - snapshots = nil - if metric.numeric? && !@snapshot.leaves_qualifiers.empty? - snapshots_conditions=["snapshots.qualifier in (:qualifiers)", "snapshots.islast=:islast", "snapshots.status = 'P'"] - snapshots_values={:qualifiers => @snapshot.leaves_qualifiers, :islast => true} - snapshots_conditions << '(snapshots.root_snapshot_id=:root_sid AND snapshots.path LIKE :path)' - snapshots_values[:root_sid] = (@snapshot.root_snapshot_id || @snapshot.id) - snapshots_values[:path]="#{@snapshot.path}#{@snapshot.id}.%" - - measures_conditions = ["project_measures.rule_id IS NULL", "project_measures.characteristic_id IS NULL", "project_measures.person_id IS NULL"] - measures_values = {} - measures_conditions << "project_measures.metric_id = :m_id" - measures_values[:m_id] = metric.id - - measures=ProjectMeasure.find(:all, - :joins => :snapshot, - :conditions => [(snapshots_conditions + measures_conditions).join(' AND '), snapshots_values.merge(measures_values)], - :order => "project_measures.value #{'DESC' if metric.direction<0}", - :limit => limit) - - snapshots=Snapshot.find(measures.map { |m| m.snapshot_id }, :include => 'project') - snapshots_by_id = {} - snapshots.each do |s| - snapshots_by_id[s.id]=s - end - end - - unless snapshots && !snapshots.empty? %> -

<%= title -%>

- <%= message('no_results') -%> - <% else %> - - - - - - - - - - <% - if metric.direction > 0 - metric_max_value = measures.last.value - else - metric_max_value = measures.first.value - end - measures.each do |measure| - resource = snapshots_by_id[measure.snapshot_id].resource - %> - - - - - - <% - end - %> - -
-
- <%= link_to_resource(resource, h(resource.name), {:metric => metric.name, :class => 'underlined-link'}) -%> - - <%= format_measure(measure) -%> - -
-
-
-
- - <% end %> - -<% end %> \ No newline at end of file diff --git a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/issues/action_plans.html.erb b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/issues/action_plans.html.erb deleted file mode 100644 index 75553d3de15..00000000000 --- a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/issues/action_plans.html.erb +++ /dev/null @@ -1,97 +0,0 @@ -<% - # This widget should only be display on root projects - if @project.qualifier == 'TRK' && has_role?(:user, @project) - action_plans = Internal.issues.findActionPlanStats(@resource.key) - open_action_plans = action_plans.select {|plan| plan.isOpen()} - - div_id = "issues-action-plan-widget-#{widget.id.to_s}" -%> - -
- <% if has_role?(:admin, @project) %> - - <% end %> - -

<%= message('widget.action_plans.title') -%>

-
- - -
- -<% if open_action_plans.size ==0 %> - - <%= message('widget.action_plans.no_action_plan') -%> - -<% - else - show_resolved_issues = widget_properties["showResolvedIssues"] - if show_resolved_issues - line_class = "top" - else - line_class = "middle" - max_unresolved_issues = open_action_plans.map {|plan| plan.unresolvedIssues()}.max - end -%> - - - - - - - - - <% - open_action_plans.each do |plan| - %> - "action_plan_" + widget.id.to_s) -%>"> - - - - <% if show_resolved_issues %> - <% if plan.totalIssues()==0 %> - - <% else %> - - <% end %> - <% - else - unresolved_issues_size = plan.unresolvedIssues() - %> - - - <% end %> - - - <% - end - %> - -
<%= h(plan.name) -%><%= format_date(plan.deadLine()) -%><%= message('action_plans.no_issues_linked_to_action_plan') -%> - <%= render :partial => 'action_plans/progress', :locals => {:action_plan => plan} -%> - - <% if unresolved_issues_size == 0 %> - <%= unresolved_issues_size -%> - <% else %> - <% - search_options = {} - search_options['actionPlans'] = plan.key - search_options['resolved'] = false - %> - <%= unresolved_issues_size -%> - <% end %> - -
-
-
-
- -<% end %> - -
- -<% end %> diff --git a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/issues/issue_filter.html.erb b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/issues/issue_filter.html.erb deleted file mode 100644 index f70e79ec85b..00000000000 --- a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/issues/issue_filter.html.erb +++ /dev/null @@ -1,52 +0,0 @@ -<% - container_id = 'widget-issue-filter-' + widget.id.to_s - filter_id = widget_properties['filter'] - filter = Internal.issues.findIssueFilterById(filter_id.to_i) - distribution_axis = widget_properties['distributionAxis'] - is_enough_permissions = filter.shared || (current_user && filter.userLogin == current_user.login) -%> - -<% if filter %> - - <% if is_enough_permissions %> - - <% @widget_title = " 'issues', :action => 'index'})}#id=#{filter.id}\">#{h(filter.name)}" %> - <% if widget_properties['displayFilterDescription'] && !filter.description.blank? %> -

<%= h filter.description -%>

- <% end %> - -
- - - <% else %> - -

<%= message 'widget.issue_filter.insufficient_privileges_warning' -%>

- - <% end %> - -<% else %> - -

<%= message 'widget.issue_filter.unknown_filter_warning' -%>

- -<% end %> diff --git a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/issues/issue_tag_cloud.html.erb b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/issues/issue_tag_cloud.html.erb deleted file mode 100644 index 99012a289e5..00000000000 --- a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/issues/issue_tag_cloud.html.erb +++ /dev/null @@ -1,61 +0,0 @@ -<% - containerId = 'issue-tag-cloud' + widget.id.to_s - maxItems = widget_properties['maxItems'].to_i - - if has_role?(:user, @project) && !Internal.issues.listTagsForComponent(@project.uuid, maxItems).isEmpty() - search_options = { - 'resolved' => 'false' - } - if @project - search_options['componentUuids'] = @project.uuid - end - if @dashboard_configuration.selected_period? - search_options['createdAfter'] = @snapshot.period_datetime(@dashboard_configuration.period_index).strftime('%FT%T%z') - end - - title = message('widget.issue_tag_cloud.title') -%> - -
- - - -

<%= title -%>

- - -
- - - - -<% end %> diff --git a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/issues/issues.html.erb b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/issues/issues.html.erb deleted file mode 100644 index 0b2fe0c63f8..00000000000 --- a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/issues/issues.html.erb +++ /dev/null @@ -1,205 +0,0 @@ -<% - issues = @snapshot.measure('violations') - blocker_issues = @snapshot.measure('blocker_violations') - critical_issues = @snapshot.measure('critical_violations') - major_issues = @snapshot.measure('major_violations') - minor_issues = @snapshot.measure('minor_violations') - info_issues = @snapshot.measure('info_violations') - - new_issues = @snapshot.measure('new_violations') - new_blocker_issues = @snapshot.measure('new_blocker_violations') - new_critical_issues = @snapshot.measure('new_critical_violations') - new_major_issues = @snapshot.measure('new_major_violations') - new_minor_issues = @snapshot.measure('new_minor_violations') - new_info_issues = @snapshot.measure('new_info_violations') - - technical_debt = @snapshot.measure('sqale_index') - new_technical_debt = @snapshot.measure('new_technical_debt') - - if @dashboard_configuration.selected_period? - period_date = @snapshot.period_datetime(@dashboard_configuration.period_index).strftime('%FT%T%z') - end - - tooltip = message('widget.as_calculated_on_x', :params => l(@snapshot.created_at)) -%> - -
- - <% if technical_debt %> -
-
-
- <%= message('metric.sqale_index.short_name') -%> - - <%= format_measure(technical_debt) -%> - - <%= format_variation(technical_debt) if dashboard_configuration.selected_period? -%> -
-
- <% - if @dashboard_configuration.selected_period? - technical_debt_variation = variation_value(technical_debt) - new_technical_debt_variation = variation_value(new_technical_debt) - estimated_cleared_technical_debt = (new_technical_debt_variation - technical_debt_variation).to_i if technical_debt_variation && new_technical_debt_variation - %> - <% if new_technical_debt_variation && new_technical_debt_variation > 0 %> -

- <%= message('widget.rules.added') %> - +<%= format_variation(new_technical_debt, :style => 'none', :default => '-') -%> -

- <% end %> - <% if estimated_cleared_technical_debt && estimated_cleared_technical_debt > 0 %> -

- <%= message('widget.rules.removed') %> - -<%= Internal.i18n.formatLongDuration(estimated_cleared_technical_debt, 'SHORT') -%> -

- <% end %> - <% end %> -
-
-
- <% end %> - -
-
- -
- <% - if @dashboard_configuration.selected_period? - issues_variation = variation_value(issues) - new_issues_variation = variation_value(new_issues) - estimated_cleared_issues = (new_issues_variation - issues_variation).to_i if issues_variation && new_issues_variation - %> - <% if new_issues_variation && new_issues_variation > 0 %> -

- <%= message('widget.rules.added') %> - +<%= format_variation(new_issues, :style => 'none', :default => '-') -%> -

- <% end %> - <% if estimated_cleared_issues && estimated_cleared_issues > 0 %> -

- <%= message('widget.rules.removed') %> - -<%= number_with_precision(estimated_cleared_issues, :precision => 0) -%> -

- <% end %> - <% end %> -
-
-
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
- - <%= message('blocker') -%> - - - <%= format_measure(blocker_issues) -%> - - - <% if @dashboard_configuration.selected_period? %> - +<%= format_variation(new_blocker_issues, :style => 'none', :default => '-') -%> - <% end %> -
- - <%= message('critical') -%> - - - <%= format_measure(critical_issues) -%> - - - <% if @dashboard_configuration.selected_period? %> - +<%= format_variation(new_critical_issues, :style => 'none', :default => '-') -%> - <% end %> -
- - <%= message('major') -%> - - - <%= format_measure(major_issues) -%> - - - <% if @dashboard_configuration.selected_period? %> - +<%= format_variation(new_major_issues, :style => 'none', :default => '-') -%> - <% end %> -
- - <%= message('minor') -%> - - - <%= format_measure(minor_issues) -%> - - - <% if @dashboard_configuration.selected_period? %> - +<%= format_variation(new_minor_issues, :style => 'none', :default => '-') -%> - <% end %> -
- - <%= message('info') -%> - - - <%= format_measure(info_issues) -%> - - - <% if @dashboard_configuration.selected_period? %> - +<%= format_variation(new_info_issues, :style => 'none', :default => '-') -%> - <% end %> -
-
-
diff --git a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/issues/project_issue_filter.html.erb b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/issues/project_issue_filter.html.erb deleted file mode 100644 index 16edb8192d1..00000000000 --- a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/issues/project_issue_filter.html.erb +++ /dev/null @@ -1,63 +0,0 @@ -<% - container_id = 'widget-issue-filter-' + widget.id.to_s - filter_id = widget_properties['filter'] - filter = Internal.issues.findIssueFilterById(filter_id.to_i) - distribution_axis = widget_properties['distributionAxis'] - is_enough_permissions = filter.shared || (current_user && filter.userLogin == current_user.login) - - if @dashboard_configuration.selected_period? - period_date = @snapshot.period_datetime(@dashboard_configuration.period_index).strftime('%FT%T%z') - else - period_date = nil - end -%> - -<% if filter %> - - <% if is_enough_permissions %> - - <% @widget_title = " 'component_issues', :action => 'index'})}?id=#{u(@project.key)}##{filter.data}\">#{h(filter.name)}" %> - <% if widget_properties['displayFilterDescription'] && !filter.description.blank? %> -

<%= h filter.description -%>

- <% end %> - -
- - - <% else %> - -

<%= message 'widget.issue_filter.insufficient_privileges_warning' -%>

- - <% end %> - -<% else %> - -

<%= message 'widget.issue_filter.unknown_filter_warning' -%>

- -<% end %> diff --git a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/it_coverage.html.erb b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/it_coverage.html.erb deleted file mode 100644 index 52c01fe6728..00000000000 --- a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/it_coverage.html.erb +++ /dev/null @@ -1,213 +0,0 @@ -<% - it_coverage=measure('it_coverage') - overall_coverage=measure('overall_coverage') - - if it_coverage || overall_coverage --%> -
- - <% if it_coverage -%> -
-
- -
- <%= message('widget.it-coverage.name') -%> - - <%= format_measure(it_coverage, :url => url_for_drilldown('it_coverage'), :default => '-') %> - <%= format_variation(it_coverage) if dashboard_configuration.selected_period? -%> - -
- - <% - it_line_coverage=measure('it_line_coverage') - if it_line_coverage - %> -
- <%= message('widget.it-coverage.line_coverage.suffix') -%> - - <%= format_measure(it_line_coverage, :url => url_for_drilldown('it_uncovered_lines', :highlight => 'it_line_coverage')) %> - <%= format_variation(it_line_coverage) if dashboard_configuration.selected_period? -%> - -
- <% end %> - - <% - it_branch_coverage=measure('it_branch_coverage') - if it_branch_coverage - %> -
- <%= message('widget.it-coverage.condition_coverage.suffix') -%> - - <%= format_measure(it_branch_coverage, :url => url_for_drilldown('it_uncovered_conditions', :highlight => 'it_branch_coverage')) %> - <%= format_variation(it_branch_coverage) if dashboard_configuration.selected_period? -%> - -
- <% end %> - - <% - if dashboard_configuration.selected_period? - new_lines_to_cover_measure=measure('new_it_lines_to_cover') - if new_lines_to_cover_measure - new_lines=new_lines_to_cover_measure.variation(dashboard_configuration.period_index) - if new_lines - new_coverage=measure('new_it_coverage') - new_line_coverage=measure('new_it_line_coverage') - new_branch_coverage=measure('new_it_branch_coverage') - %> - <% if new_lines.to_i==0 %> -
- <%= message('widget.it-coverage.on_new_code') -%> - -

<%= message('widget.it-coverage.no_new_lines_to_cover') -%>

-
- <% else %> - - <% if new_coverage %> -
- <%= message('widget.it-coverage.on_new_code') -%> - - <%= format_measure(new_coverage, - :period => dashboard_configuration.period_index, - :url => url_for_drilldown(new_coverage, :period => dashboard_configuration.period_index), - :default => '-') %> - -
- <% end %> - - <% if new_line_coverage %> -
- <%= message('widget.it-coverage.line_coverage.suffix') -%> - - <%= format_measure(new_line_coverage, - :period => dashboard_configuration.period_index, - :url => url_for_drilldown(new_line_coverage, :period => dashboard_configuration.period_index)) %> - -
- <% end %> - - <% if new_branch_coverage %> -
- <%= message('widget.it-coverage.condition_coverage.suffix') -%> - - <%= format_measure(new_branch_coverage, - :period => dashboard_configuration.period_index, - :url => url_for_drilldown(new_branch_coverage, :period => dashboard_configuration.period_index)) %> - -
- <% end %> - - <% end %> - - <% end %> - <% end %> - <% end %> - -
-
- <% end %> - - <% if overall_coverage -%> -
-
- -
- <%= message('widget.overall-coverage.name') -%> - - <%= format_measure(overall_coverage, :url => url_for_drilldown('overall_coverage'), :default => '-') %> - <%= format_variation(overall_coverage) if dashboard_configuration.selected_period? -%> - -
- - <% - overall_line_coverage=measure('overall_line_coverage') - if overall_line_coverage - %> -
- <%= message('widget.overall-coverage.line_coverage.suffix') -%> - - <%= format_measure(overall_line_coverage, :url => url_for_drilldown('overall_uncovered_lines', :highlight => 'overall_line_coverage')) %> - <%= format_variation(overall_line_coverage) if dashboard_configuration.selected_period? -%> - -
- <% end %> - - <% - overall_branch_coverage=measure('overall_branch_coverage') - if overall_branch_coverage - %> -
- <%= message('widget.overall-coverage.condition_coverage.suffix') -%> - - <%= format_measure(overall_branch_coverage, :url => url_for_drilldown('overall_uncovered_conditions', :highlight => 'overall_branch_coverage')) %> - <%= format_variation(overall_branch_coverage) if dashboard_configuration.selected_period? -%> - -
- <% end %> - - <% - if dashboard_configuration.selected_period? - new_lines_to_cover_measure=measure('new_overall_lines_to_cover') - if new_lines_to_cover_measure - new_lines=new_lines_to_cover_measure.variation(dashboard_configuration.period_index) - if new_lines - new_coverage=measure('new_overall_coverage') - new_line_coverage=measure('new_overall_line_coverage') - new_branch_coverage=measure('new_overall_branch_coverage') - %> - <% if new_lines.to_i==0 %> -
- <%= message('widget.overall-coverage.on_new_code') -%> - -

<%= message('widget.overall-coverage.no_new_lines_to_cover') -%>

-
- <% else %> - - <% if new_coverage %> -
- <%= message('widget.overall-coverage.on_new_code') -%> - - <%= format_measure(new_coverage, - :period => dashboard_configuration.period_index, - :url => url_for_drilldown(new_coverage, :period => dashboard_configuration.period_index), - :default => '-') %> - <%= format_variation(new_coverage) if dashboard_configuration.selected_period? -%> - -
- <% end %> - - <% if new_line_coverage %> -
- <%= message('widget.overall-coverage.line_coverage.suffix') -%> - - <%= format_measure(new_line_coverage, - :period => dashboard_configuration.period_index, - :url => url_for_drilldown(new_line_coverage, :period => dashboard_configuration.period_index)) %> - <%= format_variation(new_line_coverage) if dashboard_configuration.selected_period? -%> - -
- <% end %> - - <% if new_branch_coverage %> -
- <%= message('widget.overall-coverage.condition_coverage.suffix') -%> - - <%= format_measure(new_branch_coverage, - :period => dashboard_configuration.period_index, - :url => url_for_drilldown(new_branch_coverage, :period => dashboard_configuration.period_index)) %> - <%= format_variation(new_branch_coverage) if dashboard_configuration.selected_period? -%> - -
- <% end %> - - <% end %> - - <% end %> - <% end %> - <% end %> - -
-
- <% end %> - -
-<% end %> diff --git a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/measure_filter_list.html.erb b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/measure_filter_list.html.erb deleted file mode 100644 index 438c7f49d5b..00000000000 --- a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/measure_filter_list.html.erb +++ /dev/null @@ -1,28 +0,0 @@ -<% - filter_id = widget_properties['filter'] - page_size = widget_properties['pageSize'] - filter = MeasureFilter.find_by_id(filter_id.to_i) if filter_id - if filter - filter.load_criteria_from_data - if !filter.require_authentication? || logged_in? - filter.set_criteria_value('display', 'list') - filter.set_criteria_value('pageSize', page_size) - filter.execute(self, :user => current_user) - @widget_title = link_to h(filter.name), {:controller => 'measures', :action => 'filter', :id => filter.id} -%> - - <% if widget_properties['displayFilterDescription'] && !filter.description.blank? %> -
- <%= h filter.description -%> -
- <% end %> - - <%= render :partial => 'measures/display_list', :locals => {:edit_mode => false, :filter => filter, :widget_id => widget.id} -%> -<% - end - else -%> -

<%= image_tag 'warning.png' %> <%= message 'measure_filter.widget.unknown_filter_warning' -%>

-<% - end -%> diff --git a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/measures/measure_filter_bubble_chart.html.erb b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/measures/measure_filter_bubble_chart.html.erb deleted file mode 100644 index c5a23025495..00000000000 --- a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/measures/measure_filter_bubble_chart.html.erb +++ /dev/null @@ -1,68 +0,0 @@ -<% - containerId = 'bubble-chart-widget' + widget.id.to_s - chartTitle = widget_properties["chartTitle"] - chartHeight = widget_properties["chartHeight"] - filterId = widget_properties["filter"].to_i - xMetric = widget_properties["xMetric"] - yMetric = widget_properties["yMetric"] - sizeMetric = widget_properties["sizeMetric"] - xLog = !!widget_properties["xLogarithmic"] - yLog = !!widget_properties["yLogarithmic"] - maxItems = widget_properties["maxItems"].to_i - - filter = MeasureFilter.find_by_id(filterId.to_i) - if filter - @widget_title = link_to h(filter.name), {:controller => 'measures', :action => 'filter', :id => filter.id, :display => 'list'} -%> - -
- - - - <% if chartTitle %> -

<%= h(chartTitle) -%>

- <% end %> - -
- - - - -<% else %> -

<%= image_tag 'warning.png' %> <%= message 'measure_filter.widget.unknown_filter_warning' -%>

-<% end %> diff --git a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/measures/measure_filter_cloud.html.erb b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/measures/measure_filter_cloud.html.erb deleted file mode 100644 index c45bb01cfcc..00000000000 --- a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/measures/measure_filter_cloud.html.erb +++ /dev/null @@ -1,59 +0,0 @@ -<% - containerId = 'word-cloud' + widget.id.to_s - chartTitle = widget_properties['chartTitle'] - filterId = widget_properties['filter'].to_i - maxItems = widget_properties['maxItems'].to_i - - filter = MeasureFilter.find_by_id(filterId.to_i) - if filter - @widget_title = link_to h(filter.name), {:controller => 'measures', :action => 'filter', :id => filter.id, :display => 'list'} -%> - -
- - - - <% if chartTitle %> -

<%= h(chartTitle) -%>

- <% end %> - -
- - - - -<% else %> -

<%= image_tag 'warning.png' %> <%= message 'measure_filter.widget.unknown_filter_warning' -%>

-<% end %> diff --git a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/measures/measure_filter_histogram.html.erb b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/measures/measure_filter_histogram.html.erb deleted file mode 100644 index 98842071f46..00000000000 --- a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/measures/measure_filter_histogram.html.erb +++ /dev/null @@ -1,62 +0,0 @@ -<% - containerId = 'histogram-widget' + widget.id.to_s - chartTitle = widget_properties["chartTitle"] - filterId = widget_properties["filter"].to_i - maxItems = widget_properties["maxItems"].to_i - reverseOrder = widget_properties["reverseOrder"] - relativeScale = widget_properties["relativeScale"] - - filter = MeasureFilter.find_by_id(filterId.to_i) - if filter - @widget_title = link_to h(filter.name), {:controller => 'measures', :action => 'filter', :id => filter.id, :display => 'list'} -%> - -
- - - - <% if chartTitle %> -

<%= h(chartTitle) -%>

- <% end %> - -
- - - - -<% else %> -

<%= image_tag 'warning.png' %> <%= message 'measure_filter.widget.unknown_filter_warning' -%>

-<% end %> diff --git a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/measures/measure_filter_pie_chart.html.erb b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/measures/measure_filter_pie_chart.html.erb deleted file mode 100644 index c011ede3f1d..00000000000 --- a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/measures/measure_filter_pie_chart.html.erb +++ /dev/null @@ -1,64 +0,0 @@ -<% - containerId = 'pie-chart-widget' + widget.id.to_s - chartHeight = widget_properties["chartHeight"] - chartTitle = widget_properties["chartTitle"] - filterId = widget_properties["filter"].to_i - maxItems = widget_properties["maxItems"].to_i - - filter = MeasureFilter.find_by_id(filterId.to_i) - if filter - @widget_title = link_to h(filter.name), {:controller => 'measures', :action => 'filter', :id => filter.id, :display => 'list'} -%> - -
- - - - <% if chartTitle %> -

<%= h(chartTitle) -%>

- <% end %> - -
- - - - -<% else %> -

<%= image_tag 'warning.png' %> <%= message 'measure_filter.widget.unknown_filter_warning' -%>

-<% end %> diff --git a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/measures/measure_filter_treemap.html.erb b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/measures/measure_filter_treemap.html.erb deleted file mode 100644 index 48c08f864f2..00000000000 --- a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/measures/measure_filter_treemap.html.erb +++ /dev/null @@ -1,67 +0,0 @@ -<% - containerId = 'treemap-widget' + widget.id.to_s - chartTitle = widget_properties['chartTitle'] - filterId = widget_properties['filter'].to_i - maxItems = widget_properties['maxItems'].to_i - - # SONAR-2456 - # When metrics are removed, we have to manually set them to the default ones - colorMetric = widget_properties['colorMetric'] || Metric.by_key('coverage') - sizeMetric = widget_properties['sizeMetric'] || Metric.by_key('ncloc') - - filter = MeasureFilter.find_by_id(filterId.to_i) - if filter - @widget_title = link_to h(filter.name), {:controller => 'measures', :action => 'filter', :id => filter.id, :display => 'list'} -%> - -
- - - - <% if chartTitle %> -

<%= h(chartTitle) -%>

- <% end %> - -
- - - - -<% else %> -

<%= image_tag 'warning.png' %> <%= message 'measure_filter.widget.unknown_filter_warning' -%>

-<% end %> diff --git a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/project_file_cloud.html.erb b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/project_file_cloud.html.erb deleted file mode 100644 index 8cb1c029938..00000000000 --- a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/project_file_cloud.html.erb +++ /dev/null @@ -1,76 +0,0 @@ -<% - containerId = 'project-file-widget' + widget.id.to_s - colorMetric = widget_properties['colorMetric'] - sizeMetric = widget_properties['sizeMetric'] - chartTitle = widget_properties['chartTitle'] - maxItems = widget_properties['maxItems'].to_i -%> - -
- - - - <% if chartTitle %> -

<%= h(chartTitle) -%>

- <% end %> - -
- - - - diff --git a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/size.html.erb b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/size.html.erb deleted file mode 100644 index 1a4387b1ecc..00000000000 --- a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/size.html.erb +++ /dev/null @@ -1,195 +0,0 @@ -<% - lines=measure('lines') - ncloc=measure('ncloc') - ncloc_language_distribution = measure('ncloc_language_distribution') - ncloc_language_dist_hash = Hash[*(ncloc_language_distribution.data.split(';').map { |elt| elt.split('=') }.flatten)] if ncloc && ncloc_language_distribution - generated_ncloc=measure('generated_ncloc') - generated_lines=measure('generated_lines') - accessors=measure('accessors') - classes=measure('classes') - files=measure('files') - directories=measure('directories') - functions=measure('functions') - projects=measure('projects') - if measure('lines') || ncloc - files=measure('files') - statements=measure('statements') - languages = Api::Utils.java_facade.getLanguages() -%> - -
- -
-
- <% if ncloc %> -

- <%= message('metric.ncloc.name') -%> - - <%= format_measure(ncloc, :url => url_for_drilldown(ncloc)) %> - <%= format_variation(ncloc) if dashboard_configuration.selected_period? -%> - -

- <% if generated_ncloc && generated_ncloc.value>0 %> -

- <%= message('including_abbreviated') -%> - <%= format_measure(generated_ncloc, :url => url_for_drilldown(generated_ncloc)) -%> <%= format_variation(generated_ncloc) if dashboard_configuration.selected_period? -%> - <%= message('metric.generated_ncloc.name.suffix') -%> -

- <% end %> - - <% if ncloc_language_dist_hash %> - <% if ncloc_language_dist_hash.size > 1 %> - - <% - max = Math.sqrt(ncloc_language_dist_hash.max_by{|_k,v| v.to_i}[1].to_i) - - # Sort lines language distribution by lines count - languages_by_key = Hash[languages.collect { |l| [l.getKey(), l.getName] }] - ncloc_language_dist_hash.sort {|v1,v2| v2[1].to_i <=> v1[1].to_i }.each do |language_key, language_ncloc| - %> - - - - - <% end %> -
- <% if language_key.eql? '' %> - <%= message('unknown') -%> - <% else %> - <% language = languages.find { |l| l.getKey()==language_key.to_s } -%> - <%= language ? language.getName() : language_key -%> - <% end %> - - <%= ncloc.format_numeric_value(language_ncloc) %> -
- - <% else %> - <% - language_key = ncloc_language_dist_hash.first[0] - if language_key.eql? '' %> - <%= message('unknown') -%> - <% else %> - <% language = languages.find { |l| l.getKey()==language_key.to_s } -%> - <%= language ? language.getName() : language_key -%> - <% end %> - <% end %> - <% end %> - <% else %> -

- <%= message('metric.lines.name') -%> - - <%= format_measure(lines, :url => url_for_drilldown(ncloc)) %> - <%= format_variation(lines) if dashboard_configuration.selected_period? -%> - -

- <% end %> -
-
- -
-
-

- <%= message('metric.files.name') -%> - - <%= format_measure(files, :url => url_for_drilldown(files)) %> - <%= format_variation(files) if dashboard_configuration.selected_period? -%> - -

- - <% if directories %> -

- <%= message('metric.directories.name') -%> - - <%= format_measure(directories, :url => url_for_drilldown(directories)) %> - <%= format_variation(directories) if dashboard_configuration.selected_period? -%> - -

- <% end %> - -

- <%= message('metric.lines.name') -%> - - <%= format_measure(lines, :url => url_for_drilldown(lines)) %> - <%= format_variation(lines) if dashboard_configuration.selected_period? -%> - -

- - <% if generated_lines && generated_lines.value>0 %> -

- <%= message('including_abbreviated') -%> - <%= format_measure(generated_lines, :url => url_for_drilldown(generated_lines)) -%> <%= format_variation(generated_lines) if dashboard_configuration.selected_period? -%> - <%= message('metric.generated_lines.name.suffix') -%> -

- <% end %> - - <% if projects %> -

- <%= message('projects') -%> - - <%= format_measure(projects) %> - <%= format_variation(projects) if dashboard_configuration.selected_period? -%> - -

- <% end %> -
-
- -
-
- <% if functions %> -

- <%= message('metric.functions.name') -%> - - <%= format_measure(functions, :url => url_for_drilldown(functions)) %> - <%= format_variation(functions) if dashboard_configuration.selected_period? -%> - -

- <% end %> - - <% if classes %> -

- <%= message('metric.classes.name') -%> - - <%= format_measure(classes, :url => url_for_drilldown(classes)) %> - <%= format_variation(classes) if dashboard_configuration.selected_period? -%> - -

- <% end %> - - <% if statements %> -

- <%= message('metric.statements.name') -%> - - <%= format_measure(statements, :url => url_for_drilldown(statements)) %> - <%= format_variation(statements) if dashboard_configuration.selected_period? -%> - -

- <% end %> - - <% if accessors %> -

- <%= message('metric.accessors.name') -%> - - <%= format_measure(accessors, :url => url_for_drilldown(accessors)) %> - <%= format_variation(accessors) if dashboard_configuration.selected_period? -%> - -

- <% end %> -
-
- -
-<% end %> diff --git a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/technical_debt_pyramid.html.erb b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/technical_debt_pyramid.html.erb deleted file mode 100644 index 6f5464e92ea..00000000000 --- a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/technical_debt_pyramid.html.erb +++ /dev/null @@ -1,156 +0,0 @@ -<% - technical_debt = measure('sqale_index') - - root_characteristics = Internal.debt.characteristics().to_a - - should_display_diff_measures = dashboard_configuration.selected_period? && technical_debt.variation(dashboard_configuration.period_index)!=nil - if technical_debt.nil? || root_characteristics.empty? -%> - -

<%= message('widget.technical_debt_pyramid.name') -%>

- <%= message('widget.technical_debt_pyramid.no_info_available') -%> - -<% - else -%> - - - - - - - - - - - - <% - measures_by_characteristic_id={} - ProjectMeasure.find(:all, - :conditions => ['characteristic_id IN (?) AND snapshot_id=? AND metric_id=?', - root_characteristics.map{|c| c.id}, @snapshot.id, technical_debt.metric().id]).each do |measure| - measures_by_characteristic_id[measure.characteristic_id]=measure - end - - total = technical_debt.value - cumulated=total - - if should_display_diff_measures - diff_by_characteristic_id={} - total_diff = 0; - root_characteristics.each do |c| - measure = measures_by_characteristic_id[c.id] - if measure && measure.variation(dashboard_configuration.period_index) - diff_by_characteristic_id[c.id] = measure.variation(dashboard_configuration.period_index) - total_diff += measure.variation(dashboard_configuration.period_index) - end - end - end - - root_characteristics.sort_by {|characteristic| characteristic.order}.each do |characteristic| - measure=measures_by_characteristic_id[characteristic.id] - value=(measure && measure.value ? measure.value : 0) - total_size=(total>0 ? (100*cumulated/total).round(3): 0) - value_size=(cumulated>0 ? (100*value/cumulated).round(3): 100) - drilldown_url = url_for_drilldown('sqale_index', :characteristic => characteristic.key) - %> - - - - - - - <% - cumulated-=value - end - %> - -
-

<%= message('widget.technical_debt_pyramid.name') -%>

-
-

 <%= message('widget.technical_debt_pyramid.technical_debt') -%>

-
-

<%= message('widget.technical_debt_pyramid.total') -%>

-
<%= h(characteristic.name) -%> - -
-
-
-
-
- <%= Internal.i18n.formatLongDuration(value.to_i, 'SHORT') -%> - <% if should_display_diff_measures %> - <% if diff_by_characteristic_id[characteristic.id] %> - <%= format_variation(measure) -%> - <% else %> - (+0) - <% end %> - <% end %> - - <%= Internal.i18n.formatLongDuration(cumulated.to_i, 'SHORT') -%> - <% - if should_display_diff_measures - css_style = 'var' - css_style += 'b' if total_diff < 0 - css_style += 'w' if total_diff > 0 - diff_to_display = (total_diff < 0 ? '' : '+') + Internal.i18n.formatLongDuration(total_diff.to_i, 'SHORT') - %> - (<%= diff_to_display -%>) - <% - total_diff -= diff_by_characteristic_id[characteristic.id] if diff_by_characteristic_id[characteristic.id] - end - %> -
- -<% end %> diff --git a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/time_machine.html.erb b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/time_machine.html.erb deleted file mode 100644 index 3c00988eae9..00000000000 --- a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/time_machine.html.erb +++ /dev/null @@ -1,130 +0,0 @@ -<% - rows_by_metric_id={} - - # Retrieve widget settings - metric_ids = [] - (1..10).each do |index| - metric=widget_properties["metric#{index}"] - if metric - metric_ids << metric.id - row=Sonar::TimemachineRow.new(metric) - rows_by_metric_id[metric.id]=row - end - end - if metric_ids.empty? - # No metric has been selected, it's the first time the widget is displayed: 'ncloc' is the default metric - ncloc = Metric.find(:first, :conditions => "name = 'ncloc'") - metric_ids << ncloc.id - end - number_of_columns = widget_properties["numberOfColumns"] - - # Retrieve the measures for each metric on each snapshot - options = {} - from_date = dashboard_configuration.from_datetime - if from_date - options[:from] = from_date - end - snapshots=Snapshot.for_timemachine_widget(@resource, number_of_columns, options) - sids = snapshots.collect { |s| s.id }.uniq - measures=ProjectMeasure.find(:all, - :conditions => - ["snapshot_id IN (:snapshot_id) AND metric_id IN (:metric_id) AND rule_id IS NULL AND characteristic_id IS NULL AND person_id IS NULL", - {:snapshot_id => sids, :metric_id => metric_ids} - ] - ) - - - # Prepare the rows to display - snapshot_by_id={} - snapshots.each do |s| - snapshot_by_id[s.id]=s - end - measures.each do |measure| - next unless measure.metric - - if measure.metric.timemachine? && (measure.value || measure.text_value) - row=rows_by_metric_id[measure.metric_id] - - #optimization : avoid eager loading of snapshots - measure.snapshot=snapshot_by_id[measure.snapshot_id] - row.add_measure(measure) - end - end - - # Create the list of rows to display in the same order as defined by the user - rows=[] - metric_ids.each do |metric_id| - row = rows_by_metric_id[metric_id] - if row - rows< - -<% if widget_properties["title"] %> -
-

<%= h(widget_properties["title"]) -%>

-
-<% end %> - -
- - - - - - <% - snapshots.each do |snapshot| - event = snapshot.event('Version') - %> - - <% end %> - <% if display_sparkline %> - - <% end %> - - - - - <% - rows.select { |row| row.metric.val_type != Metric::VALUE_TYPE_DISTRIB }.each do |row| - %> - - - <% - snapshots.each do |snapshot| - measure=row.measure(snapshot) - %> - - <% end %> - <% - if display_sparkline - sparkline_url = sparkline_urls_by_row[row] - %> - - <% end %> - - <% end %> - - -
- <%= l snapshot.created_at.to_date -%> -
- <%= event.name unless event==nil -%> -
- <%= row.metric.short_name %> - <%= format_measure(measure, :skip_span_id => true) %> - <%= image_tag(sparkline_url) if sparkline_url %> -
- -
diff --git a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/timeline.html.erb b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/timeline.html.erb deleted file mode 100644 index 7e7ad6ec44f..00000000000 --- a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/timeline.html.erb +++ /dev/null @@ -1,193 +0,0 @@ -<% - # Retrieve widget settings - metric_data_map = {} - metric_map = {} - metrics_specified = false - (1..3).each do |index| - metric=widget_properties["metric#{index}"] - # we check that the current resource has the selected metric on the last snapshot - # => if not, we do not display this metric at all - if metric - metrics_specified = true - if measure(metric) - metric_data_map[metric.id] = [] - metric_map[metric.id] = metric - end - end - end - unless metrics_specified - # No metric has been selected, it's the first time the widget is displayed: 'ncloc' is the default metric - ncloc = Metric.by_name('ncloc') - metric_data_map[ncloc.id] = [] - metric_map[ncloc.id] = ncloc - end - chartHeight = widget_properties["chartHeight"] - - unless metric_data_map.values.empty? - # Retrieve metric trend information - options = {} - from_date = dashboard_configuration.from_datetime - if from_date - options[:from] = from_date - end - metric_count_per_snapshot_id = {} - TrendsChart.time_machine_measures(@resource, metric_data_map.keys, options).each() do |trend_item| - sid = trend_item["sid"] - if metric_count_per_snapshot_id[sid] - metric_count_per_snapshot_id[sid] += 1 - else - metric_count_per_snapshot_id[sid] = 1 - end - metric_data_map[trend_item["metric_id"].to_i] << {:date => Time.at(trend_item["created_at"].to_i/1000), :value => trend_item["value"], :sid => trend_item["sid"]} - end - - # Create JS structures to print out in the HTML page - js_data = "[" - js_snapshots = "[" - js_metrics = "[" - total_number_of_metrics = metric_map.keys.size() - metric_data_map.keys.each_with_index() do |metric_id, index| - unless metric_data_map[metric_id].empty? - js_metrics += "\"" + metric_map[metric_id].short_name + "\"," - js_data += "[" - metric_data_map[metric_id].each() do |metric_data| - # for every metric value, we need to check that the corresponding snapshot has values for each metric - if metric_count_per_snapshot_id[metric_data[:sid]]==total_number_of_metrics - m_date = metric_data[:date] - m_value = sprintf("%0.02f", metric_data[:value]) - m_value_localized = ProjectMeasure.new(:metric => metric_map[metric_id]).format_numeric_value(metric_data[:value], {}) - js_data += "{x:d(" - js_data += m_date.year.to_s - js_data += "," - # Need to decrease by 1 the month as the JS Date object start months at 0 (= January) - js_data += (m_date.month - 1).to_s - js_data += "," - js_data += m_date.day.to_s - js_data += "," - js_data += m_date.hour.to_s - js_data += "," - js_data += m_date.min.to_s - js_data += "," - js_data += m_date.sec.to_s - js_data += "),y:" - js_data += m_value - js_data += ",yl:\"" - js_data += m_value_localized - js_data += "\"}," - if index == 0 - # we fill the js_snapshots array (no need to do this more than once) - js_snapshots += "{sid:" - js_snapshots += metric_data[:sid].to_s - js_snapshots += ",d:\"" - js_snapshots += human_short_date m_date - js_snapshots += "\"}," - end - end - end - js_data = js_data.chomp(',') + "]," - end - end - js_data = js_data.chomp(',') + "]" - js_snapshots = js_snapshots.chomp(',') + "]" - js_metrics = js_metrics.chomp(',') + "]" - - # Prepare also event structure if required - unless widget_properties["hideEvents"] - events = {} - unless from_date - # find the oldest date - metric_data_map.values.each() do |metric_data_array| - first_date = metric_data_array[0][:date] - from_date = first_date if !from_date || from_date > first_date - end - end - Event.find(:all, :conditions => ["component_uuid=? AND event_date>=?", @resource.uuid, from_date.to_i*1000], :order => 'event_date').each() do |event| - if events[event.event_date] - events[event.event_date] << event - else - date_entry = [event] - events[event.event_date] = date_entry - end - end - js_events = "[" - events.keys().sort.each() do |e_date| - e_details = events[e_date] - js_events += "{sid:" - js_events += e_details[0].snapshot_id.to_s - js_events += ",d:d(" - js_events += e_date.year.to_s - js_events += "," - # Need to decrease by 1 the month as the JS Date object start months at 0 (= January) - js_events += (e_date.month - 1).to_s - js_events += "," - js_events += e_date.day.to_s - js_events += "," - js_events += e_date.hour.to_s - js_events += "," - js_events += e_date.min.to_s - js_events += "," - js_events += e_date.sec.to_s - js_events += "),l:[" - e_details.each() do |e| - js_events += "{n:\"" - js_events += json_escape(e.name) - js_events += "\"}," - end - js_events = js_events.chomp(',') + "]}," - end - js_events = js_events.chomp(',') + "]" - end - end - - -%> - - - - -<% if widget_properties["chartTitle"] %> -

<%= h(widget_properties["chartTitle"]) -%>

-<% end %> - - - - -<% - unless metric_data_map.values.empty? - - if metric_data_map.values[0].size == 1 -%> - - <%= message('widget.timeline.timeline_not_displayed') -%> - -<% else %> - <% timeline = 'timeline' + widget.id.to_s %> - -
- - -<% - end - end -%> - diff --git a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/treemap.html.erb b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/treemap.html.erb deleted file mode 100644 index f6a1fbc2b6b..00000000000 --- a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/treemap.html.erb +++ /dev/null @@ -1,85 +0,0 @@ -<% - containerId = 'project-file-widget' + widget.id.to_s - colorMetric = widget_properties['colorMetric'] - sizeMetric = widget_properties['sizeMetric'] - chartTitle = widget_properties['chartTitle'] - maxItems = widget_properties['maxItems'].to_i -%> - -
- - - - <% if chartTitle %> -

<%= h(chartTitle) -%>

- <% end %> - -
- - - - diff --git a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/welcome.html.erb b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/welcome.html.erb deleted file mode 100644 index a3e651d4f03..00000000000 --- a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/welcome.html.erb +++ /dev/null @@ -1 +0,0 @@ -<%= message('widget.welcome.html') -%> \ No newline at end of file diff --git a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/charts/AbstractChartTest.java b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/charts/AbstractChartTest.java deleted file mode 100644 index 31223db492f..00000000000 --- a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/charts/AbstractChartTest.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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 this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.plugins.core.charts; - -import org.apache.commons.io.FileUtils; -import org.jfree.chart.ChartUtilities; -import org.jfree.ui.ApplicationFrame; -import org.jfree.ui.RefineryUtilities; - -import javax.swing.JPanel; - -import java.awt.Dimension; -import java.awt.Graphics; -import java.awt.image.BufferedImage; -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.OutputStream; -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.Date; - -import static org.junit.Assert.assertTrue; - -public abstract class AbstractChartTest { - protected void assertChartSizeGreaterThan(BufferedImage img, int size) throws IOException { - ByteArrayOutputStream output = new ByteArrayOutputStream(); - ChartUtilities.writeBufferedImageAsPNG(output, img); - assertTrue("PNG size in bits=" + output.size(), output.size() > size); - } - - protected void assertChartSizeLesserThan(BufferedImage img, int size) throws IOException { - ByteArrayOutputStream output = new ByteArrayOutputStream(); - ChartUtilities.writeBufferedImageAsPNG(output, img); - assertTrue("PNG size in bits=" + output.size(), output.size() < size); - } - - protected void saveChart(BufferedImage img, String name) throws IOException { - File target = new File("target/tmp-chart", name); - FileUtils.forceMkdir(target.getParentFile()); - ByteArrayOutputStream imgOutput = new ByteArrayOutputStream(); - ChartUtilities.writeBufferedImageAsPNG(imgOutput, img); - OutputStream out = new FileOutputStream(target); - out.write(imgOutput.toByteArray()); - out.close(); - - } - - protected static void displayTestPanel(BufferedImage image) { - ApplicationFrame frame = new ApplicationFrame("testframe"); - BufferedPanel imgPanel = new BufferedPanel(image); - frame.setContentPane(imgPanel); - frame.pack(); - RefineryUtilities.centerFrameOnScreen(frame); - frame.setVisible(true); - } - - protected static Date stringToDate(String sDate) throws ParseException { - SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yy hh'h'mm"); - return sdf.parse(sDate); - } - - private static class BufferedPanel extends JPanel { - private final BufferedImage chartImage; - - public BufferedPanel(BufferedImage chartImage) { - this.chartImage = chartImage; - } - - @Override - protected void paintComponent(Graphics graphics) { - super.paintComponent(graphics); - graphics.drawImage(chartImage, 0, 0, null); - } - - @Override - public Dimension getPreferredSize() { - return new Dimension(chartImage.getWidth(), chartImage.getHeight()); - } - } -} diff --git a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/charts/DistributionAreaChartTest.java b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/charts/DistributionAreaChartTest.java deleted file mode 100644 index 6a535abad16..00000000000 --- a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/charts/DistributionAreaChartTest.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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 this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.plugins.core.charts; - -import org.junit.Test; -import org.sonar.api.charts.ChartParameters; - -import java.awt.image.BufferedImage; -import java.io.IOException; - -public class DistributionAreaChartTest extends AbstractChartTest { - - @Test - public void oneSerie() throws IOException { - DistributionAreaChart chart = new DistributionAreaChart(); - BufferedImage image = chart.generateImage(new ChartParameters("v=0%3D5%3B1%3D22%3B2%3D2")); - assertChartSizeGreaterThan(image, 1000); - saveChart(image, "DistributionAreaChartTest/oneSerie.png"); - } - - @Test - public void manySeries() throws IOException { - DistributionAreaChart chart = new DistributionAreaChart(); - BufferedImage image = chart.generateImage(new ChartParameters("v=0%3D5%3B1%3D22%3B2%3D2|0%3D7%3B1%3D15%3B2%3D4")); - assertChartSizeGreaterThan(image, 1000); - saveChart(image, "DistributionAreaChartTest/manySeries.png"); - } - - @Test - public void manySeriesWithDifferentCategories() throws IOException { - DistributionAreaChart chart = new DistributionAreaChart(); - BufferedImage image = chart.generateImage(new ChartParameters("v=0%3D5%3B1%3D22%3B2%3D2|2%3D7%3B4%3D15%3B9%3D4")); - assertChartSizeGreaterThan(image, 1000); - saveChart(image, "DistributionAreaChartTest/manySeriesWithDifferentCategories.png"); - } - - @Test - public void manySeriesIncludingAnEmptySerie() throws IOException { - // the third serie should not have the second default color, but the third one ! - DistributionAreaChart chart = new DistributionAreaChart(); - BufferedImage image = chart.generateImage(new ChartParameters("v=0%3D5%3B1%3D22%3B2%3D2||2%3D7%3B4%3D15%3B9%3D4")); - assertChartSizeGreaterThan(image, 1000); - saveChart(image, "DistributionAreaChartTest/manySeriesIncludingAnEmptySerie.png"); - } -} diff --git a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/charts/DistributionBarChartTest.java b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/charts/DistributionBarChartTest.java deleted file mode 100644 index 8e50f49ab24..00000000000 --- a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/charts/DistributionBarChartTest.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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 this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.plugins.core.charts; - -import org.junit.Test; -import org.sonar.api.charts.ChartParameters; - -import java.awt.image.BufferedImage; -import java.io.IOException; - -public class DistributionBarChartTest extends AbstractChartTest { - DistributionBarChart chart = new DistributionBarChart(); - - @Test - public void simpleSample() throws IOException { - BufferedImage image = chart.generateImage(new ChartParameters("v=0%3D5%3B1%3D22%3B2%3D2")); - assertChartSizeGreaterThan(image, 1000); - saveChart(image, "DistributionBarChartTest/simpleSample.png"); - } - - @Test - public void addXSuffix() throws IOException { - // should suffix x labels with + - BufferedImage image = chart.generateImage(new ChartParameters("v=0%3D5%3B1%3D22%3B2%3D2&xsuf=%2B")); - assertChartSizeGreaterThan(image, 1000); - saveChart(image, "DistributionBarChartTest/addXSuffix.png"); - } - - @Test - public void addYSuffix() throws IOException { - // should suffix y labels with % - BufferedImage image = chart.generateImage(new ChartParameters("v=0%3D5%3B1%3D22%3B2%3D2&ysuf=%25")); - assertChartSizeGreaterThan(image, 1000); - saveChart(image, "DistributionBarChartTest/addYSuffix.png"); - } - - @Test - public void manySeries() throws IOException { - BufferedImage image = chart.generateImage(new ChartParameters("v=0%3D5%3B1%3D22%3B2%3D2|0%3D7%3B1%3D15%3B2%3D4")); - assertChartSizeGreaterThan(image, 1000); - saveChart(image, "DistributionBarChartTest/manySeries.png"); - } - - @Test - public void manySeriesIncludingAnEmptySerie() throws IOException { - // the third serie should not have the second default color, but the third one ! - BufferedImage image = chart.generateImage(new ChartParameters("v=0%3D5%3B1%3D22%3B2%3D2||0%3D7%3B1%3D15%3B2%3D4")); - assertChartSizeGreaterThan(image, 1000); - saveChart(image, "DistributionBarChartTest/manySeriesIncludingAnEmptySerie.png"); - } - - @Test - public void overridenSize() throws IOException { - BufferedImage image = chart.generateImage(new ChartParameters("v=0%3D5%3B1%3D22%3B2%3D2|0%3D7%3B1%3D15%3B2%3D4&w=500&h=200")); - assertChartSizeGreaterThan(image, 1000); - saveChart(image, "DistributionBarChartTest/overridenSize.png"); - } - - @Test - public void changeColor() throws IOException { - BufferedImage image = chart.generateImage(new ChartParameters("v=0%3D5%3B1%3D22%3B2%3D2&c=777777&bgc=777777")); - assertChartSizeGreaterThan(image, 1000); - saveChart(image, "DistributionBarChartTest/changeColor.png"); - } - - @Test - public void smallSize() throws IOException { - BufferedImage image = chart.generateImage(new ChartParameters("v=0%3D5%3B1%3D22%3B2%3D2%3B4%3D22%3B5%3D22%3B6%3D22&c=777777&w=120&h=80&fs=8")); - assertChartSizeGreaterThan(image, 500); - saveChart(image, "DistributionBarChartTest/smallSize.png"); - } -} diff --git a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/dashboards/GlobalDefaultDashboardTest.java b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/dashboards/GlobalDefaultDashboardTest.java deleted file mode 100644 index a89ebdbfa59..00000000000 --- a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/dashboards/GlobalDefaultDashboardTest.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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 this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.plugins.core.dashboards; - -import org.junit.Before; -import org.junit.Test; -import org.sonar.api.web.Dashboard; -import org.sonar.api.web.Dashboard.Widget; -import org.sonar.core.measure.db.MeasureFilterDao; -import org.sonar.core.measure.db.MeasureFilterDto; -import org.sonar.plugins.core.CorePlugin; -import org.sonar.plugins.core.measurefilters.MyFavouritesFilter; -import org.sonar.plugins.core.measurefilters.ProjectFilter; -import org.sonar.plugins.core.widgets.WelcomeWidget; -import org.sonar.plugins.core.widgets.measures.MeasureFilterAsTreemapWidget; -import org.sonar.plugins.core.widgets.measures.MeasureFilterListWidget; - -import java.util.List; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -public class GlobalDefaultDashboardTest { - GlobalDefaultDashboard template; - MeasureFilterDao dao; - - @Before - public void init() { - dao = mock(MeasureFilterDao.class); - template = new GlobalDefaultDashboard(dao); - } - - @Test - public void should_have_a_name() { - assertThat(template.getName()).isEqualTo("Home"); - } - - @Test - public void should_be_registered_as_an_extension() { - assertThat(new CorePlugin().getExtensions()).contains(template.getClass()); - } - - @Test - public void should_create_global_dashboard_with_four_widgets() { - when(dao.findSystemFilterByName(MyFavouritesFilter.NAME)).thenReturn( - new MeasureFilterDto().setId(100L) - ); - when(dao.findSystemFilterByName(ProjectFilter.NAME)).thenReturn( - new MeasureFilterDto().setId(101L) - ); - Dashboard dashboard = template.createDashboard(); - List firstColumn = dashboard.getWidgetsOfColumn(1); - assertThat(firstColumn).hasSize(2); - assertThat(firstColumn.get(0).getId()).isEqualTo(WelcomeWidget.ID); - assertThat(firstColumn.get(1).getId()).isEqualTo(MeasureFilterListWidget.ID); - assertThat(firstColumn.get(1).getProperty("filter")).isEqualTo("100"); - - List secondColumn = dashboard.getWidgetsOfColumn(2); - assertThat(secondColumn).hasSize(2); - assertThat(secondColumn.get(0).getId()).isEqualTo(MeasureFilterListWidget.ID); - assertThat(secondColumn.get(0).getProperty("filter")).isEqualTo("101"); - assertThat(secondColumn.get(1).getId()).isEqualTo(MeasureFilterAsTreemapWidget.ID); - assertThat(secondColumn.get(1).getProperty("filter")).isEqualTo("101"); - } - - @Test - public void should_not_fail_if_filter_widgets_not_found() { - when(dao.findSystemFilterByName(MyFavouritesFilter.NAME)).thenReturn(null); - when(dao.findSystemFilterByName(ProjectFilter.NAME)).thenReturn(null); - - Dashboard dashboard = template.createDashboard(); - List firstColumn = dashboard.getWidgetsOfColumn(1); - assertThat(firstColumn).hasSize(1); - assertThat(firstColumn.get(0).getId()).isEqualTo(WelcomeWidget.ID); - - List secondColumn = dashboard.getWidgetsOfColumn(2); - assertThat(secondColumn).isEmpty(); - } -} diff --git a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/dashboards/ProjectDefaultDashboardTest.java b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/dashboards/ProjectDefaultDashboardTest.java deleted file mode 100644 index a5168888bed..00000000000 --- a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/dashboards/ProjectDefaultDashboardTest.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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 this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.plugins.core.dashboards; - -import org.junit.Test; -import org.sonar.api.web.Dashboard; -import org.sonar.api.web.DashboardLayout; -import org.sonar.plugins.core.CorePlugin; - -import static org.assertj.core.api.Assertions.assertThat; - -public class ProjectDefaultDashboardTest { - ProjectDefaultDashboard template = new ProjectDefaultDashboard(); - - @Test - public void should_have_a_name() { - assertThat(template.getName()).isEqualTo("Dashboard"); - } - - @Test - public void should_be_registered_as_an_extension() { - assertThat(new CorePlugin().getExtensions()).contains(template.getClass()); - } - - @Test - public void should_create_dashboard() { - Dashboard dashboard = template.createDashboard(); - - assertThat(dashboard.getLayout()).isEqualTo(DashboardLayout.TWO_COLUMNS); - assertThat(dashboard.getWidgets()).hasSize(9); - } -} diff --git a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/dashboards/ProjectIssuesDashboardTest.java b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/dashboards/ProjectIssuesDashboardTest.java deleted file mode 100644 index 716a43843b6..00000000000 --- a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/dashboards/ProjectIssuesDashboardTest.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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 this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -package org.sonar.plugins.core.dashboards; - -import org.junit.Before; -import org.junit.ClassRule; -import org.junit.Test; -import org.junit.experimental.categories.Category; -import org.sonar.api.web.Dashboard; -import org.sonar.api.web.DashboardLayout; -import org.sonar.core.issue.db.IssueFilterDao; -import org.sonar.core.persistence.DbTester; -import org.sonar.plugins.core.CorePlugin; -import org.sonar.test.DbTests; - -import static org.assertj.core.api.Assertions.assertThat; - -@Category(DbTests.class) -public class ProjectIssuesDashboardTest { - - @ClassRule - public static final DbTester dbTester = new DbTester(); - - ProjectIssuesDashboard template; - - @Before - public void setUp() { - IssueFilterDao issueFilterDao = new IssueFilterDao(dbTester.myBatis()); - template = new ProjectIssuesDashboard(issueFilterDao); - } - - @Test - public void should_have_a_name() { - assertThat(template.getName()).isEqualTo("Issues"); - } - - @Test - public void should_be_registered_as_an_extension() { - assertThat(new CorePlugin().getExtensions()).contains(template.getClass()); - } - - @Test - public void should_create_dashboard() { - dbTester.prepareDbUnit(getClass(), "filters.xml"); - Dashboard dashboard = template.createDashboard(); - - assertThat(dashboard.getLayout()).isEqualTo(DashboardLayout.TWO_COLUMNS); - assertThat(dashboard.getWidgets()).hasSize(5); - } - - @Test - public void should_provide_clean_error_message_on_failure() { - try { - template.createDashboard(); - } catch (IllegalStateException illegalState) { - assertThat(illegalState).hasMessage("Could not find a provided issue filter with name 'Unresolved Issues'"); - } - } -} diff --git a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/dashboards/ProjectTimeMachineDashboardTest.java b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/dashboards/ProjectTimeMachineDashboardTest.java deleted file mode 100644 index e207bfe2be8..00000000000 --- a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/dashboards/ProjectTimeMachineDashboardTest.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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 this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.plugins.core.dashboards; - -import org.junit.Test; -import org.sonar.api.web.Dashboard; -import org.sonar.api.web.Dashboard.Widget; -import org.sonar.api.web.DashboardLayout; -import org.sonar.plugins.core.CorePlugin; - -import static org.assertj.core.api.Assertions.assertThat; - -public class ProjectTimeMachineDashboardTest { - ProjectTimeMachineDashboard template = new ProjectTimeMachineDashboard(); - - @Test - public void should_have_a_name() { - assertThat(template.getName()).isEqualTo("TimeMachine"); - } - - @Test - public void should_be_registered_as_an_extension() { - assertThat(new CorePlugin().getExtensions()).contains(template.getClass()); - } - - @Test - public void should_create_dashboard() { - Dashboard dashboard = template.createDashboard(); - - assertThat(dashboard.getLayout()).isEqualTo(DashboardLayout.TWO_COLUMNS); - assertThat(dashboard.getWidgets()).hasSize(7); - - for (Widget widget : dashboard.getWidgets()) { - if (widget.getId().equals("time_machine")) { - assertThat(widget.getProperty("displaySparkLine")).isEqualTo("true"); - } - } - } -} diff --git a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/measurefilters/MyFavouritesFilterTest.java b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/measurefilters/MyFavouritesFilterTest.java deleted file mode 100644 index 3c894cdb439..00000000000 --- a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/measurefilters/MyFavouritesFilterTest.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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 this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.plugins.core.measurefilters; - -import org.junit.Test; -import org.sonar.api.web.Filter; -import org.sonar.plugins.core.CorePlugin; - -import static org.assertj.core.api.Assertions.assertThat; - -public class MyFavouritesFilterTest { - @Test - public void should_create_filter() { - MyFavouritesFilter template = new MyFavouritesFilter(); - - Filter filter = template.createFilter(); - - assertThat(template.getName()).isEqualTo("My favourites"); - assertThat(filter).isNotNull(); - assertThat(filter.isFavouritesOnly()).isTrue(); - assertThat(filter.getCriteria()).isEmpty(); - assertThat(filter.getColumns()).hasSize(3); - } - - @Test - public void should_be_registered_as_an_extension() { - assertThat(new CorePlugin().getExtensions()).contains(MyFavouritesFilter.class); - } -} diff --git a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/measurefilters/ProjectFilterTest.java b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/measurefilters/ProjectFilterTest.java deleted file mode 100644 index 9e7a96a5781..00000000000 --- a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/measurefilters/ProjectFilterTest.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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 this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.plugins.core.measurefilters; - -import org.junit.Test; -import org.sonar.api.web.Filter; -import org.sonar.plugins.core.CorePlugin; - -import static org.assertj.core.api.Assertions.assertThat; - -public class ProjectFilterTest { - @Test - public void should_create_filter() { - ProjectFilter template = new ProjectFilter(); - - Filter filter = template.createFilter(); - - assertThat(template.getName()).isEqualTo("Projects"); - assertThat(filter).isNotNull(); - assertThat(filter.getCriteria()).hasSize(1); - assertThat(filter.getColumns()).hasSize(6); - } - - @Test - public void should_be_registered_as_an_extension() { - assertThat(new CorePlugin().getExtensions()).contains(ProjectFilter.class); - } -} diff --git a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/widgets/CoreWidgetsTest.java b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/widgets/CoreWidgetsTest.java deleted file mode 100644 index 0cf8aeb9eb0..00000000000 --- a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/widgets/CoreWidgetsTest.java +++ /dev/null @@ -1,111 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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 this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.plugins.core.widgets; - -import com.google.common.base.Function; -import com.google.common.base.Throwables; -import com.google.common.collect.Collections2; -import com.google.common.collect.Iterables; -import com.google.common.collect.Sets; -import org.junit.Test; -import org.reflections.Reflections; -import org.sonar.plugins.core.CorePlugin; - -import javax.annotation.Nullable; - -import java.util.Collection; -import java.util.Set; - -import static com.google.common.collect.Lists.newArrayList; -import static org.assertj.core.api.Assertions.assertThat; - -public class CoreWidgetsTest { - - @Test - public void widget_ids_should_be_unique() { - Collection widgets = widgets(); - Collection widgetIds = Collections2.transform(widgets, new Function() { - public String apply(@Nullable CoreWidget widget) { - return widget.getId(); - } - }); - assertThat(widgetIds).hasSize(Sets.newHashSet(widgetIds).size()); - } - - @Test - public void widget_templates_should_be_unique() { - Collection widgets = widgets(); - Collection templates = Collections2.transform(widgets, new Function() { - public String apply(@Nullable CoreWidget widget) { - return widget.getTemplatePath(); - } - }); - assertThat(templates).hasSize(Sets.newHashSet(templates).size()); - } - - @Test - public void widget_titles_should_be_unique() { - Collection widgets = widgets(); - Collection templates = Collections2.transform(widgets, new Function() { - public String apply(@Nullable CoreWidget widget) { - return widget.getTitle(); - } - }); - assertThat(templates).hasSize(Sets.newHashSet(templates).size()); - } - - @Test - public void should_find_templates() { - for (CoreWidget widget : widgets()) { - assertThat(widget.getClass().getResource(widget.getTemplatePath())) - .as("Template not found: " + widget.getTemplatePath()) - .isNotNull(); - } - } - - @Test - public void should_be_registered_as_an_extension() { - for (CoreWidget widget : widgets()) { - assertThat(new CorePlugin().getExtensions()).contains(widget.getClass()); - } - } - - @Test - public void should_find_core_widgets() { - assertThat(widgets().size()).isGreaterThan(23); - } - - private Set> widgetClasses() { - String[] packages = {"org.sonar.plugins.core.widgets", "org.sonar.plugins.core.widgets.issues"}; - return new Reflections(packages).getSubTypesOf(CoreWidget.class); - } - - private Collection widgets() { - return newArrayList(Iterables.transform(widgetClasses(), new Function, CoreWidget>() { - public CoreWidget apply(@Nullable Class aClass) { - try { - return aClass.newInstance(); - } catch (Exception e) { - throw Throwables.propagate(e); - } - } - })); - } -} diff --git a/plugins/sonar-core-plugin/src/test/resources/org/sonar/plugins/core/dashboards/ProjectIssuesDashboardTest/filters.xml b/plugins/sonar-core-plugin/src/test/resources/org/sonar/plugins/core/dashboards/ProjectIssuesDashboardTest/filters.xml deleted file mode 100644 index 8ec92ddcdbf..00000000000 --- a/plugins/sonar-core-plugin/src/test/resources/org/sonar/plugins/core/dashboards/ProjectIssuesDashboardTest/filters.xml +++ /dev/null @@ -1,33 +0,0 @@ - - - - - - - - - diff --git a/server/sonar-server/pom.xml b/server/sonar-server/pom.xml index d7eee268b0c..00b38ab5674 100644 --- a/server/sonar-server/pom.xml +++ b/server/sonar-server/pom.xml @@ -1,5 +1,6 @@ - + 4.0.0 org.codehaus.sonar @@ -220,6 +221,11 @@ ${project.version} test
+ + org.reflections + reflections + test + @@ -227,8 +233,17 @@ src/main/resources true + + build.properties + + + + src/main/resources + false + + build.properties + - diff --git a/server/sonar-server/src/main/java/org/sonar/server/charts/DistributionAreaChart.java b/server/sonar-server/src/main/java/org/sonar/server/charts/DistributionAreaChart.java new file mode 100644 index 00000000000..31e02d1df36 --- /dev/null +++ b/server/sonar-server/src/main/java/org/sonar/server/charts/DistributionAreaChart.java @@ -0,0 +1,84 @@ +/* + * SonarQube, open source software quality management tool. + * Copyright (C) 2008-2014 SonarSource + * mailto:contact AT sonarsource DOT com + * + * SonarQube 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. + * + * SonarQube 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 this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.charts; + +import org.apache.commons.lang.StringUtils; +import org.jfree.chart.axis.CategoryAxis; +import org.jfree.chart.axis.NumberAxis; +import org.jfree.chart.plot.CategoryPlot; +import org.jfree.chart.plot.Plot; +import org.jfree.chart.renderer.category.AreaRenderer; +import org.jfree.data.category.DefaultCategoryDataset; +import org.sonar.api.charts.AbstractChart; +import org.sonar.api.charts.ChartParameters; + +import java.text.NumberFormat; + +public class DistributionAreaChart extends AbstractChart { + private static final String PARAM_COLORS = "c"; + + @Override + public String getKey() { + return "distarea"; + } + + @Override + protected Plot getPlot(ChartParameters params) { + DefaultCategoryDataset dataset = createDataset(params); + + CategoryAxis domainAxis = new CategoryAxis(); + domainAxis.setCategoryMargin(0.0); + domainAxis.setLowerMargin(0.0); + domainAxis.setUpperMargin(0.0); + + NumberAxis rangeAxis = new NumberAxis(); + rangeAxis.setNumberFormatOverride(NumberFormat.getIntegerInstance(params.getLocale())); + rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); + + AreaRenderer renderer = new AreaRenderer(); + CategoryPlot plot = new CategoryPlot(dataset, domainAxis, rangeAxis, renderer); + plot.setForegroundAlpha(0.5f); + plot.setDomainGridlinesVisible(true); + configureColors(dataset, plot, params.getValues(PARAM_COLORS, ",")); + return plot; + } + + private DefaultCategoryDataset createDataset(ChartParameters params) { + DefaultCategoryDataset dataset = new DefaultCategoryDataset(); + + String[] series = params.getValues("v", "|", true); + int index = 0; + while (index < series.length) { + String[] pairs = StringUtils.split(series[index], ";"); + if (pairs.length == 0) { + dataset.addValue((Number)0.0, index, "0"); + + } else { + for (String pair : pairs) { + String[] keyValue = StringUtils.split(pair, "="); + double val = Double.parseDouble(keyValue[1]); + dataset.addValue((Number) val, index, keyValue[0]); + } + } + index++; + } + return dataset; + } +} diff --git a/server/sonar-server/src/main/java/org/sonar/server/charts/DistributionBarChart.java b/server/sonar-server/src/main/java/org/sonar/server/charts/DistributionBarChart.java new file mode 100644 index 00000000000..80cfb64d927 --- /dev/null +++ b/server/sonar-server/src/main/java/org/sonar/server/charts/DistributionBarChart.java @@ -0,0 +1,130 @@ +/* + * SonarQube, open source software quality management tool. + * Copyright (C) 2008-2014 SonarSource + * mailto:contact AT sonarsource DOT com + * + * SonarQube 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. + * + * SonarQube 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 this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.charts; + +import org.apache.commons.lang.StringUtils; +import org.jfree.chart.axis.CategoryAxis; +import org.jfree.chart.axis.NumberAxis; +import org.jfree.chart.plot.CategoryPlot; +import org.jfree.chart.plot.Plot; +import org.jfree.chart.renderer.category.BarRenderer; +import org.jfree.data.category.DefaultCategoryDataset; +import org.sonar.api.charts.AbstractChart; +import org.sonar.api.charts.ChartParameters; + +import java.awt.*; +import java.text.DecimalFormat; + +public class DistributionBarChart extends AbstractChart { + + + public static final String PARAM_VALUES = "v"; + public static final String PARAM_COLORS = "c"; + public static final String PARAM_Y_SUFFIX = "ysuf"; + public static final String PARAM_X_SUFFIX = "xsuf"; + public static final String PARAM_FONT_SIZE = "fs"; + + @Override + public String getKey() { + return "distbar"; + } + + @Override + public Plot getPlot(ChartParameters params) { + CategoryPlot plot = generateJFreeChart(params); + plot.setOutlinePaint(OUTLINE_COLOR); + plot.setDomainGridlinePaint(GRID_COLOR); + plot.setRangeGridlinePaint(GRID_COLOR); + return plot; + } + + private CategoryPlot generateJFreeChart(ChartParameters params) { + DefaultCategoryDataset dataset = new DefaultCategoryDataset(); + CategoryPlot plot = new CategoryPlot(); + + Font font = getFont(params.getValue(PARAM_FONT_SIZE)); + configureDomainAxis(plot, font); + configureRangeAxis(plot, params.getValue(PARAM_Y_SUFFIX, "", true), font); + configureRenderer(plot); + configureValues(dataset, params.getValues(PARAM_VALUES, "|", true), params.getValue(PARAM_X_SUFFIX, "", true)); + configureColors(dataset, plot, params.getValues(PARAM_COLORS, ",")); + + plot.setDataset(dataset); + return plot; + } + + static void configureValues(DefaultCategoryDataset dataset, String[] series, String xSuffix) { + int index = 0; + while (index < series.length) { + String[] pairs = StringUtils.split(series[index], ";"); + if (pairs.length == 0) { + dataset.addValue((Number) 0.0, index, "0"); + + } else { + for (String pair : pairs) { + String[] keyValue = StringUtils.split(pair, "="); + double val = Double.parseDouble(keyValue[1]); + dataset.addValue((Number) val, index, keyValue[0] + xSuffix); + } + } + index++; + } + + } + + private void configureRenderer(CategoryPlot plot) { + BarRenderer renderer = new BarRenderer(); + renderer.setDrawBarOutline(true); + renderer.setSeriesItemLabelsVisible(0, true); + renderer.setItemMargin(0); + plot.setRenderer(renderer); + } + + private void configureDomainAxis(CategoryPlot plot, Font font) { + CategoryAxis categoryAxis = new CategoryAxis(); + categoryAxis.setTickMarksVisible(true); + categoryAxis.setTickLabelFont(font); + categoryAxis.setTickLabelPaint(OUTLINE_COLOR); + plot.setDomainAxis(categoryAxis); + plot.setDomainGridlinesVisible(false); + } + + private Font getFont(String fontSize) { + int size = FONT_SIZE; + if (!StringUtils.isBlank(fontSize)) { + size = Integer.parseInt(fontSize); + } + return new Font("SansSerif", Font.PLAIN, size); + } + + private void configureRangeAxis(CategoryPlot plot, String valueLabelSuffix, Font font) { + NumberAxis numberAxis = new NumberAxis(); + numberAxis.setUpperMargin(0.3); + numberAxis.setTickLabelFont(font); + numberAxis.setTickLabelPaint(OUTLINE_COLOR); + String suffix = ""; + if (valueLabelSuffix != null && !"".equals(valueLabelSuffix)) { + suffix = new StringBuilder().append("'").append(valueLabelSuffix).append("'").toString(); + } + numberAxis.setNumberFormatOverride(new DecimalFormat("0" + suffix)); + numberAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); + plot.setRangeAxis(numberAxis); + } +} diff --git a/server/sonar-server/src/main/java/org/sonar/server/dashboard/db/DashboardDao.java b/server/sonar-server/src/main/java/org/sonar/server/dashboard/db/DashboardDao.java index 3869ffb3b87..127aeac10ce 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/dashboard/db/DashboardDao.java +++ b/server/sonar-server/src/main/java/org/sonar/server/dashboard/db/DashboardDao.java @@ -19,14 +19,13 @@ */ package org.sonar.server.dashboard.db; +import javax.annotation.CheckForNull; +import javax.annotation.Nullable; import org.sonar.core.dashboard.DashboardDto; import org.sonar.core.dashboard.DashboardMapper; import org.sonar.core.persistence.DaoComponent; import org.sonar.core.persistence.DbSession; -import javax.annotation.CheckForNull; -import javax.annotation.Nullable; - public class DashboardDao implements DaoComponent { @CheckForNull diff --git a/server/sonar-server/src/main/java/org/sonar/server/dashboard/db/WidgetDao.java b/server/sonar-server/src/main/java/org/sonar/server/dashboard/db/WidgetDao.java index 3b3c6476fbd..5bc77ce1fe3 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/dashboard/db/WidgetDao.java +++ b/server/sonar-server/src/main/java/org/sonar/server/dashboard/db/WidgetDao.java @@ -19,14 +19,13 @@ */ package org.sonar.server.dashboard.db; +import java.util.Collection; import org.sonar.core.dashboard.WidgetDto; import org.sonar.core.dashboard.WidgetMapper; import org.sonar.core.persistence.DaoComponent; import org.sonar.core.persistence.DbSession; import org.sonar.core.persistence.MyBatis; -import java.util.Collection; - public class WidgetDao implements DaoComponent { private MyBatis myBatis; diff --git a/server/sonar-server/src/main/java/org/sonar/server/dashboard/db/WidgetPropertyDao.java b/server/sonar-server/src/main/java/org/sonar/server/dashboard/db/WidgetPropertyDao.java index 46ec46113b8..9ac498ebc24 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/dashboard/db/WidgetPropertyDao.java +++ b/server/sonar-server/src/main/java/org/sonar/server/dashboard/db/WidgetPropertyDao.java @@ -20,6 +20,9 @@ package org.sonar.server.dashboard.db; import com.google.common.base.Function; +import java.util.Arrays; +import java.util.Collection; +import java.util.List; import org.sonar.core.dashboard.WidgetPropertyDto; import org.sonar.core.dashboard.WidgetPropertyMapper; import org.sonar.core.persistence.DaoComponent; @@ -27,10 +30,6 @@ import org.sonar.core.persistence.DaoUtils; import org.sonar.core.persistence.DbSession; import org.sonar.core.persistence.MyBatis; -import java.util.Arrays; -import java.util.Collection; -import java.util.List; - public class WidgetPropertyDao implements DaoComponent { private final MyBatis myBatis; diff --git a/server/sonar-server/src/main/java/org/sonar/server/dashboard/db/package-info.java b/server/sonar-server/src/main/java/org/sonar/server/dashboard/db/package-info.java index ce41e8799be..ab56dedec78 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/dashboard/db/package-info.java +++ b/server/sonar-server/src/main/java/org/sonar/server/dashboard/db/package-info.java @@ -21,3 +21,4 @@ package org.sonar.server.dashboard.db; import javax.annotation.ParametersAreNonnullByDefault; + diff --git a/server/sonar-server/src/main/java/org/sonar/server/dashboard/package-info.java b/server/sonar-server/src/main/java/org/sonar/server/dashboard/package-info.java index 93024b8dc6d..2343d18367d 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/dashboard/package-info.java +++ b/server/sonar-server/src/main/java/org/sonar/server/dashboard/package-info.java @@ -21,3 +21,4 @@ package org.sonar.server.dashboard; import javax.annotation.ParametersAreNonnullByDefault; + diff --git a/server/sonar-server/src/main/java/org/sonar/server/dashboard/template/GlobalDefaultDashboard.java b/server/sonar-server/src/main/java/org/sonar/server/dashboard/template/GlobalDefaultDashboard.java new file mode 100644 index 00000000000..708b45e6f2c --- /dev/null +++ b/server/sonar-server/src/main/java/org/sonar/server/dashboard/template/GlobalDefaultDashboard.java @@ -0,0 +1,93 @@ +/* + * SonarQube, open source software quality management tool. + * Copyright (C) 2008-2014 SonarSource + * mailto:contact AT sonarsource DOT com + * + * SonarQube 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. + * + * SonarQube 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 this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.dashboard.template; + +import org.sonar.api.web.Dashboard; +import org.sonar.api.web.DashboardLayout; +import org.sonar.api.web.DashboardTemplate; +import org.sonar.core.measure.db.MeasureFilterDao; +import org.sonar.core.measure.db.MeasureFilterDto; +import org.sonar.server.dashboard.widget.MeasureFilterAsTreemapWidget; +import org.sonar.server.dashboard.widget.MeasureFilterListWidget; +import org.sonar.server.dashboard.widget.WelcomeWidget; +import org.sonar.server.measure.template.MyFavouritesFilter; +import org.sonar.server.measure.template.ProjectFilter; + +/** + * Projects global dashboard for Sonar + * + * @since 3.1 + */ +public final class GlobalDefaultDashboard extends DashboardTemplate { + + private MeasureFilterDao filterDao; + + public GlobalDefaultDashboard(MeasureFilterDao filterDao) { + this.filterDao = filterDao; + } + + @Override + public Dashboard createDashboard() { + Dashboard dashboard = Dashboard.create() + .setGlobal(true) + .setLayout(DashboardLayout.TWO_COLUMNS); + + dashboard.addWidget(WelcomeWidget.ID, 1); + addMyFavouritesWidget(dashboard); + addProjectsWidgets(dashboard); + + return dashboard; + } + + private void addMyFavouritesWidget(Dashboard dashboard) { + MeasureFilterDto filter = findSystemFilter(MyFavouritesFilter.NAME); + if (filter != null) { + dashboard + .addWidget(MeasureFilterListWidget.ID, 1) + .setProperty(MeasureFilterListWidget.FILTER_PROPERTY, filter.getId().toString()) + .setProperty(MeasureFilterListWidget.PAGE_SIZE_PROPERTY, "50"); + } + } + + private void addProjectsWidgets(Dashboard dashboard) { + MeasureFilterDto filter = findSystemFilter(ProjectFilter.NAME); + if (filter != null) { + dashboard + .addWidget(MeasureFilterListWidget.ID, 2) + .setProperty(MeasureFilterListWidget.FILTER_PROPERTY, filter.getId().toString()) + .setProperty(MeasureFilterListWidget.PAGE_SIZE_PROPERTY, "20"); + + dashboard + .addWidget(MeasureFilterAsTreemapWidget.ID, 2) + .setProperty(MeasureFilterListWidget.FILTER_PROPERTY, filter.getId().toString()) + .setProperty(MeasureFilterAsTreemapWidget.SIZE_METRIC_PROPERTY, "ncloc") + .setProperty(MeasureFilterAsTreemapWidget.COLOR_METRIC_PROPERTY, "coverage"); + } + } + + @Override + public String getName() { + return "Home"; + } + + private MeasureFilterDto findSystemFilter(String name) { + return filterDao.findSystemFilterByName(name); + } +} diff --git a/server/sonar-server/src/main/java/org/sonar/server/dashboard/template/ProjectDefaultDashboard.java b/server/sonar-server/src/main/java/org/sonar/server/dashboard/template/ProjectDefaultDashboard.java new file mode 100644 index 00000000000..7f022ea37a2 --- /dev/null +++ b/server/sonar-server/src/main/java/org/sonar/server/dashboard/template/ProjectDefaultDashboard.java @@ -0,0 +1,62 @@ +/* + * SonarQube, open source software quality management tool. + * Copyright (C) 2008-2014 SonarSource + * mailto:contact AT sonarsource DOT com + * + * SonarQube 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. + * + * SonarQube 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 this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.dashboard.template; + +import org.sonar.api.web.Dashboard; +import org.sonar.api.web.DashboardLayout; +import org.sonar.api.web.DashboardTemplate; + +/** + * Default dashboard + * + * @since 2.13 + */ +public final class ProjectDefaultDashboard extends DashboardTemplate { + + @Override + public String getName() { + return "Dashboard"; + } + + @Override + public Dashboard createDashboard() { + Dashboard dashboard = Dashboard.create(); + dashboard.setLayout(DashboardLayout.TWO_COLUMNS); + addFirstColumn(dashboard); + addSecondColumn(dashboard); + return dashboard; + } + + private void addFirstColumn(Dashboard dashboard) { + dashboard.addWidget("size", 1); + dashboard.addWidget("duplications", 1); + dashboard.addWidget("complexity", 1); + dashboard.addWidget("events", 1); + dashboard.addWidget("description", 1); + } + + private void addSecondColumn(Dashboard dashboard) { + dashboard.addWidget("debt_overview", 2); + dashboard.addWidget("rules", 2); + dashboard.addWidget("alerts", 2); + dashboard.addWidget("code_coverage", 2); + } + +} diff --git a/server/sonar-server/src/main/java/org/sonar/server/dashboard/template/ProjectIssuesDashboard.java b/server/sonar-server/src/main/java/org/sonar/server/dashboard/template/ProjectIssuesDashboard.java new file mode 100644 index 00000000000..405098f7f72 --- /dev/null +++ b/server/sonar-server/src/main/java/org/sonar/server/dashboard/template/ProjectIssuesDashboard.java @@ -0,0 +1,91 @@ +/* + * SonarQube, open source software quality management tool. + * Copyright (C) 2008-2014 SonarSource + * mailto:contact AT sonarsource DOT com + * + * SonarQube 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. + * + * SonarQube 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 this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.dashboard.template; + +import com.google.common.base.Preconditions; +import org.sonar.api.web.Dashboard; +import org.sonar.api.web.DashboardLayout; +import org.sonar.api.web.DashboardTemplate; +import org.sonar.core.issue.db.IssueFilterDao; +import org.sonar.core.issue.db.IssueFilterDto; +import org.sonar.server.dashboard.widget.ProjectIssueFilterWidget; + +/** + * Issues dashboard for Sonar + * + * @since 3.6 + */ +public final class ProjectIssuesDashboard extends DashboardTemplate { + + private final IssueFilterDao issueFilterDao; + + public ProjectIssuesDashboard(IssueFilterDao issueFilterDao) { + this.issueFilterDao = issueFilterDao; + } + + @Override + public String getName() { + return "Issues"; + } + + @Override + public Dashboard createDashboard() { + Dashboard dashboard = Dashboard.create(); + dashboard.setLayout(DashboardLayout.TWO_COLUMNS); + + IssueFilterDto unresolvedIssues = getIssueFilterByName("Unresolved Issues"); + IssueFilterDto hiddenDebt = getIssueFilterByName("False Positive and Won't Fix Issues"); + IssueFilterDto myUnresolvedIssues = getIssueFilterByName("My Unresolved Issues"); + + addFirstColumn(dashboard, unresolvedIssues); + addSecondColumn(dashboard, unresolvedIssues, hiddenDebt, myUnresolvedIssues); + return dashboard; + } + + private IssueFilterDto getIssueFilterByName(String name) { + IssueFilterDto filter = issueFilterDao.selectProvidedFilterByName(name); + Preconditions.checkState(filter != null, String.format("Could not find a provided issue filter with name '%s'", name)); + return filter; + } + + private void addFirstColumn(Dashboard dashboard, IssueFilterDto unresolvedIssues) { + // Unresolved issues by status + dashboard.addWidget(ProjectIssueFilterWidget.ID, 1) + .setProperty(ProjectIssueFilterWidget.FILTER_PROPERTY, Long.toString(unresolvedIssues.getId())) + .setProperty(ProjectIssueFilterWidget.DISTRIBUTION_AXIS_PROPERTY, "statuses"); + // Action plans + dashboard.addWidget("action_plans", 1); + } + + private void addSecondColumn(Dashboard dashboard, IssueFilterDto unresolvedIssues, IssueFilterDto hiddenDebt, IssueFilterDto myUnresolvedIssues) { + // Unresolved issues by assignee + dashboard.addWidget(ProjectIssueFilterWidget.ID, 2) + .setProperty(ProjectIssueFilterWidget.FILTER_PROPERTY, Long.toString(unresolvedIssues.getId())) + .setProperty(ProjectIssueFilterWidget.DISTRIBUTION_AXIS_PROPERTY, "assignees"); + // My unresolved issues + dashboard.addWidget(ProjectIssueFilterWidget.ID, 2) + .setProperty("filter", Long.toString(myUnresolvedIssues.getId())); + // False positive and won't fix issues by resolution + dashboard.addWidget(ProjectIssueFilterWidget.ID, 2) + .setProperty(ProjectIssueFilterWidget.FILTER_PROPERTY, Long.toString(hiddenDebt.getId())) + .setProperty(ProjectIssueFilterWidget.DISTRIBUTION_AXIS_PROPERTY, "resolutions"); + } + +} diff --git a/server/sonar-server/src/main/java/org/sonar/server/dashboard/template/ProjectTimeMachineDashboard.java b/server/sonar-server/src/main/java/org/sonar/server/dashboard/template/ProjectTimeMachineDashboard.java new file mode 100644 index 00000000000..f34b456cb94 --- /dev/null +++ b/server/sonar-server/src/main/java/org/sonar/server/dashboard/template/ProjectTimeMachineDashboard.java @@ -0,0 +1,127 @@ +/* + * SonarQube, open source software quality management tool. + * Copyright (C) 2008-2014 SonarSource + * mailto:contact AT sonarsource DOT com + * + * SonarQube 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. + * + * SonarQube 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 this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.dashboard.template; + +import org.sonar.api.measures.CoreMetrics; +import org.sonar.api.web.Dashboard; +import org.sonar.api.web.Dashboard.Widget; +import org.sonar.api.web.DashboardLayout; +import org.sonar.api.web.DashboardTemplate; + +/** + * Time Machine dashboard + * + * @since 3.0 + */ +public final class ProjectTimeMachineDashboard extends DashboardTemplate { + + private static final String METRIC1 = "metric1"; + private static final String METRIC2 = "metric2"; + private static final String METRIC3 = "metric3"; + private static final String METRIC4 = "metric4"; + private static final String METRIC5 = "metric5"; + private static final String METRIC6 = "metric6"; + private static final String METRIC7 = "metric7"; + private static final String METRIC8 = "metric8"; + + @Override + public String getName() { + return "TimeMachine"; + } + + @Override + public Dashboard createDashboard() { + Dashboard dashboard = Dashboard.create(); + dashboard.setLayout(DashboardLayout.TWO_COLUMNS); + addFirstColumn(dashboard); + addSecondColumn(dashboard); + return dashboard; + } + + private void addFirstColumn(Dashboard dashboard) { + Widget timelineWidget = dashboard.addWidget("timeline", 1); + timelineWidget.setProperty(METRIC1, CoreMetrics.COMPLEXITY_KEY); + timelineWidget.setProperty(METRIC2, CoreMetrics.TECHNICAL_DEBT_KEY); + timelineWidget.setProperty(METRIC3, CoreMetrics.COVERAGE_KEY); + + Widget sizeTimeMachineWidget = addTimeMachineWidgetOnFirstColumn(dashboard); + sizeTimeMachineWidget.setProperty(METRIC1, CoreMetrics.NCLOC_KEY); + sizeTimeMachineWidget.setProperty(METRIC2, CoreMetrics.LINES_KEY); + sizeTimeMachineWidget.setProperty(METRIC3, CoreMetrics.STATEMENTS_KEY); + sizeTimeMachineWidget.setProperty(METRIC4, CoreMetrics.FILES_KEY); + sizeTimeMachineWidget.setProperty(METRIC5, CoreMetrics.CLASSES_KEY); + sizeTimeMachineWidget.setProperty(METRIC6, CoreMetrics.FUNCTIONS_KEY); + sizeTimeMachineWidget.setProperty(METRIC7, CoreMetrics.ACCESSORS_KEY); + + Widget commentsTimeMachineWidget = addTimeMachineWidgetOnFirstColumn(dashboard); + commentsTimeMachineWidget.setProperty(METRIC1, CoreMetrics.COMMENT_LINES_DENSITY_KEY); + commentsTimeMachineWidget.setProperty(METRIC2, CoreMetrics.COMMENT_LINES_KEY); + commentsTimeMachineWidget.setProperty(METRIC3, CoreMetrics.PUBLIC_DOCUMENTED_API_DENSITY_KEY); + commentsTimeMachineWidget.setProperty(METRIC4, CoreMetrics.PUBLIC_UNDOCUMENTED_API_KEY); + + Widget duplicationTimeMachineWidget = addTimeMachineWidgetOnFirstColumn(dashboard); + duplicationTimeMachineWidget.setProperty(METRIC1, CoreMetrics.DUPLICATED_LINES_DENSITY_KEY); + duplicationTimeMachineWidget.setProperty(METRIC2, CoreMetrics.DUPLICATED_LINES_KEY); + duplicationTimeMachineWidget.setProperty(METRIC3, CoreMetrics.DUPLICATED_BLOCKS_KEY); + duplicationTimeMachineWidget.setProperty(METRIC4, CoreMetrics.DUPLICATED_FILES_KEY); + } + + private void addSecondColumn(Dashboard dashboard) { + Widget rulesTimeMachineWidget = addTimeMachineWidgetOnSecondColumn(dashboard); + rulesTimeMachineWidget.setProperty(METRIC1, CoreMetrics.VIOLATIONS_KEY); + rulesTimeMachineWidget.setProperty(METRIC2, CoreMetrics.BLOCKER_VIOLATIONS_KEY); + rulesTimeMachineWidget.setProperty(METRIC3, CoreMetrics.CRITICAL_VIOLATIONS_KEY); + rulesTimeMachineWidget.setProperty(METRIC4, CoreMetrics.MAJOR_VIOLATIONS_KEY); + rulesTimeMachineWidget.setProperty(METRIC5, CoreMetrics.MINOR_VIOLATIONS_KEY); + rulesTimeMachineWidget.setProperty(METRIC6, CoreMetrics.INFO_VIOLATIONS_KEY); + rulesTimeMachineWidget.setProperty(METRIC7, CoreMetrics.TECHNICAL_DEBT_KEY); + + Widget complexityTimeMachineWidget = addTimeMachineWidgetOnSecondColumn(dashboard); + complexityTimeMachineWidget.setProperty(METRIC1, CoreMetrics.COMPLEXITY_KEY); + complexityTimeMachineWidget.setProperty(METRIC2, CoreMetrics.FUNCTION_COMPLEXITY_KEY); + complexityTimeMachineWidget.setProperty(METRIC3, CoreMetrics.CLASS_COMPLEXITY_KEY); + complexityTimeMachineWidget.setProperty(METRIC4, CoreMetrics.FILE_COMPLEXITY_KEY); + + Widget testsTimeMachineWidget = addTimeMachineWidgetOnSecondColumn(dashboard); + testsTimeMachineWidget.setProperty(METRIC1, CoreMetrics.COVERAGE_KEY); + testsTimeMachineWidget.setProperty(METRIC2, CoreMetrics.LINE_COVERAGE_KEY); + testsTimeMachineWidget.setProperty(METRIC3, CoreMetrics.BRANCH_COVERAGE_KEY); + testsTimeMachineWidget.setProperty(METRIC4, CoreMetrics.TEST_SUCCESS_DENSITY_KEY); + testsTimeMachineWidget.setProperty(METRIC5, CoreMetrics.TEST_FAILURES_KEY); + testsTimeMachineWidget.setProperty(METRIC6, CoreMetrics.TEST_ERRORS_KEY); + testsTimeMachineWidget.setProperty(METRIC7, CoreMetrics.TESTS_KEY); + testsTimeMachineWidget.setProperty(METRIC8, CoreMetrics.TEST_EXECUTION_TIME_KEY); + } + + private Widget addTimeMachineWidgetOnFirstColumn(Dashboard dashboard) { + return addTimeMachineWidget(dashboard, 1); + } + + private Widget addTimeMachineWidgetOnSecondColumn(Dashboard dashboard) { + return addTimeMachineWidget(dashboard, 2); + } + + private Widget addTimeMachineWidget(Dashboard dashboard, int columnIndex) { + Widget widget = dashboard.addWidget("time_machine", columnIndex); + widget.setProperty("displaySparkLine", "true"); + return widget; + } + +} diff --git a/server/sonar-server/src/main/java/org/sonar/server/dashboard/template/package-info.java b/server/sonar-server/src/main/java/org/sonar/server/dashboard/template/package-info.java new file mode 100644 index 00000000000..0326d785bd4 --- /dev/null +++ b/server/sonar-server/src/main/java/org/sonar/server/dashboard/template/package-info.java @@ -0,0 +1,24 @@ +/* + * SonarQube, open source software quality management tool. + * Copyright (C) 2008-2014 SonarSource + * mailto:contact AT sonarsource DOT com + * + * SonarQube 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. + * + * SonarQube 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 this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +@ParametersAreNonnullByDefault +package org.sonar.server.dashboard.template; + +import javax.annotation.ParametersAreNonnullByDefault; + diff --git a/server/sonar-server/src/main/java/org/sonar/server/dashboard/widget/ActionPlansWidget.java b/server/sonar-server/src/main/java/org/sonar/server/dashboard/widget/ActionPlansWidget.java new file mode 100644 index 00000000000..cd42eaeaf05 --- /dev/null +++ b/server/sonar-server/src/main/java/org/sonar/server/dashboard/widget/ActionPlansWidget.java @@ -0,0 +1,35 @@ +/* + * SonarQube, open source software quality management tool. + * Copyright (C) 2008-2014 SonarSource + * mailto:contact AT sonarsource DOT com + * + * SonarQube 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. + * + * SonarQube 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 this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.dashboard.widget; + +import org.sonar.api.web.WidgetCategory; +import org.sonar.api.web.WidgetProperties; +import org.sonar.api.web.WidgetProperty; +import org.sonar.api.web.WidgetPropertyType; + +@WidgetCategory({"Issues"}) +@WidgetProperties({ + @WidgetProperty(key = "showResolvedIssues", type = WidgetPropertyType.BOOLEAN, defaultValue = "true") +}) +public class ActionPlansWidget extends CoreWidget { + public ActionPlansWidget() { + super("action_plans", "Issues action plans", "/org/sonar/server/dashboard/widget/action_plans.html.erb"); + } +} diff --git a/server/sonar-server/src/main/java/org/sonar/server/dashboard/widget/AlertsWidget.java b/server/sonar-server/src/main/java/org/sonar/server/dashboard/widget/AlertsWidget.java new file mode 100644 index 00000000000..2394a054de0 --- /dev/null +++ b/server/sonar-server/src/main/java/org/sonar/server/dashboard/widget/AlertsWidget.java @@ -0,0 +1,38 @@ +/* + * SonarQube, open source software quality management tool. + * Copyright (C) 2008-2014 SonarSource + * mailto:contact AT sonarsource DOT com + * + * SonarQube 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. + * + * SonarQube 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 this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.dashboard.widget; + +import org.sonar.api.web.WidgetLayout; +import org.sonar.api.web.WidgetLayoutType; +import org.sonar.api.web.WidgetProperties; +import org.sonar.api.web.WidgetProperty; +import org.sonar.api.web.WidgetPropertyType; + +@WidgetProperties({ + @WidgetProperty(key = "show_ok", type = WidgetPropertyType.BOOLEAN, defaultValue = "false"), +}) +@WidgetLayout(WidgetLayoutType.NONE) +public class AlertsWidget extends CoreWidget { + + public AlertsWidget() { + super("alerts", "Alerts", "/org/sonar/server/dashboard/widget/alerts.html.erb"); + } + +} diff --git a/server/sonar-server/src/main/java/org/sonar/server/dashboard/widget/BubbleChartWidget.java b/server/sonar-server/src/main/java/org/sonar/server/dashboard/widget/BubbleChartWidget.java new file mode 100644 index 00000000000..dbab080abe0 --- /dev/null +++ b/server/sonar-server/src/main/java/org/sonar/server/dashboard/widget/BubbleChartWidget.java @@ -0,0 +1,40 @@ +/* + * SonarQube, open source software quality management tool. + * Copyright (C) 2008-2014 SonarSource + * mailto:contact AT sonarsource DOT com + * + * SonarQube 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. + * + * SonarQube 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 this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.dashboard.widget; + +import org.sonar.api.measures.CoreMetrics; +import org.sonar.api.web.WidgetProperties; +import org.sonar.api.web.WidgetProperty; +import org.sonar.api.web.WidgetPropertyType; + +@WidgetProperties({ + @WidgetProperty(key = "chartTitle", type = WidgetPropertyType.STRING), + @WidgetProperty(key = "chartHeight", type = WidgetPropertyType.INTEGER, defaultValue = "300"), + @WidgetProperty(key = "xMetric", type = WidgetPropertyType.METRIC, defaultValue = CoreMetrics.NCLOC_KEY, options = {WidgetConstants.FILTER_OUT_NEW_METRICS}), + @WidgetProperty(key = "yMetric", type = WidgetPropertyType.METRIC, defaultValue = CoreMetrics.VIOLATIONS_KEY, options = {WidgetConstants.FILTER_OUT_NEW_METRICS}), + @WidgetProperty(key = "sizeMetric", type = WidgetPropertyType.METRIC, defaultValue = CoreMetrics.TECHNICAL_DEBT_KEY, options = {WidgetConstants.FILTER_OUT_NEW_METRICS}), + @WidgetProperty(key = "xLogarithmic", type = WidgetPropertyType.BOOLEAN), + @WidgetProperty(key = "yLogarithmic", type = WidgetPropertyType.BOOLEAN) +}) +public class BubbleChartWidget extends CoreWidget { + public BubbleChartWidget() { + super("bubble_chart", "Project File Bubble Chart", "/org/sonar/server/dashboard/widget/bubbleChart.html.erb"); + } +} diff --git a/server/sonar-server/src/main/java/org/sonar/server/dashboard/widget/ComplexityWidget.java b/server/sonar-server/src/main/java/org/sonar/server/dashboard/widget/ComplexityWidget.java new file mode 100644 index 00000000000..84c51bf828a --- /dev/null +++ b/server/sonar-server/src/main/java/org/sonar/server/dashboard/widget/ComplexityWidget.java @@ -0,0 +1,27 @@ +/* + * SonarQube, open source software quality management tool. + * Copyright (C) 2008-2014 SonarSource + * mailto:contact AT sonarsource DOT com + * + * SonarQube 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. + * + * SonarQube 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 this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.dashboard.widget; + +public class ComplexityWidget extends CoreWidget { + + public ComplexityWidget() { + super("complexity", "Complexity", "/org/sonar/server/dashboard/widget/complexity.html.erb"); + } +} diff --git a/server/sonar-server/src/main/java/org/sonar/server/dashboard/widget/CoreWidget.java b/server/sonar-server/src/main/java/org/sonar/server/dashboard/widget/CoreWidget.java new file mode 100644 index 00000000000..7db3f4775c9 --- /dev/null +++ b/server/sonar-server/src/main/java/org/sonar/server/dashboard/widget/CoreWidget.java @@ -0,0 +1,48 @@ +/* + * SonarQube, open source software quality management tool. + * Copyright (C) 2008-2014 SonarSource + * mailto:contact AT sonarsource DOT com + * + * SonarQube 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. + * + * SonarQube 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 this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.dashboard.widget; + +import org.sonar.api.web.AbstractRubyTemplate; +import org.sonar.api.web.RubyRailsWidget; + +public abstract class CoreWidget extends AbstractRubyTemplate implements RubyRailsWidget { + private String id, title, templatePath; + + protected CoreWidget(String id, String title, String templatePath) { + this.id = id; + this.title = title; + this.templatePath = templatePath; + } + + @Override + public String getId() { + return id; + } + + @Override + public String getTitle() { + return title; + } + + @Override + protected String getTemplatePath() { + return templatePath; + } +} diff --git a/server/sonar-server/src/main/java/org/sonar/server/dashboard/widget/CoverageWidget.java b/server/sonar-server/src/main/java/org/sonar/server/dashboard/widget/CoverageWidget.java new file mode 100644 index 00000000000..951f96e467d --- /dev/null +++ b/server/sonar-server/src/main/java/org/sonar/server/dashboard/widget/CoverageWidget.java @@ -0,0 +1,32 @@ +/* + * SonarQube, open source software quality management tool. + * Copyright (C) 2008-2014 SonarSource + * mailto:contact AT sonarsource DOT com + * + * SonarQube 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. + * + * SonarQube 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 this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.dashboard.widget; + +import org.sonar.api.web.UserRole; +import org.sonar.api.web.WidgetCategory; + +@WidgetCategory("Tests") +@UserRole(UserRole.USER) +public class CoverageWidget extends CoreWidget { + + public CoverageWidget() { + super("code_coverage", "Code coverage", "/org/sonar/server/dashboard/widget/coverage.html.erb"); + } +} diff --git a/server/sonar-server/src/main/java/org/sonar/server/dashboard/widget/CustomMeasuresWidget.java b/server/sonar-server/src/main/java/org/sonar/server/dashboard/widget/CustomMeasuresWidget.java new file mode 100644 index 00000000000..9ab2e89ec27 --- /dev/null +++ b/server/sonar-server/src/main/java/org/sonar/server/dashboard/widget/CustomMeasuresWidget.java @@ -0,0 +1,42 @@ +/* + * SonarQube, open source software quality management tool. + * Copyright (C) 2008-2014 SonarSource + * mailto:contact AT sonarsource DOT com + * + * SonarQube 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. + * + * SonarQube 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 this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.dashboard.widget; + +import org.sonar.api.web.WidgetProperties; +import org.sonar.api.web.WidgetProperty; +import org.sonar.api.web.WidgetPropertyType; + +@WidgetProperties({ + @WidgetProperty(key = "metric1", type = WidgetPropertyType.METRIC), + @WidgetProperty(key = "metric2", type = WidgetPropertyType.METRIC), + @WidgetProperty(key = "metric3", type = WidgetPropertyType.METRIC), + @WidgetProperty(key = "metric4", type = WidgetPropertyType.METRIC), + @WidgetProperty(key = "metric5", type = WidgetPropertyType.METRIC), + @WidgetProperty(key = "metric6", type = WidgetPropertyType.METRIC), + @WidgetProperty(key = "metric7", type = WidgetPropertyType.METRIC), + @WidgetProperty(key = "metric8", type = WidgetPropertyType.METRIC), + @WidgetProperty(key = "metric9", type = WidgetPropertyType.METRIC), + @WidgetProperty(key = "metric10", type = WidgetPropertyType.METRIC) +}) +public class CustomMeasuresWidget extends CoreWidget { + public CustomMeasuresWidget() { + super("custom_measures", "Custom Measures", "/org/sonar/server/dashboard/widget/custom_measures.html.erb"); + } +} diff --git a/server/sonar-server/src/main/java/org/sonar/server/dashboard/widget/DebtOverviewWidget.java b/server/sonar-server/src/main/java/org/sonar/server/dashboard/widget/DebtOverviewWidget.java new file mode 100644 index 00000000000..ea7ff617af9 --- /dev/null +++ b/server/sonar-server/src/main/java/org/sonar/server/dashboard/widget/DebtOverviewWidget.java @@ -0,0 +1,33 @@ +/* + * SonarQube, open source software quality management tool. + * Copyright (C) 2008-2014 SonarSource + * mailto:contact AT sonarsource DOT com + * + * SonarQube 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. + * + * SonarQube 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 this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +package org.sonar.server.dashboard.widget; + +import org.sonar.api.web.UserRole; +import org.sonar.api.web.WidgetCategory; + +@UserRole(UserRole.USER) +@WidgetCategory("Technical Debt") +public final class DebtOverviewWidget extends CoreWidget { + + public DebtOverviewWidget() { + super("debt_overview", "Technical Debt Overview", "/org/sonar/server/dashboard/widget/debt_overview.erb"); + } +} diff --git a/server/sonar-server/src/main/java/org/sonar/server/dashboard/widget/DescriptionWidget.java b/server/sonar-server/src/main/java/org/sonar/server/dashboard/widget/DescriptionWidget.java new file mode 100644 index 00000000000..4f9689582cf --- /dev/null +++ b/server/sonar-server/src/main/java/org/sonar/server/dashboard/widget/DescriptionWidget.java @@ -0,0 +1,31 @@ +/* + * SonarQube, open source software quality management tool. + * Copyright (C) 2008-2014 SonarSource + * mailto:contact AT sonarsource DOT com + * + * SonarQube 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. + * + * SonarQube 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 this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.dashboard.widget; + +import org.sonar.api.web.WidgetLayout; +import org.sonar.api.web.WidgetLayoutType; + +@WidgetLayout(WidgetLayoutType.NONE) +public class DescriptionWidget extends CoreWidget { + + public DescriptionWidget() { + super("description", "Description", "/org/sonar/server/dashboard/widget/description.html.erb"); + } +} diff --git a/server/sonar-server/src/main/java/org/sonar/server/dashboard/widget/DocumentationCommentsWidget.java b/server/sonar-server/src/main/java/org/sonar/server/dashboard/widget/DocumentationCommentsWidget.java new file mode 100644 index 00000000000..40d71e2c43c --- /dev/null +++ b/server/sonar-server/src/main/java/org/sonar/server/dashboard/widget/DocumentationCommentsWidget.java @@ -0,0 +1,28 @@ +/* + * SonarQube, open source software quality management tool. + * Copyright (C) 2008-2014 SonarSource + * mailto:contact AT sonarsource DOT com + * + * SonarQube 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. + * + * SonarQube 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 this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.dashboard.widget; + +public class DocumentationCommentsWidget extends CoreWidget { + + public DocumentationCommentsWidget() { + super("documentation_comments", "Documentation Metrics", "/org/sonar/server/dashboard/widget/documentation_comments_widget.html.erb"); + } + +} diff --git a/server/sonar-server/src/main/java/org/sonar/server/dashboard/widget/DuplicationsWidget.java b/server/sonar-server/src/main/java/org/sonar/server/dashboard/widget/DuplicationsWidget.java new file mode 100644 index 00000000000..de161b8e3cf --- /dev/null +++ b/server/sonar-server/src/main/java/org/sonar/server/dashboard/widget/DuplicationsWidget.java @@ -0,0 +1,32 @@ +/* + * SonarQube, open source software quality management tool. + * Copyright (C) 2008-2014 SonarSource + * mailto:contact AT sonarsource DOT com + * + * SonarQube 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. + * + * SonarQube 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 this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.dashboard.widget; + +/** + * @author Patroklos PAPAPETROU + */ + +public class DuplicationsWidget extends CoreWidget { + + public DuplicationsWidget() { + super("duplications", "Duplications", "/org/sonar/server/dashboard/widget/duplications_widget.html.erb"); + } + +} diff --git a/server/sonar-server/src/main/java/org/sonar/server/dashboard/widget/EventsWidget.java b/server/sonar-server/src/main/java/org/sonar/server/dashboard/widget/EventsWidget.java new file mode 100644 index 00000000000..c9a8b398a80 --- /dev/null +++ b/server/sonar-server/src/main/java/org/sonar/server/dashboard/widget/EventsWidget.java @@ -0,0 +1,27 @@ +/* + * SonarQube, open source software quality management tool. + * Copyright (C) 2008-2014 SonarSource + * mailto:contact AT sonarsource DOT com + * + * SonarQube 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. + * + * SonarQube 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 this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.dashboard.widget; + +public class EventsWidget extends CoreWidget { + + public EventsWidget() { + super("events", "Events", "/org/sonar/server/dashboard/widget/events.html.erb"); + } +} diff --git a/server/sonar-server/src/main/java/org/sonar/server/dashboard/widget/HotspotMetricWidget.java b/server/sonar-server/src/main/java/org/sonar/server/dashboard/widget/HotspotMetricWidget.java new file mode 100644 index 00000000000..a13cb4d4a7d --- /dev/null +++ b/server/sonar-server/src/main/java/org/sonar/server/dashboard/widget/HotspotMetricWidget.java @@ -0,0 +1,37 @@ +/* + * SonarQube, open source software quality management tool. + * Copyright (C) 2008-2014 SonarSource + * mailto:contact AT sonarsource DOT com + * + * SonarQube 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. + * + * SonarQube 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 this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.dashboard.widget; + +import org.sonar.api.web.WidgetCategory; +import org.sonar.api.web.WidgetProperties; +import org.sonar.api.web.WidgetProperty; +import org.sonar.api.web.WidgetPropertyType; + +@WidgetCategory({"Hotspots"}) +@WidgetProperties({ + @WidgetProperty(key = "title", type = WidgetPropertyType.STRING), + @WidgetProperty(key = "metric", type = WidgetPropertyType.METRIC, defaultValue = "ncloc", options = {WidgetConstants.FILTER_OUT_NEW_METRICS}), + @WidgetProperty(key = "numberOfLines", type = WidgetPropertyType.INTEGER, defaultValue = "5") +}) +public class HotspotMetricWidget extends CoreWidget { + public HotspotMetricWidget() { + super("hotspot_metric", "Metric hotspot", "/org/sonar/server/dashboard/widget/hotspot_metric.html.erb"); + } +} diff --git a/server/sonar-server/src/main/java/org/sonar/server/dashboard/widget/IssueFilterWidget.java b/server/sonar-server/src/main/java/org/sonar/server/dashboard/widget/IssueFilterWidget.java new file mode 100644 index 00000000000..d3bc92a44a5 --- /dev/null +++ b/server/sonar-server/src/main/java/org/sonar/server/dashboard/widget/IssueFilterWidget.java @@ -0,0 +1,49 @@ +/* + * SonarQube, open source software quality management tool. + * Copyright (C) 2008-2014 SonarSource + * mailto:contact AT sonarsource DOT com + * + * SonarQube 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. + * + * SonarQube 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 this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.dashboard.widget; + +import org.sonar.api.web.WidgetCategory; +import org.sonar.api.web.WidgetProperties; +import org.sonar.api.web.WidgetProperty; +import org.sonar.api.web.WidgetPropertyType; +import org.sonar.api.web.WidgetScope; + +import static org.sonar.api.web.WidgetScope.GLOBAL; + +@WidgetCategory({"Filters", "Issues"}) +@WidgetScope(GLOBAL) +@WidgetProperties({ + @WidgetProperty(key = IssueFilterWidget.FILTER_PROPERTY, type = WidgetPropertyType.ISSUE_FILTER, optional = false), + @WidgetProperty(key = IssueFilterWidget.DISTRIBUTION_AXIS_PROPERTY, type = WidgetPropertyType.SINGLE_SELECT_LIST, defaultValue = "severities", + options = {"severities", "resolutions", "statuses", "rules", "tags", "projectUuids", "assignees", "reporters", + "authors", "languages", "actionPlans", "createdAt"}), + @WidgetProperty(key = IssueFilterWidget.DISPLAY_FILTER_DESCRIPTION, type = WidgetPropertyType.BOOLEAN, defaultValue = "false") +}) +public class IssueFilterWidget extends CoreWidget { + + public static final String FILTER_PROPERTY = "filter"; + public static final String DISTRIBUTION_AXIS_PROPERTY = "distributionAxis"; + public static final String DISPLAY_FILTER_DESCRIPTION = "displayFilterDescription"; + public static final String ID = "issue_filter"; + + public IssueFilterWidget() { + super(ID, "Issue Filter", "/org/sonar/server/dashboard/widget/issue_filter.html.erb"); + } +} diff --git a/server/sonar-server/src/main/java/org/sonar/server/dashboard/widget/IssueTagCloudWidget.java b/server/sonar-server/src/main/java/org/sonar/server/dashboard/widget/IssueTagCloudWidget.java new file mode 100644 index 00000000000..60fde54c082 --- /dev/null +++ b/server/sonar-server/src/main/java/org/sonar/server/dashboard/widget/IssueTagCloudWidget.java @@ -0,0 +1,41 @@ +/* + * SonarQube, open source software quality management tool. + * Copyright (C) 2008-2014 SonarSource + * mailto:contact AT sonarsource DOT com + * + * SonarQube 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. + * + * SonarQube 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 this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.dashboard.widget; + +import org.sonar.api.web.WidgetCategory; +import org.sonar.api.web.WidgetProperties; +import org.sonar.api.web.WidgetProperty; +import org.sonar.api.web.WidgetPropertyType; +import org.sonar.api.web.WidgetScope; + +import static org.sonar.api.web.WidgetScope.PROJECT; + +@WidgetCategory({"Issues"}) +@WidgetScope(PROJECT) +@WidgetProperties({ + @WidgetProperty(key = "maxItems", type = WidgetPropertyType.INTEGER, defaultValue = "100") +}) +public class IssueTagCloudWidget extends CoreWidget { + + public IssueTagCloudWidget() { + super("issue_tag_cloud", "Issue Tag Cloud", "/org/sonar/server/dashboard/widget/issue_tag_cloud.html.erb"); + } + +} diff --git a/server/sonar-server/src/main/java/org/sonar/server/dashboard/widget/IssuesWidget.java b/server/sonar-server/src/main/java/org/sonar/server/dashboard/widget/IssuesWidget.java new file mode 100644 index 00000000000..9b035643f27 --- /dev/null +++ b/server/sonar-server/src/main/java/org/sonar/server/dashboard/widget/IssuesWidget.java @@ -0,0 +1,30 @@ +/* + * SonarQube, open source software quality management tool. + * Copyright (C) 2008-2014 SonarSource + * mailto:contact AT sonarsource DOT com + * + * SonarQube 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. + * + * SonarQube 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 this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.dashboard.widget; + +import org.sonar.api.web.WidgetCategory; + +@WidgetCategory({"Issues", "Technical Debt"}) +public class IssuesWidget extends CoreWidget { + + public IssuesWidget() { + super("rules", "Issues and Technical Debt", "/org/sonar/server/dashboard/widget/issues.html.erb"); + } +} diff --git a/server/sonar-server/src/main/java/org/sonar/server/dashboard/widget/ItCoverageWidget.java b/server/sonar-server/src/main/java/org/sonar/server/dashboard/widget/ItCoverageWidget.java new file mode 100644 index 00000000000..cb3b0eea262 --- /dev/null +++ b/server/sonar-server/src/main/java/org/sonar/server/dashboard/widget/ItCoverageWidget.java @@ -0,0 +1,32 @@ +/* + * SonarQube, open source software quality management tool. + * Copyright (C) 2008-2014 SonarSource + * mailto:contact AT sonarsource DOT com + * + * SonarQube 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. + * + * SonarQube 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 this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.dashboard.widget; + +import org.sonar.api.web.UserRole; +import org.sonar.api.web.WidgetCategory; + +@WidgetCategory("Tests") +@UserRole(UserRole.USER) +public class ItCoverageWidget extends CoreWidget { + + public ItCoverageWidget() { + super("it-coverage", "Integration Test Coverage", "/org/sonar/server/dashboard/widget/it_coverage.html.erb"); + } +} diff --git a/server/sonar-server/src/main/java/org/sonar/server/dashboard/widget/MeasureFilterAsBubbleChartWidget.java b/server/sonar-server/src/main/java/org/sonar/server/dashboard/widget/MeasureFilterAsBubbleChartWidget.java new file mode 100644 index 00000000000..9d8f1cee819 --- /dev/null +++ b/server/sonar-server/src/main/java/org/sonar/server/dashboard/widget/MeasureFilterAsBubbleChartWidget.java @@ -0,0 +1,50 @@ +/* + * SonarQube, open source software quality management tool. + * Copyright (C) 2008-2014 SonarSource + * mailto:contact AT sonarsource DOT com + * + * SonarQube 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. + * + * SonarQube 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 this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.dashboard.widget; + +import org.sonar.api.measures.CoreMetrics; +import org.sonar.api.web.WidgetCategory; +import org.sonar.api.web.WidgetProperties; +import org.sonar.api.web.WidgetProperty; +import org.sonar.api.web.WidgetPropertyType; +import org.sonar.api.web.WidgetScope; + +import static org.sonar.api.web.WidgetScope.GLOBAL; + +@WidgetCategory({"Filters"}) +@WidgetScope(GLOBAL) +@WidgetProperties({ + @WidgetProperty(key = "chartTitle", type = WidgetPropertyType.STRING), + @WidgetProperty(key = "chartHeight", type = WidgetPropertyType.INTEGER, defaultValue = "300"), + @WidgetProperty(key = "filter", type = WidgetPropertyType.FILTER, optional = false), + @WidgetProperty(key = "xMetric", type = WidgetPropertyType.METRIC, defaultValue = CoreMetrics.NCLOC_KEY, options = {WidgetConstants.FILTER_OUT_NEW_METRICS}), + @WidgetProperty(key = "yMetric", type = WidgetPropertyType.METRIC, defaultValue = CoreMetrics.VIOLATIONS_KEY, options = {WidgetConstants.FILTER_OUT_NEW_METRICS}), + @WidgetProperty(key = "sizeMetric", type = WidgetPropertyType.METRIC, defaultValue = CoreMetrics.TECHNICAL_DEBT_KEY, options = {WidgetConstants.FILTER_OUT_NEW_METRICS}), + @WidgetProperty(key = "xLogarithmic", type = WidgetPropertyType.BOOLEAN), + @WidgetProperty(key = "yLogarithmic", type = WidgetPropertyType.BOOLEAN), + @WidgetProperty(key = "maxItems", type = WidgetPropertyType.INTEGER) +}) +public class MeasureFilterAsBubbleChartWidget extends CoreWidget { + + public MeasureFilterAsBubbleChartWidget() { + super("measure_filter_bubble_chart", "Measure Filter as Bubble Chart", "/org/sonar/server/dashboard/widget/measure_filter_bubble_chart.html.erb"); + } + +} diff --git a/server/sonar-server/src/main/java/org/sonar/server/dashboard/widget/MeasureFilterAsCloudWidget.java b/server/sonar-server/src/main/java/org/sonar/server/dashboard/widget/MeasureFilterAsCloudWidget.java new file mode 100644 index 00000000000..c148c4a5bb1 --- /dev/null +++ b/server/sonar-server/src/main/java/org/sonar/server/dashboard/widget/MeasureFilterAsCloudWidget.java @@ -0,0 +1,47 @@ +/* + * SonarQube, open source software quality management tool. + * Copyright (C) 2008-2014 SonarSource + * mailto:contact AT sonarsource DOT com + * + * SonarQube 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. + * + * SonarQube 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 this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.dashboard.widget; + +import org.sonar.api.measures.CoreMetrics; +import org.sonar.api.web.WidgetCategory; +import org.sonar.api.web.WidgetProperties; +import org.sonar.api.web.WidgetProperty; +import org.sonar.api.web.WidgetPropertyType; +import org.sonar.api.web.WidgetScope; + +import static org.sonar.api.web.WidgetScope.GLOBAL; + +@WidgetCategory({"Filters"}) +@WidgetScope(GLOBAL) +@WidgetProperties({ + @WidgetProperty(key = "filter", type = WidgetPropertyType.FILTER, optional = false), + @WidgetProperty(key = "chartTitle", type = WidgetPropertyType.STRING), + @WidgetProperty(key = "sizeMetric", type = WidgetPropertyType.METRIC, defaultValue = CoreMetrics.COMPLEXITY_KEY, options = {WidgetConstants.FILTER_OUT_NEW_METRICS}), + @WidgetProperty(key = "colorMetric", type = WidgetPropertyType.METRIC, defaultValue = CoreMetrics.COVERAGE_KEY, + options = {WidgetConstants.FILTER_OUT_NEW_METRICS, "type:PERCENT"}), + @WidgetProperty(key = "maxItems", type = WidgetPropertyType.INTEGER, defaultValue = "100") +}) +public class MeasureFilterAsCloudWidget extends CoreWidget { + + public MeasureFilterAsCloudWidget() { + super("measure_filter_cloud", "Measure Filter as Cloud", "/org/sonar/server/dashboard/widget/measure_filter_cloud.html.erb"); + } + +} diff --git a/server/sonar-server/src/main/java/org/sonar/server/dashboard/widget/MeasureFilterAsHistogramWidget.java b/server/sonar-server/src/main/java/org/sonar/server/dashboard/widget/MeasureFilterAsHistogramWidget.java new file mode 100644 index 00000000000..6341a1e2ed6 --- /dev/null +++ b/server/sonar-server/src/main/java/org/sonar/server/dashboard/widget/MeasureFilterAsHistogramWidget.java @@ -0,0 +1,47 @@ +/* + * SonarQube, open source software quality management tool. + * Copyright (C) 2008-2014 SonarSource + * mailto:contact AT sonarsource DOT com + * + * SonarQube 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. + * + * SonarQube 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 this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.dashboard.widget; + +import org.sonar.api.measures.CoreMetrics; +import org.sonar.api.web.WidgetCategory; +import org.sonar.api.web.WidgetProperties; +import org.sonar.api.web.WidgetProperty; +import org.sonar.api.web.WidgetPropertyType; +import org.sonar.api.web.WidgetScope; + +import static org.sonar.api.web.WidgetScope.GLOBAL; + +@WidgetCategory({"Filters"}) +@WidgetScope(GLOBAL) +@WidgetProperties({ + @WidgetProperty(key = "chartTitle", type = WidgetPropertyType.STRING), + @WidgetProperty(key = "filter", type = WidgetPropertyType.FILTER, optional = false), + @WidgetProperty(key = "metric", type = WidgetPropertyType.METRIC, defaultValue = CoreMetrics.TECHNICAL_DEBT_KEY, options = {WidgetConstants.FILTER_OUT_NEW_METRICS}), + @WidgetProperty(key = "maxItems", type = WidgetPropertyType.INTEGER, defaultValue = "40"), + @WidgetProperty(key = "reverseOrder", type = WidgetPropertyType.BOOLEAN, defaultValue = "false"), + @WidgetProperty(key = "relativeScale", type = WidgetPropertyType.BOOLEAN, defaultValue = "false") +}) +public class MeasureFilterAsHistogramWidget extends CoreWidget { + + public MeasureFilterAsHistogramWidget() { + super("measure_filter_histogram", "Measure Filter as Histogram", "/org/sonar/server/dashboard/widget/measure_filter_histogram.html.erb"); + } + +} diff --git a/server/sonar-server/src/main/java/org/sonar/server/dashboard/widget/MeasureFilterAsPieChartWidget.java b/server/sonar-server/src/main/java/org/sonar/server/dashboard/widget/MeasureFilterAsPieChartWidget.java new file mode 100644 index 00000000000..c32565f3e3b --- /dev/null +++ b/server/sonar-server/src/main/java/org/sonar/server/dashboard/widget/MeasureFilterAsPieChartWidget.java @@ -0,0 +1,48 @@ +/* + * SonarQube, open source software quality management tool. + * Copyright (C) 2008-2014 SonarSource + * mailto:contact AT sonarsource DOT com + * + * SonarQube 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. + * + * SonarQube 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 this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.dashboard.widget; + +import org.sonar.api.measures.CoreMetrics; +import org.sonar.api.web.WidgetCategory; +import org.sonar.api.web.WidgetProperties; +import org.sonar.api.web.WidgetProperty; +import org.sonar.api.web.WidgetPropertyType; +import org.sonar.api.web.WidgetScope; + +import static org.sonar.api.web.WidgetScope.GLOBAL; + +@WidgetCategory({"Filters"}) +@WidgetScope(GLOBAL) +@WidgetProperties({ + @WidgetProperty(key = "chartTitle", type = WidgetPropertyType.STRING), + @WidgetProperty(key = "chartHeight", type = WidgetPropertyType.INTEGER, defaultValue = "300"), + @WidgetProperty(key = "filter", type = WidgetPropertyType.FILTER, optional = false), + @WidgetProperty(key = "mainMetric", type = WidgetPropertyType.METRIC, defaultValue = CoreMetrics.TECHNICAL_DEBT_KEY, options = {WidgetConstants.FILTER_OUT_NEW_METRICS}), + @WidgetProperty(key = "extraMetric1", type = WidgetPropertyType.METRIC, defaultValue = CoreMetrics.NCLOC_KEY, options = {WidgetConstants.FILTER_OUT_NEW_METRICS}), + @WidgetProperty(key = "extraMetric2", type = WidgetPropertyType.METRIC, options = {WidgetConstants.FILTER_OUT_NEW_METRICS}), + @WidgetProperty(key = "maxItems", type = WidgetPropertyType.INTEGER, defaultValue = "20") +}) +public class MeasureFilterAsPieChartWidget extends CoreWidget { + + public MeasureFilterAsPieChartWidget() { + super("measure_filter_pie_chart", "Measure Filter as Donut Chart", "/org/sonar/server/dashboard/widget/measure_filter_pie_chart.html.erb"); + } + +} diff --git a/server/sonar-server/src/main/java/org/sonar/server/dashboard/widget/MeasureFilterAsTreemapWidget.java b/server/sonar-server/src/main/java/org/sonar/server/dashboard/widget/MeasureFilterAsTreemapWidget.java new file mode 100644 index 00000000000..3eb4c9f5895 --- /dev/null +++ b/server/sonar-server/src/main/java/org/sonar/server/dashboard/widget/MeasureFilterAsTreemapWidget.java @@ -0,0 +1,59 @@ +/* + * SonarQube, open source software quality management tool. + * Copyright (C) 2008-2014 SonarSource + * mailto:contact AT sonarsource DOT com + * + * SonarQube 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. + * + * SonarQube 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 this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.dashboard.widget; + +import org.sonar.api.measures.CoreMetrics; +import org.sonar.api.web.WidgetCategory; +import org.sonar.api.web.WidgetProperties; +import org.sonar.api.web.WidgetProperty; +import org.sonar.api.web.WidgetPropertyType; +import org.sonar.api.web.WidgetScope; + +import static org.sonar.api.web.WidgetScope.GLOBAL; + +@WidgetCategory({"Filters"}) +@WidgetScope(GLOBAL) +@WidgetProperties({ + @WidgetProperty(key = MeasureFilterAsTreemapWidget.FILTER_PROPERTY, type = WidgetPropertyType.FILTER, + optional = false), + @WidgetProperty(key = MeasureFilterAsTreemapWidget.CHART_TITLE_PROPERTY, type = WidgetPropertyType.STRING), + @WidgetProperty(key = MeasureFilterAsTreemapWidget.SIZE_METRIC_PROPERTY, type = WidgetPropertyType.METRIC, + defaultValue = CoreMetrics.NCLOC_KEY, options = {WidgetConstants.FILTER_OUT_NEW_METRICS}), + @WidgetProperty(key = MeasureFilterAsTreemapWidget.COLOR_METRIC_PROPERTY, type = WidgetPropertyType.METRIC, + defaultValue = CoreMetrics.COVERAGE_KEY, + options = {WidgetConstants.FILTER_OUT_NEW_METRICS, "type:PERCENT,RATING,LEVEL"}), + @WidgetProperty(key = MeasureFilterAsTreemapWidget.HEIGHT_PERCENTS_PROPERTY, type = WidgetPropertyType.INTEGER, + optional = true, defaultValue = "55", description = "Height in percents of width"), + @WidgetProperty(key = MeasureFilterAsTreemapWidget.MAX_ITEMS_PROPERTY, type = WidgetPropertyType.INTEGER, + defaultValue = "30") +}) +public class MeasureFilterAsTreemapWidget extends CoreWidget { + public static final String FILTER_PROPERTY = "filter"; + public static final String SIZE_METRIC_PROPERTY = "sizeMetric"; + public static final String COLOR_METRIC_PROPERTY = "colorMetric"; + public static final String HEIGHT_PERCENTS_PROPERTY = "heightInPercents"; + public static final String CHART_TITLE_PROPERTY = "chartTitle"; + public static final String MAX_ITEMS_PROPERTY = "maxItems"; + public static final String ID = "measure_filter_treemap"; + + public MeasureFilterAsTreemapWidget() { + super(ID, "Measure Filter as Treemap", "/org/sonar/server/dashboard/widget/measure_filter_treemap.html.erb"); + } +} diff --git a/server/sonar-server/src/main/java/org/sonar/server/dashboard/widget/MeasureFilterListWidget.java b/server/sonar-server/src/main/java/org/sonar/server/dashboard/widget/MeasureFilterListWidget.java new file mode 100644 index 00000000000..24d4a1831e0 --- /dev/null +++ b/server/sonar-server/src/main/java/org/sonar/server/dashboard/widget/MeasureFilterListWidget.java @@ -0,0 +1,46 @@ +/* + * SonarQube, open source software quality management tool. + * Copyright (C) 2008-2014 SonarSource + * mailto:contact AT sonarsource DOT com + * + * SonarQube 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. + * + * SonarQube 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 this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.dashboard.widget; + +import org.sonar.api.web.WidgetCategory; +import org.sonar.api.web.WidgetProperties; +import org.sonar.api.web.WidgetProperty; +import org.sonar.api.web.WidgetPropertyType; +import org.sonar.api.web.WidgetScope; + +import static org.sonar.api.web.WidgetScope.GLOBAL; + +@WidgetCategory({"Filters"}) +@WidgetScope(GLOBAL) +@WidgetProperties({ + @WidgetProperty(key = MeasureFilterListWidget.FILTER_PROPERTY, type = WidgetPropertyType.FILTER, optional = false), + @WidgetProperty(key = MeasureFilterListWidget.PAGE_SIZE_PROPERTY, type = WidgetPropertyType.INTEGER, defaultValue = "30"), + @WidgetProperty(key = MeasureFilterListWidget.DISPLAY_FILTER_DESCRIPTION, type = WidgetPropertyType.BOOLEAN, defaultValue = "false") +}) +public class MeasureFilterListWidget extends CoreWidget { + public static final String FILTER_PROPERTY = "filter"; + public static final String PAGE_SIZE_PROPERTY = "pageSize"; + public static final String DISPLAY_FILTER_DESCRIPTION = "displayFilterDescription"; + public static final String ID = "measure_filter_list"; + + public MeasureFilterListWidget() { + super(ID, "Measure Filter as List", "/org/sonar/server/dashboard/widget/measure_filter_list.html.erb"); + } +} diff --git a/server/sonar-server/src/main/java/org/sonar/server/dashboard/widget/ProjectFileCloudWidget.java b/server/sonar-server/src/main/java/org/sonar/server/dashboard/widget/ProjectFileCloudWidget.java new file mode 100644 index 00000000000..616267d5841 --- /dev/null +++ b/server/sonar-server/src/main/java/org/sonar/server/dashboard/widget/ProjectFileCloudWidget.java @@ -0,0 +1,38 @@ +/* + * SonarQube, open source software quality management tool. + * Copyright (C) 2008-2014 SonarSource + * mailto:contact AT sonarsource DOT com + * + * SonarQube 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. + * + * SonarQube 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 this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +package org.sonar.server.dashboard.widget; + +import org.sonar.api.measures.CoreMetrics; +import org.sonar.api.web.WidgetProperties; +import org.sonar.api.web.WidgetProperty; +import org.sonar.api.web.WidgetPropertyType; + +@WidgetProperties({ + @WidgetProperty(key = "chartTitle", type = WidgetPropertyType.STRING), + @WidgetProperty(key = "colorMetric", type = WidgetPropertyType.METRIC, defaultValue = CoreMetrics.COVERAGE_KEY, options = "type:PERCENT"), + @WidgetProperty(key = "sizeMetric", type = WidgetPropertyType.METRIC, defaultValue = CoreMetrics.COMPLEXITY_KEY, options = {WidgetConstants.FILTER_OUT_NEW_METRICS}), + @WidgetProperty(key = "maxItems", type = WidgetPropertyType.INTEGER, defaultValue = "100") +}) +public class ProjectFileCloudWidget extends CoreWidget { + public ProjectFileCloudWidget() { + super("project_file_cloud", "Project File Word Cloud", "/org/sonar/server/dashboard/widget/project_file_cloud.html.erb"); + } +} diff --git a/server/sonar-server/src/main/java/org/sonar/server/dashboard/widget/ProjectIssueFilterWidget.java b/server/sonar-server/src/main/java/org/sonar/server/dashboard/widget/ProjectIssueFilterWidget.java new file mode 100644 index 00000000000..3f4f1ff9275 --- /dev/null +++ b/server/sonar-server/src/main/java/org/sonar/server/dashboard/widget/ProjectIssueFilterWidget.java @@ -0,0 +1,49 @@ +/* + * SonarQube, open source software quality management tool. + * Copyright (C) 2008-2014 SonarSource + * mailto:contact AT sonarsource DOT com + * + * SonarQube 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. + * + * SonarQube 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 this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.dashboard.widget; + +import org.sonar.api.web.WidgetCategory; +import org.sonar.api.web.WidgetProperties; +import org.sonar.api.web.WidgetProperty; +import org.sonar.api.web.WidgetPropertyType; +import org.sonar.api.web.WidgetScope; + +import static org.sonar.api.web.WidgetScope.PROJECT; + +@WidgetCategory({"Filters", "Issues"}) +@WidgetScope(PROJECT) +@WidgetProperties({ + @WidgetProperty(key = ProjectIssueFilterWidget.FILTER_PROPERTY, type = WidgetPropertyType.ISSUE_FILTER, optional = false), + @WidgetProperty(key = ProjectIssueFilterWidget.DISTRIBUTION_AXIS_PROPERTY, type = WidgetPropertyType.SINGLE_SELECT_LIST, defaultValue = "severities", + options = {"severities", "resolutions", "statuses", "rules", "tags", "assignees", "reporters", "authors", + "languages", "actionPlans", "createdAt"}), + @WidgetProperty(key = ProjectIssueFilterWidget.DISPLAY_FILTER_DESCRIPTION, type = WidgetPropertyType.BOOLEAN, defaultValue = "false") +}) +public class ProjectIssueFilterWidget extends CoreWidget { + + public static final String FILTER_PROPERTY = "filter"; + public static final String DISTRIBUTION_AXIS_PROPERTY = "distributionAxis"; + public static final String DISPLAY_FILTER_DESCRIPTION = "displayFilterDescription"; + public static final String ID = "project_issue_filter"; + + public ProjectIssueFilterWidget() { + super(ID, "Project Issue Filter", "/org/sonar/server/dashboard/widget/project_issue_filter.html.erb"); + } +} diff --git a/server/sonar-server/src/main/java/org/sonar/server/dashboard/widget/SizeWidget.java b/server/sonar-server/src/main/java/org/sonar/server/dashboard/widget/SizeWidget.java new file mode 100644 index 00000000000..e5b0db1df35 --- /dev/null +++ b/server/sonar-server/src/main/java/org/sonar/server/dashboard/widget/SizeWidget.java @@ -0,0 +1,27 @@ +/* + * SonarQube, open source software quality management tool. + * Copyright (C) 2008-2014 SonarSource + * mailto:contact AT sonarsource DOT com + * + * SonarQube 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. + * + * SonarQube 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 this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.dashboard.widget; + +public class SizeWidget extends CoreWidget { + + public SizeWidget() { + super("size", "Size metrics", "/org/sonar/server/dashboard/widget/size.html.erb"); + } +} diff --git a/server/sonar-server/src/main/java/org/sonar/server/dashboard/widget/TechnicalDebtPyramidWidget.java b/server/sonar-server/src/main/java/org/sonar/server/dashboard/widget/TechnicalDebtPyramidWidget.java new file mode 100644 index 00000000000..1eb36c50460 --- /dev/null +++ b/server/sonar-server/src/main/java/org/sonar/server/dashboard/widget/TechnicalDebtPyramidWidget.java @@ -0,0 +1,32 @@ +/* + * SonarQube, open source software quality management tool. + * Copyright (C) 2008-2014 SonarSource + * mailto:contact AT sonarsource DOT com + * + * SonarQube 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. + * + * SonarQube 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 this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.dashboard.widget; + +import org.sonar.api.web.UserRole; +import org.sonar.api.web.WidgetCategory; + +@UserRole(UserRole.USER) +@WidgetCategory("Technical Debt") +public final class TechnicalDebtPyramidWidget extends CoreWidget { + + public TechnicalDebtPyramidWidget() { + super("technical_debt_pyramid", "Technical Debt Pyramid", "/org/sonar/server/dashboard/widget/technical_debt_pyramid.html.erb"); + } +} diff --git a/server/sonar-server/src/main/java/org/sonar/server/dashboard/widget/TimeMachineWidget.java b/server/sonar-server/src/main/java/org/sonar/server/dashboard/widget/TimeMachineWidget.java new file mode 100644 index 00000000000..73f96bb2bd1 --- /dev/null +++ b/server/sonar-server/src/main/java/org/sonar/server/dashboard/widget/TimeMachineWidget.java @@ -0,0 +1,47 @@ +/* + * SonarQube, open source software quality management tool. + * Copyright (C) 2008-2014 SonarSource + * mailto:contact AT sonarsource DOT com + * + * SonarQube 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. + * + * SonarQube 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 this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.dashboard.widget; + +import org.sonar.api.web.WidgetCategory; +import org.sonar.api.web.WidgetProperties; +import org.sonar.api.web.WidgetProperty; +import org.sonar.api.web.WidgetPropertyType; + +@WidgetCategory("History") +@WidgetProperties({ + @WidgetProperty(key = "title", type = WidgetPropertyType.STRING), + @WidgetProperty(key = "numberOfColumns", type = WidgetPropertyType.INTEGER, defaultValue = "3"), + @WidgetProperty(key = "displaySparkLine", type = WidgetPropertyType.BOOLEAN), + @WidgetProperty(key = "metric1", type = WidgetPropertyType.METRIC, defaultValue = "ncloc", options = {WidgetConstants.FILTER_OUT_NEW_METRICS}), + @WidgetProperty(key = "metric2", type = WidgetPropertyType.METRIC, options = {WidgetConstants.FILTER_OUT_NEW_METRICS}), + @WidgetProperty(key = "metric3", type = WidgetPropertyType.METRIC, options = {WidgetConstants.FILTER_OUT_NEW_METRICS}), + @WidgetProperty(key = "metric4", type = WidgetPropertyType.METRIC, options = {WidgetConstants.FILTER_OUT_NEW_METRICS}), + @WidgetProperty(key = "metric5", type = WidgetPropertyType.METRIC, options = {WidgetConstants.FILTER_OUT_NEW_METRICS}), + @WidgetProperty(key = "metric6", type = WidgetPropertyType.METRIC, options = {WidgetConstants.FILTER_OUT_NEW_METRICS}), + @WidgetProperty(key = "metric7", type = WidgetPropertyType.METRIC, options = {WidgetConstants.FILTER_OUT_NEW_METRICS}), + @WidgetProperty(key = "metric8", type = WidgetPropertyType.METRIC, options = {WidgetConstants.FILTER_OUT_NEW_METRICS}), + @WidgetProperty(key = "metric9", type = WidgetPropertyType.METRIC, options = {WidgetConstants.FILTER_OUT_NEW_METRICS}), + @WidgetProperty(key = "metric10", type = WidgetPropertyType.METRIC, options = {WidgetConstants.FILTER_OUT_NEW_METRICS}) +}) +public class TimeMachineWidget extends CoreWidget { + public TimeMachineWidget() { + super("time_machine", "History Table", "/org/sonar/server/dashboard/widget/time_machine.html.erb"); + } +} diff --git a/server/sonar-server/src/main/java/org/sonar/server/dashboard/widget/TimelineWidget.java b/server/sonar-server/src/main/java/org/sonar/server/dashboard/widget/TimelineWidget.java new file mode 100644 index 00000000000..afe5c9eb842 --- /dev/null +++ b/server/sonar-server/src/main/java/org/sonar/server/dashboard/widget/TimelineWidget.java @@ -0,0 +1,40 @@ +/* + * SonarQube, open source software quality management tool. + * Copyright (C) 2008-2014 SonarSource + * mailto:contact AT sonarsource DOT com + * + * SonarQube 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. + * + * SonarQube 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 this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.dashboard.widget; + +import org.sonar.api.web.WidgetCategory; +import org.sonar.api.web.WidgetProperties; +import org.sonar.api.web.WidgetProperty; +import org.sonar.api.web.WidgetPropertyType; + +@WidgetCategory("History") +@WidgetProperties({ + @WidgetProperty(key = "chartTitle", type = WidgetPropertyType.STRING), + @WidgetProperty(key = "metric1", type = WidgetPropertyType.METRIC, defaultValue = "ncloc", options = {WidgetConstants.FILTER_OUT_NEW_METRICS}), + @WidgetProperty(key = "metric2", type = WidgetPropertyType.METRIC, options = {WidgetConstants.FILTER_OUT_NEW_METRICS}), + @WidgetProperty(key = "metric3", type = WidgetPropertyType.METRIC, options = {WidgetConstants.FILTER_OUT_NEW_METRICS}), + @WidgetProperty(key = "hideEvents", type = WidgetPropertyType.BOOLEAN), + @WidgetProperty(key = "chartHeight", type = WidgetPropertyType.INTEGER, defaultValue = "180") +}) +public class TimelineWidget extends CoreWidget { + public TimelineWidget() { + super("timeline", "Timeline", "/org/sonar/server/dashboard/widget/timeline.html.erb"); + } +} diff --git a/server/sonar-server/src/main/java/org/sonar/server/dashboard/widget/TreemapWidget.java b/server/sonar-server/src/main/java/org/sonar/server/dashboard/widget/TreemapWidget.java new file mode 100644 index 00000000000..e70a341b431 --- /dev/null +++ b/server/sonar-server/src/main/java/org/sonar/server/dashboard/widget/TreemapWidget.java @@ -0,0 +1,40 @@ +/* + * SonarQube, open source software quality management tool. + * Copyright (C) 2008-2014 SonarSource + * mailto:contact AT sonarsource DOT com + * + * SonarQube 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. + * + * SonarQube 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 this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +package org.sonar.server.dashboard.widget; + +import org.sonar.api.measures.CoreMetrics; +import org.sonar.api.web.WidgetProperties; +import org.sonar.api.web.WidgetProperty; +import org.sonar.api.web.WidgetPropertyType; + +@WidgetProperties({ + @WidgetProperty(key = "chartTitle", type = WidgetPropertyType.STRING), + @WidgetProperty(key = "sizeMetric", type = WidgetPropertyType.METRIC, defaultValue = CoreMetrics.NCLOC_KEY, options = {WidgetConstants.FILTER_OUT_NEW_METRICS}), + @WidgetProperty(key = "colorMetric", type = WidgetPropertyType.METRIC, defaultValue = CoreMetrics.COVERAGE_KEY, + options = {WidgetConstants.FILTER_OUT_NEW_METRICS, "type:PERCENT,RATING,LEVEL"}), + @WidgetProperty(key = "heightInPercents", type = WidgetPropertyType.INTEGER, optional = true, defaultValue = "55"), + @WidgetProperty(key = "maxItems", type = WidgetPropertyType.INTEGER, defaultValue = "100") +}) +public class TreemapWidget extends CoreWidget { + public TreemapWidget() { + super("treemap-widget", "Treemap of Components", "/org/sonar/server/dashboard/widget/treemap.html.erb"); + } +} diff --git a/server/sonar-server/src/main/java/org/sonar/server/dashboard/widget/WelcomeWidget.java b/server/sonar-server/src/main/java/org/sonar/server/dashboard/widget/WelcomeWidget.java new file mode 100644 index 00000000000..743f44fbf0b --- /dev/null +++ b/server/sonar-server/src/main/java/org/sonar/server/dashboard/widget/WelcomeWidget.java @@ -0,0 +1,34 @@ +/* + * SonarQube, open source software quality management tool. + * Copyright (C) 2008-2014 SonarSource + * mailto:contact AT sonarsource DOT com + * + * SonarQube 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. + * + * SonarQube 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 this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.dashboard.widget; + +import org.sonar.api.web.WidgetScope; + +import static org.sonar.api.web.WidgetScope.GLOBAL; + +@WidgetScope(GLOBAL) +public class WelcomeWidget extends CoreWidget { + + public static final String ID = "welcome"; + + public WelcomeWidget() { + super(ID, "Welcome", "/org/sonar/server/dashboard/widget/welcome.html.erb"); + } +} diff --git a/server/sonar-server/src/main/java/org/sonar/server/dashboard/widget/WidgetConstants.java b/server/sonar-server/src/main/java/org/sonar/server/dashboard/widget/WidgetConstants.java new file mode 100644 index 00000000000..55f6efe36ac --- /dev/null +++ b/server/sonar-server/src/main/java/org/sonar/server/dashboard/widget/WidgetConstants.java @@ -0,0 +1,33 @@ +/* + * SonarQube, open source software quality management tool. + * Copyright (C) 2008-2014 SonarSource + * mailto:contact AT sonarsource DOT com + * + * SonarQube 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. + * + * SonarQube 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 this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.dashboard.widget; + +/** + * Constants shared accross multiple widgets + */ +public interface WidgetConstants { + + /** + * Widget property option used to filter out all the metrics which keys start with "new_". + * + * @see org.sonar.api.web.WidgetProperty#options() + */ + String FILTER_OUT_NEW_METRICS = "key:^(?!new_).*"; +} diff --git a/server/sonar-server/src/main/java/org/sonar/server/dashboard/widget/package-info.java b/server/sonar-server/src/main/java/org/sonar/server/dashboard/widget/package-info.java new file mode 100644 index 00000000000..2e21d54b045 --- /dev/null +++ b/server/sonar-server/src/main/java/org/sonar/server/dashboard/widget/package-info.java @@ -0,0 +1,24 @@ +/* + * SonarQube, open source software quality management tool. + * Copyright (C) 2008-2014 SonarSource + * mailto:contact AT sonarsource DOT com + * + * SonarQube 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. + * + * SonarQube 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 this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +@ParametersAreNonnullByDefault +package org.sonar.server.dashboard.widget; + +import javax.annotation.ParametersAreNonnullByDefault; + diff --git a/server/sonar-server/src/main/java/org/sonar/server/dashboard/ws/ShowAction.java b/server/sonar-server/src/main/java/org/sonar/server/dashboard/ws/ShowAction.java index 354239cf756..49ed5a37786 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/dashboard/ws/ShowAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/dashboard/ws/ShowAction.java @@ -20,6 +20,7 @@ package org.sonar.server.dashboard.ws; import com.google.common.collect.ListMultimap; +import java.util.Collection; import org.sonar.api.server.ws.Request; import org.sonar.api.server.ws.Response; import org.sonar.api.server.ws.WebService; @@ -33,8 +34,6 @@ import org.sonar.server.db.DbClient; import org.sonar.server.exceptions.NotFoundException; import org.sonar.server.user.UserSession; -import java.util.Collection; - public class ShowAction implements DashboardsWsAction { private static final String PARAM_KEY = "key"; diff --git a/server/sonar-server/src/main/java/org/sonar/server/dashboard/ws/package-info.java b/server/sonar-server/src/main/java/org/sonar/server/dashboard/ws/package-info.java index d7b36f91de1..df3059cd05f 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/dashboard/ws/package-info.java +++ b/server/sonar-server/src/main/java/org/sonar/server/dashboard/ws/package-info.java @@ -21,3 +21,4 @@ package org.sonar.server.dashboard.ws; import javax.annotation.ParametersAreNonnullByDefault; + diff --git a/server/sonar-server/src/main/java/org/sonar/server/measure/template/MyFavouritesFilter.java b/server/sonar-server/src/main/java/org/sonar/server/measure/template/MyFavouritesFilter.java new file mode 100644 index 00000000000..96e0e7eca13 --- /dev/null +++ b/server/sonar-server/src/main/java/org/sonar/server/measure/template/MyFavouritesFilter.java @@ -0,0 +1,49 @@ +/* + * SonarQube, open source software quality management tool. + * Copyright (C) 2008-2014 SonarSource + * mailto:contact AT sonarsource DOT com + * + * SonarQube 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. + * + * SonarQube 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 this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.measure.template; + +import org.sonar.api.measures.CoreMetrics; +import org.sonar.api.web.Filter; +import org.sonar.api.web.FilterColumn; +import org.sonar.api.web.FilterTemplate; + +/** + * Default filter for looking for user favourite resources. + * + * @since 3.1 + */ +public class MyFavouritesFilter extends FilterTemplate { + public static final String NAME = "My favourites"; + + @Override + public String getName() { + return NAME; + } + + @Override + public Filter createFilter() { + return Filter.create() + .setDisplayAs(Filter.LIST) + .setFavouritesOnly(true) + .add(FilterColumn.create("metric", CoreMetrics.ALERT_STATUS_KEY, FilterColumn.DESC, false)) + .add(FilterColumn.create("name", null, FilterColumn.ASC, false)) + .add(FilterColumn.create("date", null, FilterColumn.DESC, false)); + } +} diff --git a/server/sonar-server/src/main/java/org/sonar/server/measure/template/ProjectFilter.java b/server/sonar-server/src/main/java/org/sonar/server/measure/template/ProjectFilter.java new file mode 100644 index 00000000000..a82ae695a82 --- /dev/null +++ b/server/sonar-server/src/main/java/org/sonar/server/measure/template/ProjectFilter.java @@ -0,0 +1,54 @@ +/* + * SonarQube, open source software quality management tool. + * Copyright (C) 2008-2014 SonarSource + * mailto:contact AT sonarsource DOT com + * + * SonarQube 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. + * + * SonarQube 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 this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.measure.template; + +import org.sonar.api.measures.CoreMetrics; +import org.sonar.api.resources.Qualifiers; +import org.sonar.api.web.Criterion; +import org.sonar.api.web.Filter; +import org.sonar.api.web.FilterColumn; +import org.sonar.api.web.FilterTemplate; + +/** + * Default projects filter. + * + * @since 3.1 + */ +public class ProjectFilter extends FilterTemplate { + public static final String NAME = "Projects"; + + @Override + public String getName() { + return NAME; + } + + @Override + public Filter createFilter() { + return Filter.create() + .setDisplayAs(Filter.LIST) + .add(Criterion.createForQualifier(Qualifiers.PROJECT)) + .add(FilterColumn.create("metric", CoreMetrics.ALERT_STATUS_KEY, FilterColumn.DESC, false)) + .add(FilterColumn.create("name", null, FilterColumn.ASC, false)) + .add(FilterColumn.create("version", null, FilterColumn.DESC, false)) + .add(FilterColumn.create("metric", CoreMetrics.NCLOC_KEY, FilterColumn.DESC, false)) + .add(FilterColumn.create("metric", CoreMetrics.TECHNICAL_DEBT_KEY, FilterColumn.DESC, false)) + .add(FilterColumn.create("date", null, FilterColumn.DESC, false)); + } +} diff --git a/server/sonar-server/src/main/java/org/sonar/server/measure/template/package-info.java b/server/sonar-server/src/main/java/org/sonar/server/measure/template/package-info.java new file mode 100644 index 00000000000..4a9c1cded91 --- /dev/null +++ b/server/sonar-server/src/main/java/org/sonar/server/measure/template/package-info.java @@ -0,0 +1,21 @@ +/* + * SonarQube, open source software quality management tool. + * Copyright (C) 2008-2014 SonarSource + * mailto:contact AT sonarsource DOT com + * + * SonarQube 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. + * + * SonarQube 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 this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +@javax.annotation.ParametersAreNonnullByDefault +package org.sonar.server.measure.template; diff --git a/server/sonar-server/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel4.java b/server/sonar-server/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel4.java index 2bf4c9ca845..59f0cc900fc 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel4.java +++ b/server/sonar-server/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel4.java @@ -58,6 +58,8 @@ import org.sonar.server.activity.ws.ActivityMapping; import org.sonar.server.authentication.ws.AuthenticationWs; import org.sonar.server.batch.BatchWsModule; import org.sonar.server.charts.ChartFactory; +import org.sonar.server.charts.DistributionAreaChart; +import org.sonar.server.charts.DistributionBarChart; import org.sonar.server.component.ComponentCleanerService; import org.sonar.server.component.ComponentService; import org.sonar.server.component.DefaultComponentFinder; @@ -72,6 +74,40 @@ import org.sonar.server.computation.ws.HistoryAction; import org.sonar.server.computation.ws.IsQueueEmptyWs; import org.sonar.server.computation.ws.QueueAction; import org.sonar.server.config.ws.PropertiesWs; +import org.sonar.server.dashboard.template.GlobalDefaultDashboard; +import org.sonar.server.dashboard.template.ProjectDefaultDashboard; +import org.sonar.server.dashboard.template.ProjectIssuesDashboard; +import org.sonar.server.dashboard.template.ProjectTimeMachineDashboard; +import org.sonar.server.dashboard.widget.ActionPlansWidget; +import org.sonar.server.dashboard.widget.AlertsWidget; +import org.sonar.server.dashboard.widget.BubbleChartWidget; +import org.sonar.server.dashboard.widget.ComplexityWidget; +import org.sonar.server.dashboard.widget.CoverageWidget; +import org.sonar.server.dashboard.widget.CustomMeasuresWidget; +import org.sonar.server.dashboard.widget.DebtOverviewWidget; +import org.sonar.server.dashboard.widget.DescriptionWidget; +import org.sonar.server.dashboard.widget.DocumentationCommentsWidget; +import org.sonar.server.dashboard.widget.DuplicationsWidget; +import org.sonar.server.dashboard.widget.EventsWidget; +import org.sonar.server.dashboard.widget.HotspotMetricWidget; +import org.sonar.server.dashboard.widget.IssueFilterWidget; +import org.sonar.server.dashboard.widget.IssueTagCloudWidget; +import org.sonar.server.dashboard.widget.IssuesWidget; +import org.sonar.server.dashboard.widget.ItCoverageWidget; +import org.sonar.server.dashboard.widget.MeasureFilterAsBubbleChartWidget; +import org.sonar.server.dashboard.widget.MeasureFilterAsCloudWidget; +import org.sonar.server.dashboard.widget.MeasureFilterAsHistogramWidget; +import org.sonar.server.dashboard.widget.MeasureFilterAsPieChartWidget; +import org.sonar.server.dashboard.widget.MeasureFilterAsTreemapWidget; +import org.sonar.server.dashboard.widget.MeasureFilterListWidget; +import org.sonar.server.dashboard.widget.ProjectFileCloudWidget; +import org.sonar.server.dashboard.widget.ProjectIssueFilterWidget; +import org.sonar.server.dashboard.widget.SizeWidget; +import org.sonar.server.dashboard.widget.TechnicalDebtPyramidWidget; +import org.sonar.server.dashboard.widget.TimeMachineWidget; +import org.sonar.server.dashboard.widget.TimelineWidget; +import org.sonar.server.dashboard.widget.TreemapWidget; +import org.sonar.server.dashboard.widget.WelcomeWidget; import org.sonar.server.dashboard.ws.DashboardsWs; import org.sonar.server.debt.DebtCharacteristicsXMLImporter; import org.sonar.server.debt.DebtModelBackup; @@ -126,6 +162,8 @@ import org.sonar.server.language.ws.LanguageWs; import org.sonar.server.measure.MeasureFilterEngine; import org.sonar.server.measure.MeasureFilterExecutor; import org.sonar.server.measure.MeasureFilterFactory; +import org.sonar.server.measure.template.MyFavouritesFilter; +import org.sonar.server.measure.template.ProjectFilter; import org.sonar.server.measure.ws.ManualMeasuresWs; import org.sonar.server.measure.ws.TimeMachineWs; import org.sonar.server.metric.ws.MetricsWs; @@ -298,6 +336,8 @@ public class PlatformLevel4 extends PlatformLevel { add( PluginDownloader.class, ChartFactory.class, + DistributionBarChart.class, + DistributionAreaChart.class, Views.class, ResourceTypes.class, SettingsChangeNotifier.class, @@ -321,6 +361,40 @@ public class PlatformLevel4 extends PlatformLevel { // Dashboard DashboardsWs.class, org.sonar.server.dashboard.ws.ShowAction.class, + ProjectDefaultDashboard.class, + ProjectIssuesDashboard.class, + ProjectTimeMachineDashboard.class, + GlobalDefaultDashboard.class, + AlertsWidget.class, + CoverageWidget.class, + ItCoverageWidget.class, + DescriptionWidget.class, + ComplexityWidget.class, + IssuesWidget.class, + SizeWidget.class, + EventsWidget.class, + CustomMeasuresWidget.class, + TimelineWidget.class, + BubbleChartWidget.class, + TimeMachineWidget.class, + HotspotMetricWidget.class, + TreemapWidget.class, + MeasureFilterListWidget.class, + MeasureFilterAsTreemapWidget.class, + WelcomeWidget.class, + DocumentationCommentsWidget.class, + DuplicationsWidget.class, + TechnicalDebtPyramidWidget.class, + MeasureFilterAsPieChartWidget.class, + MeasureFilterAsCloudWidget.class, + MeasureFilterAsHistogramWidget.class, + MeasureFilterAsBubbleChartWidget.class, + ProjectFileCloudWidget.class, + DebtOverviewWidget.class, + ActionPlansWidget.class, + IssueFilterWidget.class, + ProjectIssueFilterWidget.class, + IssueTagCloudWidget.class, // update center UpdateCenterClient.class, @@ -412,6 +486,8 @@ public class PlatformLevel4 extends PlatformLevel { MeasureFilterFactory.class, MeasureFilterExecutor.class, MeasureFilterEngine.class, + ProjectFilter.class, + MyFavouritesFilter.class, DefaultMetricFinder.class, ServerLifecycleNotifier.class, TimeMachineWs.class, diff --git a/server/sonar-server/src/main/resources/org/sonar/server/dashboard/widget/_complexity_chart.html.erb b/server/sonar-server/src/main/resources/org/sonar/server/dashboard/widget/_complexity_chart.html.erb new file mode 100644 index 00000000000..b75db5d24fd --- /dev/null +++ b/server/sonar-server/src/main/resources/org/sonar/server/dashboard/widget/_complexity_chart.html.erb @@ -0,0 +1,18 @@ +<% dist_measure = measure(metric) + if dist_measure && !dist_measure.data.blank? +%> +
"> +<% + query="ck=distbar&c=777777&v=" + u(dist_measure.data) + small_size_query=query + '&w=220&h=100&fs=8&bgc=ffffff' + big_size_query=query + '&w=300&h=150&fs=12&bgc=CAE3F2' +%><%= chart(small_size_query, :id => 'chart_img_' + metric, :alt => title) -%> + + +
+<% end %> \ No newline at end of file diff --git a/server/sonar-server/src/main/resources/org/sonar/server/dashboard/widget/action_plans.html.erb b/server/sonar-server/src/main/resources/org/sonar/server/dashboard/widget/action_plans.html.erb new file mode 100644 index 00000000000..75553d3de15 --- /dev/null +++ b/server/sonar-server/src/main/resources/org/sonar/server/dashboard/widget/action_plans.html.erb @@ -0,0 +1,97 @@ +<% + # This widget should only be display on root projects + if @project.qualifier == 'TRK' && has_role?(:user, @project) + action_plans = Internal.issues.findActionPlanStats(@resource.key) + open_action_plans = action_plans.select {|plan| plan.isOpen()} + + div_id = "issues-action-plan-widget-#{widget.id.to_s}" +%> + +
+ <% if has_role?(:admin, @project) %> + + <% end %> + +

<%= message('widget.action_plans.title') -%>

+
+ + +
+ +<% if open_action_plans.size ==0 %> + + <%= message('widget.action_plans.no_action_plan') -%> + +<% + else + show_resolved_issues = widget_properties["showResolvedIssues"] + if show_resolved_issues + line_class = "top" + else + line_class = "middle" + max_unresolved_issues = open_action_plans.map {|plan| plan.unresolvedIssues()}.max + end +%> + + + + + + + + + <% + open_action_plans.each do |plan| + %> + "action_plan_" + widget.id.to_s) -%>"> + + + + <% if show_resolved_issues %> + <% if plan.totalIssues()==0 %> + + <% else %> + + <% end %> + <% + else + unresolved_issues_size = plan.unresolvedIssues() + %> + + + <% end %> + + + <% + end + %> + +
<%= h(plan.name) -%><%= format_date(plan.deadLine()) -%><%= message('action_plans.no_issues_linked_to_action_plan') -%> + <%= render :partial => 'action_plans/progress', :locals => {:action_plan => plan} -%> + + <% if unresolved_issues_size == 0 %> + <%= unresolved_issues_size -%> + <% else %> + <% + search_options = {} + search_options['actionPlans'] = plan.key + search_options['resolved'] = false + %> + <%= unresolved_issues_size -%> + <% end %> + +
+
+
+
+ +<% end %> + +
+ +<% end %> diff --git a/server/sonar-server/src/main/resources/org/sonar/server/dashboard/widget/alerts.html.erb b/server/sonar-server/src/main/resources/org/sonar/server/dashboard/widget/alerts.html.erb new file mode 100644 index 00000000000..d50c712836a --- /dev/null +++ b/server/sonar-server/src/main/resources/org/sonar/server/dashboard/widget/alerts.html.erb @@ -0,0 +1,95 @@ +<% m=measure(Metric::QUALITY_GATE_DETAILS) + if m && !m.data.blank? + details = JSON.parse m.data + m.alert_status = details['level'] + raw_conditions = details['conditions'] + conditions = [] + missing_metric = false + raw_conditions.each do |condition| + if metric(condition['metric']).nil? + missing_metric = true + else + conditions << condition + end + end + alert_metric = metric(Metric::ALERT_STATUS) + + warn_message = message('measure_filter.criteria.alert.warn') + error_message = message('measure_filter.criteria.alert.error') + + css_class = "color_#{m.alert_status}" + if m.alert_status==Metric::TYPE_LEVEL_OK + label = "#{message('widget.alerts.no_alert')}." + elsif m.alert_status==Metric::TYPE_LEVEL_WARN + label = "#{message('widget.alerts.warnings')}" + else + label = "#{message('widget.alerts.errors')}" + end +-%>
+
<%= format_measure(measure(Metric::ALERT_STATUS)) -%> <%= label -%>
+ <% if conditions.any? {|condition| condition['level'] != 'OK'} || widget_properties['show_ok'] && !conditions.empty? -%> + <% conditions.sort_by {|condition| [ -condition['level'].length, metric(condition['metric']).short_name] }.each do |condition| + + level = condition['level'] + condition_metric = metric(condition['metric']) + operator = message("quality_gates.operator.#{condition['op']}.short") + period = condition['period'] + warning_value = condition['warning'] + error_value = condition['error'] + actual_value = condition['actual'] + + detail_measure = ProjectMeasure.new :metric => alert_metric, :alert_status => level + + drilldown_url = period.blank? ? url_for_drilldown(condition_metric) : url_for_drilldown(condition_metric, :period => period) + + actual_measure = ProjectMeasure.new :metric => condition_metric, :value => actual_value, :alert_status => level + warning_measure = ProjectMeasure.new :metric => condition_metric, :value => warning_value + error_measure = ProjectMeasure.new :metric => condition_metric, :value => error_value + + is_difference_measure = condition_metric.name.start_with?('new_') + is_issue_measure = get_issue_metrics.include? condition_metric.name + is_not_difference_measure_with_period = !is_difference_measure && !period.blank? && !is_issue_measure + + tooltip = message('widget.as_calculated_on_x', :params => l(@snapshot.created_at)) + + + unless level == 'OK' && !widget_properties['show_ok'] + -%> +
+

<%= condition_metric.short_name -%>

+ <% if is_not_difference_measure_with_period %> + <%= format_measure(actual_measure) -%> + <% else %> + <%= format_measure(actual_measure, :url => drilldown_url) -%> + <% end %> + <% if level == 'WARN' -%><%= operator -%> <%= format_measure(warning_measure) -%><% end -%> + <% if level == 'ERROR' -%><%= operator -%> <%= format_measure(error_measure) -%><% end -%> + <% if level == 'OK' -%> + <% unless warning_value.blank? -%><%= warn_message -%> <%= operator -%> <%= format_measure(warning_measure) -%> <%= '|' unless error_value.blank? -%><% end -%> + <% unless error_value.blank? -%><%= error_message -%> <%= operator -%> <%= format_measure(error_measure) -%><% end -%> + <% end -%> +

<%= period_label(@snapshot, period) unless period.blank? -%>

+
+ <% end + end + end + if missing_metric -%> +
<%= message('widget.alerts.missing_metric') -%>
+ <% end -%> +
+<% else -%> +<% m=measure(Metric::ALERT_STATUS) + if m && !m.alert_status.blank? + css_class = "widget color_#{m.alert_status}" + if m.alert_status==Metric::TYPE_LEVEL_OK + label = "#{message('widget.alerts.no_alert')}." + elsif m.alert_status==Metric::TYPE_LEVEL_WARN + label = "#{message('widget.alerts.warnings')}#{h(m.alert_text)}." + else + label = "#{message('widget.alerts.errors')}#{h(m.alert_text)}." + end +-%>
+
<%= format_measure(m) -%> <%= label -%>
+
+<% end +end -%> diff --git a/server/sonar-server/src/main/resources/org/sonar/server/dashboard/widget/bubbleChart.html.erb b/server/sonar-server/src/main/resources/org/sonar/server/dashboard/widget/bubbleChart.html.erb new file mode 100644 index 00000000000..e0188194dd2 --- /dev/null +++ b/server/sonar-server/src/main/resources/org/sonar/server/dashboard/widget/bubbleChart.html.erb @@ -0,0 +1,88 @@ +<% + containerId = 'bubble-chart-widget' + widget.id.to_s + xMetric = widget_properties["xMetric"] + yMetric = widget_properties["yMetric"] + sizeMetric = widget_properties["sizeMetric"] + xLog = !!widget_properties["xLogarithmic"] + yLog = !!widget_properties["yLogarithmic"] + chartHeight = widget_properties["chartHeight"] + chartTitle = widget_properties["chartTitle"] +%> + +
+ + + + <% if chartTitle %> +

<%= h(chartTitle) -%>

+ <% end %> + +
+ + + + diff --git a/server/sonar-server/src/main/resources/org/sonar/server/dashboard/widget/complexity.html.erb b/server/sonar-server/src/main/resources/org/sonar/server/dashboard/widget/complexity.html.erb new file mode 100644 index 00000000000..62832d2335a --- /dev/null +++ b/server/sonar-server/src/main/resources/org/sonar/server/dashboard/widget/complexity.html.erb @@ -0,0 +1,115 @@ +<% + file_complexity=measure('file_complexity') + function_complexity=measure('function_complexity') + class_complexity=measure('class_complexity') + + if file_complexity || function_complexity || class_complexity + complexity=measure('complexity') +%> + +
+
+
+ <% if complexity %> +

+ <%= message('metric.complexity.name') %> + + <%= format_measure(complexity, :url => url_for_drilldown(complexity)) %> + <%= format_variation(complexity) if dashboard_configuration.selected_period? -%> + +

+ <% end %> + <% if function_complexity %> +

+ <%= message('widget.complexity.per_method.suffix') %> + + <%= format_measure(function_complexity, :url => url_for_drilldown(function_complexity)) %> + <%= format_variation(function_complexity) if dashboard_configuration.selected_period? -%> + +

+ <% end %> + <% if class_complexity %> +

+ <%= message('widget.complexity.per_class.suffix') %> + + <%= format_measure(class_complexity, :url => url_for_drilldown(class_complexity)) %> + <%= format_variation(class_complexity) if dashboard_configuration.selected_period? -%> + +

+ <% end %> + <% if file_complexity %> +

+ <%= message('widget.complexity.per_file.suffix') %> + + <%= format_measure(file_complexity, :url => url_for_drilldown(file_complexity)) %> + <%= format_variation(file_complexity) if dashboard_configuration.selected_period? -%> + +

+ <% end %> +
+
+ +
+ <% + function_distribution=measure('function_complexity_distribution') + class_distribution=measure('class_complexity_distribution') + file_distribution=measure('file_complexity_distribution') + distributions=[function_distribution, class_distribution, file_distribution].compact + selected_distribution=nil + if distributions.size>0 + selected_distribution=distributions.first + end + if selected_distribution + %> +
+ + + <% distributions.each do |distribution_measure| %> + <%= render :partial => 'project/widgets/complexity_chart', :locals => {:metric => distribution_measure.metric.key, :title => distribution_measure.metric.description, :visible => (selected_distribution==distribution_measure)} %> + <% end %> + +
+ <% + count_dist=0 + if function_distribution + count_dist+=1 + %> + /> + + <% + end + if class_distribution + count_dist+=1 + %> + /> + <%= '
' if count_dist==2 %> + <% + end + if file_distribution + count_dist+=1 + %> + /> + + <% end %> + +
+ +
+ <% end %> +
+
+<% end %> diff --git a/server/sonar-server/src/main/resources/org/sonar/server/dashboard/widget/coverage.html.erb b/server/sonar-server/src/main/resources/org/sonar/server/dashboard/widget/coverage.html.erb new file mode 100644 index 00000000000..e293cfa0d56 --- /dev/null +++ b/server/sonar-server/src/main/resources/org/sonar/server/dashboard/widget/coverage.html.erb @@ -0,0 +1,156 @@ +<% + code_coverage_measure=measure('coverage') + tests_measure=measure('tests') + execution_time=measure('test_execution_time') + success_percentage=measure('test_success_density') + + if code_coverage_measure || tests_measure +%> +
+
+
+
+ <%= message('widget.code_coverage.name') -%> + + <%= format_measure(code_coverage_measure, :suffix => '', :url => url_for_drilldown('coverage'), :default => '-') %> + <%= format_variation(code_coverage_measure) if dashboard_configuration.selected_period? -%> + +
+ <% + line_coverage=measure('line_coverage') + if line_coverage + %> +
+ <%= message('widget.code_coverage.line_coverage.suffix') -%> + + <%= format_measure(line_coverage, :url => url_for_drilldown('uncovered_lines', :highlight => 'line_coverage')) %> + <%= format_variation(line_coverage) if dashboard_configuration.selected_period? -%> + +
+ <% end %> + <% + branch_coverage=measure('branch_coverage') + if branch_coverage + %> +
+ <%= message('widget.code_coverage.condition_coverage.suffix') -%> + + <%= format_measure(branch_coverage, :url => url_for_drilldown('uncovered_conditions', :highlight => 'branch_coverage')) %> + <%= format_variation(branch_coverage) if dashboard_configuration.selected_period? -%> + +
+ <% end %> + + <% + if dashboard_configuration.selected_period? + new_lines_to_cover_measure=measure('new_lines_to_cover') + if new_lines_to_cover_measure + new_lines=new_lines_to_cover_measure.variation(dashboard_configuration.period_index) + if new_lines + new_coverage=measure('new_coverage') if variation_value('new_coverage') + new_line_coverage=measure('new_line_coverage') if variation_value('new_line_coverage') + new_branch_coverage=measure('new_branch_coverage') if variation_value('new_branch_coverage') + %> + <% if new_lines.to_i==0 %> +
+ <%= message('widget.code_coverage.on_new_code') -%> +

<%= message('widget.code_coverage.no_new_lines_to_cover') -%>

+
+ <% else %> + <% if new_coverage %> +
+ <%= message('widget.code_coverage.on_new_code') -%> + <%= format_measure(new_coverage, + :period => dashboard_configuration.period_index, + :url => url_for_drilldown('new_coverage', :period => dashboard_configuration.period_index)) %> +
+ <% end %> + <% if new_line_coverage %> +
+ <%= message('widget.code_coverage.line_coverage.suffix') -%> + <%= format_measure(new_line_coverage, + :period => dashboard_configuration.period_index, + :url => url_for_drilldown('new_uncovered_lines', :highlight => 'new_line_coverage', :period => dashboard_configuration.period_index), + :default => '-') %> +
+ <% end %> + <% if new_branch_coverage %> +
+ <%= message('widget.code_coverage.condition_coverage.suffix') -%> + <%= format_measure(new_branch_coverage, + :period => dashboard_configuration.period_index, + :url => url_for_drilldown('new_uncovered_conditions', :highlight => 'new_branch_coverage', :period => dashboard_configuration.period_index), + :default => '-') %> +
+ <% end %> + <% end %> + <% + end + end + end + %> +
+
+
+ <% + if tests_measure + %> +
+
+ <%= message('widget.code_coverage.test_success') -%> + + <%= format_measure(success_percentage, :url => url_for_drilldown(success_percentage)) %> + <%= format_variation(success_percentage) if dashboard_configuration.selected_period? -%> + +
+ +
+ <%= message('widget.code_coverage.failures.suffix') -%> + + <%= format_measure(Metric::TEST_FAILURES, :url => url_for_drilldown(Metric::TEST_FAILURES)) %> + <%= format_variation(Metric::TEST_FAILURES) if dashboard_configuration.selected_period? -%> + +
+ +
+ <%= message('widget.code_coverage.errors.suffix') -%> + + <%= format_measure(Metric::TEST_ERRORS, :url => url_for_drilldown(Metric::TEST_ERRORS)) %> + <%= format_variation(Metric::TEST_ERRORS) if dashboard_configuration.selected_period? -%> + +
+ +
+ <%= message('widget.code_coverage.tests.suffix') -%> + + <%= format_measure(tests_measure, :url => url_for_drilldown('tests')) %> + <%= format_variation(tests_measure) if dashboard_configuration.selected_period? -%> + +
+ + <% skipped_measure=measure(Metric::SKIPPED_TESTS) + if dashboard_configuration.selected_period? || (skipped_measure && skipped_measure.value && skipped_measure.value>0) + %> +
+ <%= message('widget.code_coverage.skipped.suffix') -%> + + <%= format_measure(skipped_measure, :url => url_for_drilldown(Metric::SKIPPED_TESTS)) %> + <%= format_variation(skipped_measure) if dashboard_configuration.selected_period? -%> + +
+ <% end %> + +
+ <%= message('widget.code_coverage.execution_time') -%> + + <%= format_measure(execution_time, :url => url_for_drilldown('test_execution_time')) %> + <%= format_variation(execution_time) if dashboard_configuration.selected_period? -%> + +
+
+ <% end %> +
+
+<% end %> + + diff --git a/server/sonar-server/src/main/resources/org/sonar/server/dashboard/widget/custom_measures.html.erb b/server/sonar-server/src/main/resources/org/sonar/server/dashboard/widget/custom_measures.html.erb new file mode 100644 index 00000000000..c817403bc8c --- /dev/null +++ b/server/sonar-server/src/main/resources/org/sonar/server/dashboard/widget/custom_measures.html.erb @@ -0,0 +1,36 @@ +<% + measures=[] + (1..10).each do |index| + metric=widget_properties["metric#{index}"] + m=(metric ? measure(metric) : nil) + measures << m if m + end + period = params[:period] + unless measures.empty? || measures.none? { |measure| measure.visible?(period.to_i) } +%> +
+ <% + measures.each do |measure| + if measure.visible?(period.to_i) + -%> +
+
+

+ <%= measure.metric.short_name -%> + + <% if measure.value.nil? && measure.text_value.nil? -%> + <%= format_measure(measure, :url => url_for_drilldown(measure, :period => period), :period => period) -%> + <% else %> + <%= format_measure(measure, :url => url_for_drilldown(measure)) -%> + <%= format_variation(measure) if dashboard_configuration.selected_period? -%> + <% end -%> + +

+
+
+ <% + end + end + -%> +
+<% end %> diff --git a/server/sonar-server/src/main/resources/org/sonar/server/dashboard/widget/debt_overview.erb b/server/sonar-server/src/main/resources/org/sonar/server/dashboard/widget/debt_overview.erb new file mode 100644 index 00000000000..87cceb5ff3b --- /dev/null +++ b/server/sonar-server/src/main/resources/org/sonar/server/dashboard/widget/debt_overview.erb @@ -0,0 +1,33 @@ +<% + sqale_rating = @snapshot.measure('sqale_rating') + sqale_debt_ratio = @snapshot.measure('sqale_debt_ratio') + if sqale_rating && sqale_rating.text_value && sqale_debt_ratio +%> + <% if sqale_rating && sqale_rating.text_value %> +
+
+
+
+ <%= message('metric.sqale_rating.name') -%> + + <%= format_measure(sqale_rating, :url => url_for_drilldown(sqale_rating)) %> + +
+
+
+ <% end %> + <% if sqale_debt_ratio %> +
+
+
+ <%= message('metric.sqale_debt_ratio.name') -%> + + <%= format_measure(sqale_debt_ratio, :url => url_for_drilldown(sqale_debt_ratio)) %> + <%= format_variation(sqale_debt_ratio) if dashboard_configuration.selected_period? -%> + +
+
+
+
+ <% end %> +<% end %> diff --git a/server/sonar-server/src/main/resources/org/sonar/server/dashboard/widget/description.html.erb b/server/sonar-server/src/main/resources/org/sonar/server/dashboard/widget/description.html.erb new file mode 100644 index 00000000000..6d587793407 --- /dev/null +++ b/server/sonar-server/src/main/resources/org/sonar/server/dashboard/widget/description.html.erb @@ -0,0 +1,90 @@ +
+

+ + <%= @project.name -%> +

+ <%= h @project.key -%> + + <% if @project.description.present? %> +

<%= h @project.description -%>

+ <% end %> + + <% + qprofiles_measure = measure(Metric::QUALITY_PROFILES) + if qprofiles_measure && !qprofiles_measure.data.blank? + qprofiles = JSON.parse qprofiles_measure.data + if qprofiles.size>0 + %> +

+ <%= message('widget.description.profiles') -%>: + <% qprofiles.each_with_index do |profile, i| %> + + + <%= link_to profile['name'], {:controller => 'profiles', :action => 'show', :key => profile['key']}, :class => 'widget-link', :id => profile['language'] + '_profile_link' -%> + + + (<%= Api::Utils.language_name(profile['language']) -%>) + + <% if i < (qprofiles.size - 1) %>,<% end %> + + <% end + end %> +

+ <% + else + profile_measure=@snapshot.measure('profile') + if profile_measure + %> +

+ <%= message('widget.description.profile') -%>: + + <%= link_to profile_measure.data, {:controller => 'profiles', :action => 'show', :id => profile_measure.value.to_i}, :class => 'widget-link', :id => 'profile_link' -%> + +

+ <% end + end %> + + <% + unless @resource.qualifier == 'DEV' or @resource.qualifier == 'VW' or @resource.qualifier == 'SVW' + using_default=false + quality_gate=Property.value('sonar.qualitygate', @resource && @resource.id, nil) + unless quality_gate + quality_gate=Property.value('sonar.qualitygate', nil, nil) + using_default=false || quality_gate + end + if quality_gate + qgate = Internal.quality_gates.get(quality_gate.to_i) + %> +

+ + <%= message('widget.description.qualitygate') -%>: + <%= link_to qgate.getName(), (url_for :controller => '/quality_gates') + '#show/' + quality_gate, :class => 'widget-link', :id => 'qgate_link' -%> + <% if using_default %> + (<%= message('default') -%>) + <% end %> + +

+ <% end end %> + + <% unless @project.project_links.empty? %> + + <% end %> +
diff --git a/server/sonar-server/src/main/resources/org/sonar/server/dashboard/widget/documentation_comments_widget.html.erb b/server/sonar-server/src/main/resources/org/sonar/server/dashboard/widget/documentation_comments_widget.html.erb new file mode 100644 index 00000000000..06423d5c029 --- /dev/null +++ b/server/sonar-server/src/main/resources/org/sonar/server/dashboard/widget/documentation_comments_widget.html.erb @@ -0,0 +1,63 @@ +<% + if measure(Metric::LINES) || measure(Metric::NCLOC) + public_api=measure('public_api') + public_documented_api_density=measure('public_documented_api_density') + public_undocumented_api=measure('public_undocumented_api') + comment_lines=measure('comment_lines') + comment_lines_density=measure('comment_lines_density') +%> +
+
+ <% if public_documented_api_density || public_api || public_undocumented_api %> +
+ <% + if public_documented_api_density + %> +
+ <%= message('widget.documentation_comments.documentation') -%> + + <%= format_measure(public_documented_api_density, :url => url_for_drilldown(Metric::PUBLIC_UNDOCUMENTED_API, :highlight => Metric::PUBLIC_DOCUMENTED_API_DENSITY)) %> + <%= format_variation('public_documented_api_density') if dashboard_configuration.selected_period? -%> + +
+ <% end %> +
+ <%= message('metric.public_api.name') -%> + + <%= format_measure(public_api,:url => url_for_drilldown(public_api)) %> + <%= format_variation(public_api) if dashboard_configuration.selected_period? -%> + +
+
+ <%= message('metric.public_undocumented_api.abbreviation') -%> + + <%= format_measure(public_undocumented_api,:url => url_for_drilldown(public_undocumented_api)) %> + <%= format_variation(public_undocumented_api) if dashboard_configuration.selected_period? -%> + +
+
+ <% end %> +
+ +
+
+
+ <%= message('widget.documentation_comments.comments') -%> + + <%= format_measure(comment_lines_density,:url => url_for_drilldown(comment_lines_density))%> + <%= format_variation(comment_lines_density) if dashboard_configuration.selected_period? -%> + +
+
+ <%= message('metric.comment_lines.name') -%> + + <%= format_measure(comment_lines,:url => url_for_drilldown(comment_lines)) %> + <%= format_variation(comment_lines) if dashboard_configuration.selected_period? -%> + +
+
+
+
+<% + end +%> diff --git a/server/sonar-server/src/main/resources/org/sonar/server/dashboard/widget/duplications_widget.html.erb b/server/sonar-server/src/main/resources/org/sonar/server/dashboard/widget/duplications_widget.html.erb new file mode 100644 index 00000000000..99b487a57a7 --- /dev/null +++ b/server/sonar-server/src/main/resources/org/sonar/server/dashboard/widget/duplications_widget.html.erb @@ -0,0 +1,41 @@ +<% + duplicated_lines_density=measure('duplicated_lines_density') + if duplicated_lines_density +%> +
+
+
+ <%= message('widget.duplications.duplications') -%> + + <%= format_measure(duplicated_lines_density, :url => url_for_drilldown('duplicated_lines', :highlight => 'duplicated_lines_density')) %> + <%= format_variation('duplicated_lines_density') if dashboard_configuration.selected_period? -%> + +
+ +
+ <%= message('widget.duplications.lines.suffix') -%> + + <%= format_measure(measure('duplicated_lines'), :url => url_for_drilldown('duplicated_lines'))%> + <%= format_variation('duplicated_lines') if dashboard_configuration.selected_period? -%> + +
+ +
+ <%= message('widget.duplications.blocks.suffix') -%> + + <%= format_measure(measure('duplicated_blocks'), :url => url_for_drilldown('duplicated_blocks'))%> + <%= format_variation('duplicated_blocks') if dashboard_configuration.selected_period? -%> + +
+ +
+ <%= message('widget.duplications.files.suffix') -%> + + <%= format_measure(measure('duplicated_files'), :url => url_for_drilldown('duplicated_files'))%> + <%= format_variation('duplicated_files') if dashboard_configuration.selected_period? -%> + +
+ +
+
+<% end %> diff --git a/server/sonar-server/src/main/resources/org/sonar/server/dashboard/widget/events.html.erb b/server/sonar-server/src/main/resources/org/sonar/server/dashboard/widget/events.html.erb new file mode 100644 index 00000000000..d6be1d2e667 --- /dev/null +++ b/server/sonar-server/src/main/resources/org/sonar/server/dashboard/widget/events.html.erb @@ -0,0 +1,120 @@ +<% + if @resource.scope=='PRJ' + + conditions = "component_uuid=:component_uuid" + values = {:component_uuid => @resource.uuid} + # in order to not display events linked to deleted snapshot, we build the SQL request with 'NOT IN' as most of the time, there won't be unprocessed snapshots + snapshots_to_be_deleted = Snapshot.find(:all, :conditions => ["status='U' AND project_id=?", @resource.id]) + unless snapshots_to_be_deleted.empty? + conditions << " AND snapshot_id NOT IN (:sids)" + values[:sids] = snapshots_to_be_deleted.map { |s| s.id } + end + + events=Event.find(:all, :conditions => [conditions, values], :order => 'event_date desc') + + categories = EventCategory.categories(true) +%> + + + + +

<%= message('widget.events.title') -%>    + + + + + +

+ + + + + + + + + +<% + events.each do |event| + categ = event.category + profile_data={} + if categ=='Profile' && event.event_data + profile_data=Hash[*(event.event_data.split(';').map { |elt| elt.split('=') }.flatten)] + end +%> + + + + + + +<% + end +%> + +
<%= l(event.event_date.to_date) %><%= h message('event.category.' + categ, :default => categ) %> + <%= link_to_if profile_data['key'] && profile_data['from'] && profile_data['to'], event.name, + :controller => 'profiles', :action => 'changelog', :key => profile_data['key'], + :since => profile_data['from'], :to => profile_data['to'] -%> + + <% unless event.description.blank? %> + + <% end %> +
+ +
+ <%= message('widget.events.no_event') -%> +
+ +<%= message('widget.events.show_all') -%> + + + +<% end %> diff --git a/server/sonar-server/src/main/resources/org/sonar/server/dashboard/widget/hotspot_metric.html.erb b/server/sonar-server/src/main/resources/org/sonar/server/dashboard/widget/hotspot_metric.html.erb new file mode 100644 index 00000000000..bf2872762d8 --- /dev/null +++ b/server/sonar-server/src/main/resources/org/sonar/server/dashboard/widget/hotspot_metric.html.erb @@ -0,0 +1,85 @@ +<% + metric = widget_properties["metric"] || Metric.by_key('ncloc') + + if measure(metric) + + limit = widget_properties["numberOfLines"] + title = widget_properties["title"] + title = message('widget.hotspot_metric.hotspots_by_x', :params => metric.short_name) if title.blank? + + snapshots = nil + if metric.numeric? && !@snapshot.leaves_qualifiers.empty? + snapshots_conditions=["snapshots.qualifier in (:qualifiers)", "snapshots.islast=:islast", "snapshots.status = 'P'"] + snapshots_values={:qualifiers => @snapshot.leaves_qualifiers, :islast => true} + snapshots_conditions << '(snapshots.root_snapshot_id=:root_sid AND snapshots.path LIKE :path)' + snapshots_values[:root_sid] = (@snapshot.root_snapshot_id || @snapshot.id) + snapshots_values[:path]="#{@snapshot.path}#{@snapshot.id}.%" + + measures_conditions = ["project_measures.rule_id IS NULL", "project_measures.characteristic_id IS NULL", "project_measures.person_id IS NULL"] + measures_values = {} + measures_conditions << "project_measures.metric_id = :m_id" + measures_values[:m_id] = metric.id + + measures=ProjectMeasure.find(:all, + :joins => :snapshot, + :conditions => [(snapshots_conditions + measures_conditions).join(' AND '), snapshots_values.merge(measures_values)], + :order => "project_measures.value #{'DESC' if metric.direction<0}", + :limit => limit) + + snapshots=Snapshot.find(measures.map { |m| m.snapshot_id }, :include => 'project') + snapshots_by_id = {} + snapshots.each do |s| + snapshots_by_id[s.id]=s + end + end + + unless snapshots && !snapshots.empty? %> +

<%= title -%>

+ <%= message('no_results') -%> + <% else %> + + + + + + + + + + <% + if metric.direction > 0 + metric_max_value = measures.last.value + else + metric_max_value = measures.first.value + end + measures.each do |measure| + resource = snapshots_by_id[measure.snapshot_id].resource + %> + + + + + + <% + end + %> + +
+
+ <%= link_to_resource(resource, h(resource.name), {:metric => metric.name, :class => 'underlined-link'}) -%> + + <%= format_measure(measure) -%> + +
+
+
+
+ + <% end %> + +<% end %> \ No newline at end of file diff --git a/server/sonar-server/src/main/resources/org/sonar/server/dashboard/widget/issue_filter.html.erb b/server/sonar-server/src/main/resources/org/sonar/server/dashboard/widget/issue_filter.html.erb new file mode 100644 index 00000000000..f70e79ec85b --- /dev/null +++ b/server/sonar-server/src/main/resources/org/sonar/server/dashboard/widget/issue_filter.html.erb @@ -0,0 +1,52 @@ +<% + container_id = 'widget-issue-filter-' + widget.id.to_s + filter_id = widget_properties['filter'] + filter = Internal.issues.findIssueFilterById(filter_id.to_i) + distribution_axis = widget_properties['distributionAxis'] + is_enough_permissions = filter.shared || (current_user && filter.userLogin == current_user.login) +%> + +<% if filter %> + + <% if is_enough_permissions %> + + <% @widget_title = " 'issues', :action => 'index'})}#id=#{filter.id}\">#{h(filter.name)}" %> + <% if widget_properties['displayFilterDescription'] && !filter.description.blank? %> +

<%= h filter.description -%>

+ <% end %> + +
+ + + <% else %> + +

<%= message 'widget.issue_filter.insufficient_privileges_warning' -%>

+ + <% end %> + +<% else %> + +

<%= message 'widget.issue_filter.unknown_filter_warning' -%>

+ +<% end %> diff --git a/server/sonar-server/src/main/resources/org/sonar/server/dashboard/widget/issue_tag_cloud.html.erb b/server/sonar-server/src/main/resources/org/sonar/server/dashboard/widget/issue_tag_cloud.html.erb new file mode 100644 index 00000000000..99012a289e5 --- /dev/null +++ b/server/sonar-server/src/main/resources/org/sonar/server/dashboard/widget/issue_tag_cloud.html.erb @@ -0,0 +1,61 @@ +<% + containerId = 'issue-tag-cloud' + widget.id.to_s + maxItems = widget_properties['maxItems'].to_i + + if has_role?(:user, @project) && !Internal.issues.listTagsForComponent(@project.uuid, maxItems).isEmpty() + search_options = { + 'resolved' => 'false' + } + if @project + search_options['componentUuids'] = @project.uuid + end + if @dashboard_configuration.selected_period? + search_options['createdAfter'] = @snapshot.period_datetime(@dashboard_configuration.period_index).strftime('%FT%T%z') + end + + title = message('widget.issue_tag_cloud.title') +%> + +
+ + + +

<%= title -%>

+ + +
+ + + + +<% end %> diff --git a/server/sonar-server/src/main/resources/org/sonar/server/dashboard/widget/issues.html.erb b/server/sonar-server/src/main/resources/org/sonar/server/dashboard/widget/issues.html.erb new file mode 100644 index 00000000000..0b2fe0c63f8 --- /dev/null +++ b/server/sonar-server/src/main/resources/org/sonar/server/dashboard/widget/issues.html.erb @@ -0,0 +1,205 @@ +<% + issues = @snapshot.measure('violations') + blocker_issues = @snapshot.measure('blocker_violations') + critical_issues = @snapshot.measure('critical_violations') + major_issues = @snapshot.measure('major_violations') + minor_issues = @snapshot.measure('minor_violations') + info_issues = @snapshot.measure('info_violations') + + new_issues = @snapshot.measure('new_violations') + new_blocker_issues = @snapshot.measure('new_blocker_violations') + new_critical_issues = @snapshot.measure('new_critical_violations') + new_major_issues = @snapshot.measure('new_major_violations') + new_minor_issues = @snapshot.measure('new_minor_violations') + new_info_issues = @snapshot.measure('new_info_violations') + + technical_debt = @snapshot.measure('sqale_index') + new_technical_debt = @snapshot.measure('new_technical_debt') + + if @dashboard_configuration.selected_period? + period_date = @snapshot.period_datetime(@dashboard_configuration.period_index).strftime('%FT%T%z') + end + + tooltip = message('widget.as_calculated_on_x', :params => l(@snapshot.created_at)) +%> + +
+ + <% if technical_debt %> +
+
+
+ <%= message('metric.sqale_index.short_name') -%> + + <%= format_measure(technical_debt) -%> + + <%= format_variation(technical_debt) if dashboard_configuration.selected_period? -%> +
+
+ <% + if @dashboard_configuration.selected_period? + technical_debt_variation = variation_value(technical_debt) + new_technical_debt_variation = variation_value(new_technical_debt) + estimated_cleared_technical_debt = (new_technical_debt_variation - technical_debt_variation).to_i if technical_debt_variation && new_technical_debt_variation + %> + <% if new_technical_debt_variation && new_technical_debt_variation > 0 %> +

+ <%= message('widget.rules.added') %> + +<%= format_variation(new_technical_debt, :style => 'none', :default => '-') -%> +

+ <% end %> + <% if estimated_cleared_technical_debt && estimated_cleared_technical_debt > 0 %> +

+ <%= message('widget.rules.removed') %> + -<%= Internal.i18n.formatLongDuration(estimated_cleared_technical_debt, 'SHORT') -%> +

+ <% end %> + <% end %> +
+
+
+ <% end %> + +
+
+ +
+ <% + if @dashboard_configuration.selected_period? + issues_variation = variation_value(issues) + new_issues_variation = variation_value(new_issues) + estimated_cleared_issues = (new_issues_variation - issues_variation).to_i if issues_variation && new_issues_variation + %> + <% if new_issues_variation && new_issues_variation > 0 %> +

+ <%= message('widget.rules.added') %> + +<%= format_variation(new_issues, :style => 'none', :default => '-') -%> +

+ <% end %> + <% if estimated_cleared_issues && estimated_cleared_issues > 0 %> +

+ <%= message('widget.rules.removed') %> + -<%= number_with_precision(estimated_cleared_issues, :precision => 0) -%> +

+ <% end %> + <% end %> +
+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + <%= message('blocker') -%> + + + <%= format_measure(blocker_issues) -%> + + + <% if @dashboard_configuration.selected_period? %> + +<%= format_variation(new_blocker_issues, :style => 'none', :default => '-') -%> + <% end %> +
+ + <%= message('critical') -%> + + + <%= format_measure(critical_issues) -%> + + + <% if @dashboard_configuration.selected_period? %> + +<%= format_variation(new_critical_issues, :style => 'none', :default => '-') -%> + <% end %> +
+ + <%= message('major') -%> + + + <%= format_measure(major_issues) -%> + + + <% if @dashboard_configuration.selected_period? %> + +<%= format_variation(new_major_issues, :style => 'none', :default => '-') -%> + <% end %> +
+ + <%= message('minor') -%> + + + <%= format_measure(minor_issues) -%> + + + <% if @dashboard_configuration.selected_period? %> + +<%= format_variation(new_minor_issues, :style => 'none', :default => '-') -%> + <% end %> +
+ + <%= message('info') -%> + + + <%= format_measure(info_issues) -%> + + + <% if @dashboard_configuration.selected_period? %> + +<%= format_variation(new_info_issues, :style => 'none', :default => '-') -%> + <% end %> +
+
+
diff --git a/server/sonar-server/src/main/resources/org/sonar/server/dashboard/widget/it_coverage.html.erb b/server/sonar-server/src/main/resources/org/sonar/server/dashboard/widget/it_coverage.html.erb new file mode 100644 index 00000000000..52c01fe6728 --- /dev/null +++ b/server/sonar-server/src/main/resources/org/sonar/server/dashboard/widget/it_coverage.html.erb @@ -0,0 +1,213 @@ +<% + it_coverage=measure('it_coverage') + overall_coverage=measure('overall_coverage') + + if it_coverage || overall_coverage +-%> +
+ + <% if it_coverage -%> +
+
+ +
+ <%= message('widget.it-coverage.name') -%> + + <%= format_measure(it_coverage, :url => url_for_drilldown('it_coverage'), :default => '-') %> + <%= format_variation(it_coverage) if dashboard_configuration.selected_period? -%> + +
+ + <% + it_line_coverage=measure('it_line_coverage') + if it_line_coverage + %> +
+ <%= message('widget.it-coverage.line_coverage.suffix') -%> + + <%= format_measure(it_line_coverage, :url => url_for_drilldown('it_uncovered_lines', :highlight => 'it_line_coverage')) %> + <%= format_variation(it_line_coverage) if dashboard_configuration.selected_period? -%> + +
+ <% end %> + + <% + it_branch_coverage=measure('it_branch_coverage') + if it_branch_coverage + %> +
+ <%= message('widget.it-coverage.condition_coverage.suffix') -%> + + <%= format_measure(it_branch_coverage, :url => url_for_drilldown('it_uncovered_conditions', :highlight => 'it_branch_coverage')) %> + <%= format_variation(it_branch_coverage) if dashboard_configuration.selected_period? -%> + +
+ <% end %> + + <% + if dashboard_configuration.selected_period? + new_lines_to_cover_measure=measure('new_it_lines_to_cover') + if new_lines_to_cover_measure + new_lines=new_lines_to_cover_measure.variation(dashboard_configuration.period_index) + if new_lines + new_coverage=measure('new_it_coverage') + new_line_coverage=measure('new_it_line_coverage') + new_branch_coverage=measure('new_it_branch_coverage') + %> + <% if new_lines.to_i==0 %> +
+ <%= message('widget.it-coverage.on_new_code') -%> + +

<%= message('widget.it-coverage.no_new_lines_to_cover') -%>

+
+ <% else %> + + <% if new_coverage %> +
+ <%= message('widget.it-coverage.on_new_code') -%> + + <%= format_measure(new_coverage, + :period => dashboard_configuration.period_index, + :url => url_for_drilldown(new_coverage, :period => dashboard_configuration.period_index), + :default => '-') %> + +
+ <% end %> + + <% if new_line_coverage %> +
+ <%= message('widget.it-coverage.line_coverage.suffix') -%> + + <%= format_measure(new_line_coverage, + :period => dashboard_configuration.period_index, + :url => url_for_drilldown(new_line_coverage, :period => dashboard_configuration.period_index)) %> + +
+ <% end %> + + <% if new_branch_coverage %> +
+ <%= message('widget.it-coverage.condition_coverage.suffix') -%> + + <%= format_measure(new_branch_coverage, + :period => dashboard_configuration.period_index, + :url => url_for_drilldown(new_branch_coverage, :period => dashboard_configuration.period_index)) %> + +
+ <% end %> + + <% end %> + + <% end %> + <% end %> + <% end %> + +
+
+ <% end %> + + <% if overall_coverage -%> +
+
+ +
+ <%= message('widget.overall-coverage.name') -%> + + <%= format_measure(overall_coverage, :url => url_for_drilldown('overall_coverage'), :default => '-') %> + <%= format_variation(overall_coverage) if dashboard_configuration.selected_period? -%> + +
+ + <% + overall_line_coverage=measure('overall_line_coverage') + if overall_line_coverage + %> +
+ <%= message('widget.overall-coverage.line_coverage.suffix') -%> + + <%= format_measure(overall_line_coverage, :url => url_for_drilldown('overall_uncovered_lines', :highlight => 'overall_line_coverage')) %> + <%= format_variation(overall_line_coverage) if dashboard_configuration.selected_period? -%> + +
+ <% end %> + + <% + overall_branch_coverage=measure('overall_branch_coverage') + if overall_branch_coverage + %> +
+ <%= message('widget.overall-coverage.condition_coverage.suffix') -%> + + <%= format_measure(overall_branch_coverage, :url => url_for_drilldown('overall_uncovered_conditions', :highlight => 'overall_branch_coverage')) %> + <%= format_variation(overall_branch_coverage) if dashboard_configuration.selected_period? -%> + +
+ <% end %> + + <% + if dashboard_configuration.selected_period? + new_lines_to_cover_measure=measure('new_overall_lines_to_cover') + if new_lines_to_cover_measure + new_lines=new_lines_to_cover_measure.variation(dashboard_configuration.period_index) + if new_lines + new_coverage=measure('new_overall_coverage') + new_line_coverage=measure('new_overall_line_coverage') + new_branch_coverage=measure('new_overall_branch_coverage') + %> + <% if new_lines.to_i==0 %> +
+ <%= message('widget.overall-coverage.on_new_code') -%> + +

<%= message('widget.overall-coverage.no_new_lines_to_cover') -%>

+
+ <% else %> + + <% if new_coverage %> +
+ <%= message('widget.overall-coverage.on_new_code') -%> + + <%= format_measure(new_coverage, + :period => dashboard_configuration.period_index, + :url => url_for_drilldown(new_coverage, :period => dashboard_configuration.period_index), + :default => '-') %> + <%= format_variation(new_coverage) if dashboard_configuration.selected_period? -%> + +
+ <% end %> + + <% if new_line_coverage %> +
+ <%= message('widget.overall-coverage.line_coverage.suffix') -%> + + <%= format_measure(new_line_coverage, + :period => dashboard_configuration.period_index, + :url => url_for_drilldown(new_line_coverage, :period => dashboard_configuration.period_index)) %> + <%= format_variation(new_line_coverage) if dashboard_configuration.selected_period? -%> + +
+ <% end %> + + <% if new_branch_coverage %> +
+ <%= message('widget.overall-coverage.condition_coverage.suffix') -%> + + <%= format_measure(new_branch_coverage, + :period => dashboard_configuration.period_index, + :url => url_for_drilldown(new_branch_coverage, :period => dashboard_configuration.period_index)) %> + <%= format_variation(new_branch_coverage) if dashboard_configuration.selected_period? -%> + +
+ <% end %> + + <% end %> + + <% end %> + <% end %> + <% end %> + +
+
+ <% end %> + +
+<% end %> diff --git a/server/sonar-server/src/main/resources/org/sonar/server/dashboard/widget/measure_filter_bubble_chart.html.erb b/server/sonar-server/src/main/resources/org/sonar/server/dashboard/widget/measure_filter_bubble_chart.html.erb new file mode 100644 index 00000000000..c5a23025495 --- /dev/null +++ b/server/sonar-server/src/main/resources/org/sonar/server/dashboard/widget/measure_filter_bubble_chart.html.erb @@ -0,0 +1,68 @@ +<% + containerId = 'bubble-chart-widget' + widget.id.to_s + chartTitle = widget_properties["chartTitle"] + chartHeight = widget_properties["chartHeight"] + filterId = widget_properties["filter"].to_i + xMetric = widget_properties["xMetric"] + yMetric = widget_properties["yMetric"] + sizeMetric = widget_properties["sizeMetric"] + xLog = !!widget_properties["xLogarithmic"] + yLog = !!widget_properties["yLogarithmic"] + maxItems = widget_properties["maxItems"].to_i + + filter = MeasureFilter.find_by_id(filterId.to_i) + if filter + @widget_title = link_to h(filter.name), {:controller => 'measures', :action => 'filter', :id => filter.id, :display => 'list'} +%> + +
+ + + + <% if chartTitle %> +

<%= h(chartTitle) -%>

+ <% end %> + +
+ + + + +<% else %> +

<%= image_tag 'warning.png' %> <%= message 'measure_filter.widget.unknown_filter_warning' -%>

+<% end %> diff --git a/server/sonar-server/src/main/resources/org/sonar/server/dashboard/widget/measure_filter_cloud.html.erb b/server/sonar-server/src/main/resources/org/sonar/server/dashboard/widget/measure_filter_cloud.html.erb new file mode 100644 index 00000000000..c45bb01cfcc --- /dev/null +++ b/server/sonar-server/src/main/resources/org/sonar/server/dashboard/widget/measure_filter_cloud.html.erb @@ -0,0 +1,59 @@ +<% + containerId = 'word-cloud' + widget.id.to_s + chartTitle = widget_properties['chartTitle'] + filterId = widget_properties['filter'].to_i + maxItems = widget_properties['maxItems'].to_i + + filter = MeasureFilter.find_by_id(filterId.to_i) + if filter + @widget_title = link_to h(filter.name), {:controller => 'measures', :action => 'filter', :id => filter.id, :display => 'list'} +%> + +
+ + + + <% if chartTitle %> +

<%= h(chartTitle) -%>

+ <% end %> + +
+ + + + +<% else %> +

<%= image_tag 'warning.png' %> <%= message 'measure_filter.widget.unknown_filter_warning' -%>

+<% end %> diff --git a/server/sonar-server/src/main/resources/org/sonar/server/dashboard/widget/measure_filter_histogram.html.erb b/server/sonar-server/src/main/resources/org/sonar/server/dashboard/widget/measure_filter_histogram.html.erb new file mode 100644 index 00000000000..98842071f46 --- /dev/null +++ b/server/sonar-server/src/main/resources/org/sonar/server/dashboard/widget/measure_filter_histogram.html.erb @@ -0,0 +1,62 @@ +<% + containerId = 'histogram-widget' + widget.id.to_s + chartTitle = widget_properties["chartTitle"] + filterId = widget_properties["filter"].to_i + maxItems = widget_properties["maxItems"].to_i + reverseOrder = widget_properties["reverseOrder"] + relativeScale = widget_properties["relativeScale"] + + filter = MeasureFilter.find_by_id(filterId.to_i) + if filter + @widget_title = link_to h(filter.name), {:controller => 'measures', :action => 'filter', :id => filter.id, :display => 'list'} +%> + +
+ + + + <% if chartTitle %> +

<%= h(chartTitle) -%>

+ <% end %> + +
+ + + + +<% else %> +

<%= image_tag 'warning.png' %> <%= message 'measure_filter.widget.unknown_filter_warning' -%>

+<% end %> diff --git a/server/sonar-server/src/main/resources/org/sonar/server/dashboard/widget/measure_filter_list.html.erb b/server/sonar-server/src/main/resources/org/sonar/server/dashboard/widget/measure_filter_list.html.erb new file mode 100644 index 00000000000..438c7f49d5b --- /dev/null +++ b/server/sonar-server/src/main/resources/org/sonar/server/dashboard/widget/measure_filter_list.html.erb @@ -0,0 +1,28 @@ +<% + filter_id = widget_properties['filter'] + page_size = widget_properties['pageSize'] + filter = MeasureFilter.find_by_id(filter_id.to_i) if filter_id + if filter + filter.load_criteria_from_data + if !filter.require_authentication? || logged_in? + filter.set_criteria_value('display', 'list') + filter.set_criteria_value('pageSize', page_size) + filter.execute(self, :user => current_user) + @widget_title = link_to h(filter.name), {:controller => 'measures', :action => 'filter', :id => filter.id} +%> + + <% if widget_properties['displayFilterDescription'] && !filter.description.blank? %> +
+ <%= h filter.description -%> +
+ <% end %> + + <%= render :partial => 'measures/display_list', :locals => {:edit_mode => false, :filter => filter, :widget_id => widget.id} -%> +<% + end + else +%> +

<%= image_tag 'warning.png' %> <%= message 'measure_filter.widget.unknown_filter_warning' -%>

+<% + end +%> diff --git a/server/sonar-server/src/main/resources/org/sonar/server/dashboard/widget/measure_filter_pie_chart.html.erb b/server/sonar-server/src/main/resources/org/sonar/server/dashboard/widget/measure_filter_pie_chart.html.erb new file mode 100644 index 00000000000..c011ede3f1d --- /dev/null +++ b/server/sonar-server/src/main/resources/org/sonar/server/dashboard/widget/measure_filter_pie_chart.html.erb @@ -0,0 +1,64 @@ +<% + containerId = 'pie-chart-widget' + widget.id.to_s + chartHeight = widget_properties["chartHeight"] + chartTitle = widget_properties["chartTitle"] + filterId = widget_properties["filter"].to_i + maxItems = widget_properties["maxItems"].to_i + + filter = MeasureFilter.find_by_id(filterId.to_i) + if filter + @widget_title = link_to h(filter.name), {:controller => 'measures', :action => 'filter', :id => filter.id, :display => 'list'} +%> + +
+ + + + <% if chartTitle %> +

<%= h(chartTitle) -%>

+ <% end %> + +
+ + + + +<% else %> +

<%= image_tag 'warning.png' %> <%= message 'measure_filter.widget.unknown_filter_warning' -%>

+<% end %> diff --git a/server/sonar-server/src/main/resources/org/sonar/server/dashboard/widget/measure_filter_treemap.html.erb b/server/sonar-server/src/main/resources/org/sonar/server/dashboard/widget/measure_filter_treemap.html.erb new file mode 100644 index 00000000000..48c08f864f2 --- /dev/null +++ b/server/sonar-server/src/main/resources/org/sonar/server/dashboard/widget/measure_filter_treemap.html.erb @@ -0,0 +1,67 @@ +<% + containerId = 'treemap-widget' + widget.id.to_s + chartTitle = widget_properties['chartTitle'] + filterId = widget_properties['filter'].to_i + maxItems = widget_properties['maxItems'].to_i + + # SONAR-2456 + # When metrics are removed, we have to manually set them to the default ones + colorMetric = widget_properties['colorMetric'] || Metric.by_key('coverage') + sizeMetric = widget_properties['sizeMetric'] || Metric.by_key('ncloc') + + filter = MeasureFilter.find_by_id(filterId.to_i) + if filter + @widget_title = link_to h(filter.name), {:controller => 'measures', :action => 'filter', :id => filter.id, :display => 'list'} +%> + +
+ + + + <% if chartTitle %> +

<%= h(chartTitle) -%>

+ <% end %> + +
+ + + + +<% else %> +

<%= image_tag 'warning.png' %> <%= message 'measure_filter.widget.unknown_filter_warning' -%>

+<% end %> diff --git a/server/sonar-server/src/main/resources/org/sonar/server/dashboard/widget/project_file_cloud.html.erb b/server/sonar-server/src/main/resources/org/sonar/server/dashboard/widget/project_file_cloud.html.erb new file mode 100644 index 00000000000..8cb1c029938 --- /dev/null +++ b/server/sonar-server/src/main/resources/org/sonar/server/dashboard/widget/project_file_cloud.html.erb @@ -0,0 +1,76 @@ +<% + containerId = 'project-file-widget' + widget.id.to_s + colorMetric = widget_properties['colorMetric'] + sizeMetric = widget_properties['sizeMetric'] + chartTitle = widget_properties['chartTitle'] + maxItems = widget_properties['maxItems'].to_i +%> + +
+ + + + <% if chartTitle %> +

<%= h(chartTitle) -%>

+ <% end %> + +
+ + + + diff --git a/server/sonar-server/src/main/resources/org/sonar/server/dashboard/widget/project_issue_filter.html.erb b/server/sonar-server/src/main/resources/org/sonar/server/dashboard/widget/project_issue_filter.html.erb new file mode 100644 index 00000000000..16edb8192d1 --- /dev/null +++ b/server/sonar-server/src/main/resources/org/sonar/server/dashboard/widget/project_issue_filter.html.erb @@ -0,0 +1,63 @@ +<% + container_id = 'widget-issue-filter-' + widget.id.to_s + filter_id = widget_properties['filter'] + filter = Internal.issues.findIssueFilterById(filter_id.to_i) + distribution_axis = widget_properties['distributionAxis'] + is_enough_permissions = filter.shared || (current_user && filter.userLogin == current_user.login) + + if @dashboard_configuration.selected_period? + period_date = @snapshot.period_datetime(@dashboard_configuration.period_index).strftime('%FT%T%z') + else + period_date = nil + end +%> + +<% if filter %> + + <% if is_enough_permissions %> + + <% @widget_title = " 'component_issues', :action => 'index'})}?id=#{u(@project.key)}##{filter.data}\">#{h(filter.name)}" %> + <% if widget_properties['displayFilterDescription'] && !filter.description.blank? %> +

<%= h filter.description -%>

+ <% end %> + +
+ + + <% else %> + +

<%= message 'widget.issue_filter.insufficient_privileges_warning' -%>

+ + <% end %> + +<% else %> + +

<%= message 'widget.issue_filter.unknown_filter_warning' -%>

+ +<% end %> diff --git a/server/sonar-server/src/main/resources/org/sonar/server/dashboard/widget/size.html.erb b/server/sonar-server/src/main/resources/org/sonar/server/dashboard/widget/size.html.erb new file mode 100644 index 00000000000..1a4387b1ecc --- /dev/null +++ b/server/sonar-server/src/main/resources/org/sonar/server/dashboard/widget/size.html.erb @@ -0,0 +1,195 @@ +<% + lines=measure('lines') + ncloc=measure('ncloc') + ncloc_language_distribution = measure('ncloc_language_distribution') + ncloc_language_dist_hash = Hash[*(ncloc_language_distribution.data.split(';').map { |elt| elt.split('=') }.flatten)] if ncloc && ncloc_language_distribution + generated_ncloc=measure('generated_ncloc') + generated_lines=measure('generated_lines') + accessors=measure('accessors') + classes=measure('classes') + files=measure('files') + directories=measure('directories') + functions=measure('functions') + projects=measure('projects') + if measure('lines') || ncloc + files=measure('files') + statements=measure('statements') + languages = Api::Utils.java_facade.getLanguages() +%> + +
+ +
+
+ <% if ncloc %> +

+ <%= message('metric.ncloc.name') -%> + + <%= format_measure(ncloc, :url => url_for_drilldown(ncloc)) %> + <%= format_variation(ncloc) if dashboard_configuration.selected_period? -%> + +

+ <% if generated_ncloc && generated_ncloc.value>0 %> +

+ <%= message('including_abbreviated') -%> + <%= format_measure(generated_ncloc, :url => url_for_drilldown(generated_ncloc)) -%> <%= format_variation(generated_ncloc) if dashboard_configuration.selected_period? -%> + <%= message('metric.generated_ncloc.name.suffix') -%> +

+ <% end %> + + <% if ncloc_language_dist_hash %> + <% if ncloc_language_dist_hash.size > 1 %> + + <% + max = Math.sqrt(ncloc_language_dist_hash.max_by{|_k,v| v.to_i}[1].to_i) + + # Sort lines language distribution by lines count + languages_by_key = Hash[languages.collect { |l| [l.getKey(), l.getName] }] + ncloc_language_dist_hash.sort {|v1,v2| v2[1].to_i <=> v1[1].to_i }.each do |language_key, language_ncloc| + %> + + + + + <% end %> +
+ <% if language_key.eql? '' %> + <%= message('unknown') -%> + <% else %> + <% language = languages.find { |l| l.getKey()==language_key.to_s } -%> + <%= language ? language.getName() : language_key -%> + <% end %> + + <%= ncloc.format_numeric_value(language_ncloc) %> +
+ + <% else %> + <% + language_key = ncloc_language_dist_hash.first[0] + if language_key.eql? '' %> + <%= message('unknown') -%> + <% else %> + <% language = languages.find { |l| l.getKey()==language_key.to_s } -%> + <%= language ? language.getName() : language_key -%> + <% end %> + <% end %> + <% end %> + <% else %> +

+ <%= message('metric.lines.name') -%> + + <%= format_measure(lines, :url => url_for_drilldown(ncloc)) %> + <%= format_variation(lines) if dashboard_configuration.selected_period? -%> + +

+ <% end %> +
+
+ +
+
+

+ <%= message('metric.files.name') -%> + + <%= format_measure(files, :url => url_for_drilldown(files)) %> + <%= format_variation(files) if dashboard_configuration.selected_period? -%> + +

+ + <% if directories %> +

+ <%= message('metric.directories.name') -%> + + <%= format_measure(directories, :url => url_for_drilldown(directories)) %> + <%= format_variation(directories) if dashboard_configuration.selected_period? -%> + +

+ <% end %> + +

+ <%= message('metric.lines.name') -%> + + <%= format_measure(lines, :url => url_for_drilldown(lines)) %> + <%= format_variation(lines) if dashboard_configuration.selected_period? -%> + +

+ + <% if generated_lines && generated_lines.value>0 %> +

+ <%= message('including_abbreviated') -%> + <%= format_measure(generated_lines, :url => url_for_drilldown(generated_lines)) -%> <%= format_variation(generated_lines) if dashboard_configuration.selected_period? -%> + <%= message('metric.generated_lines.name.suffix') -%> +

+ <% end %> + + <% if projects %> +

+ <%= message('projects') -%> + + <%= format_measure(projects) %> + <%= format_variation(projects) if dashboard_configuration.selected_period? -%> + +

+ <% end %> +
+
+ +
+
+ <% if functions %> +

+ <%= message('metric.functions.name') -%> + + <%= format_measure(functions, :url => url_for_drilldown(functions)) %> + <%= format_variation(functions) if dashboard_configuration.selected_period? -%> + +

+ <% end %> + + <% if classes %> +

+ <%= message('metric.classes.name') -%> + + <%= format_measure(classes, :url => url_for_drilldown(classes)) %> + <%= format_variation(classes) if dashboard_configuration.selected_period? -%> + +

+ <% end %> + + <% if statements %> +

+ <%= message('metric.statements.name') -%> + + <%= format_measure(statements, :url => url_for_drilldown(statements)) %> + <%= format_variation(statements) if dashboard_configuration.selected_period? -%> + +

+ <% end %> + + <% if accessors %> +

+ <%= message('metric.accessors.name') -%> + + <%= format_measure(accessors, :url => url_for_drilldown(accessors)) %> + <%= format_variation(accessors) if dashboard_configuration.selected_period? -%> + +

+ <% end %> +
+
+ +
+<% end %> diff --git a/server/sonar-server/src/main/resources/org/sonar/server/dashboard/widget/technical_debt_pyramid.html.erb b/server/sonar-server/src/main/resources/org/sonar/server/dashboard/widget/technical_debt_pyramid.html.erb new file mode 100644 index 00000000000..6f5464e92ea --- /dev/null +++ b/server/sonar-server/src/main/resources/org/sonar/server/dashboard/widget/technical_debt_pyramid.html.erb @@ -0,0 +1,156 @@ +<% + technical_debt = measure('sqale_index') + + root_characteristics = Internal.debt.characteristics().to_a + + should_display_diff_measures = dashboard_configuration.selected_period? && technical_debt.variation(dashboard_configuration.period_index)!=nil + if technical_debt.nil? || root_characteristics.empty? +%> + +

<%= message('widget.technical_debt_pyramid.name') -%>

+ <%= message('widget.technical_debt_pyramid.no_info_available') -%> + +<% + else +%> + + + + + + + + + + + + <% + measures_by_characteristic_id={} + ProjectMeasure.find(:all, + :conditions => ['characteristic_id IN (?) AND snapshot_id=? AND metric_id=?', + root_characteristics.map{|c| c.id}, @snapshot.id, technical_debt.metric().id]).each do |measure| + measures_by_characteristic_id[measure.characteristic_id]=measure + end + + total = technical_debt.value + cumulated=total + + if should_display_diff_measures + diff_by_characteristic_id={} + total_diff = 0; + root_characteristics.each do |c| + measure = measures_by_characteristic_id[c.id] + if measure && measure.variation(dashboard_configuration.period_index) + diff_by_characteristic_id[c.id] = measure.variation(dashboard_configuration.period_index) + total_diff += measure.variation(dashboard_configuration.period_index) + end + end + end + + root_characteristics.sort_by {|characteristic| characteristic.order}.each do |characteristic| + measure=measures_by_characteristic_id[characteristic.id] + value=(measure && measure.value ? measure.value : 0) + total_size=(total>0 ? (100*cumulated/total).round(3): 0) + value_size=(cumulated>0 ? (100*value/cumulated).round(3): 100) + drilldown_url = url_for_drilldown('sqale_index', :characteristic => characteristic.key) + %> + + + + + + + <% + cumulated-=value + end + %> + +
+

<%= message('widget.technical_debt_pyramid.name') -%>

+
+

 <%= message('widget.technical_debt_pyramid.technical_debt') -%>

+
+

<%= message('widget.technical_debt_pyramid.total') -%>

+
<%= h(characteristic.name) -%> + +
+
+
+
+
+ <%= Internal.i18n.formatLongDuration(value.to_i, 'SHORT') -%> + <% if should_display_diff_measures %> + <% if diff_by_characteristic_id[characteristic.id] %> + <%= format_variation(measure) -%> + <% else %> + (+0) + <% end %> + <% end %> + + <%= Internal.i18n.formatLongDuration(cumulated.to_i, 'SHORT') -%> + <% + if should_display_diff_measures + css_style = 'var' + css_style += 'b' if total_diff < 0 + css_style += 'w' if total_diff > 0 + diff_to_display = (total_diff < 0 ? '' : '+') + Internal.i18n.formatLongDuration(total_diff.to_i, 'SHORT') + %> + (<%= diff_to_display -%>) + <% + total_diff -= diff_by_characteristic_id[characteristic.id] if diff_by_characteristic_id[characteristic.id] + end + %> +
+ +<% end %> diff --git a/server/sonar-server/src/main/resources/org/sonar/server/dashboard/widget/time_machine.html.erb b/server/sonar-server/src/main/resources/org/sonar/server/dashboard/widget/time_machine.html.erb new file mode 100644 index 00000000000..3c00988eae9 --- /dev/null +++ b/server/sonar-server/src/main/resources/org/sonar/server/dashboard/widget/time_machine.html.erb @@ -0,0 +1,130 @@ +<% + rows_by_metric_id={} + + # Retrieve widget settings + metric_ids = [] + (1..10).each do |index| + metric=widget_properties["metric#{index}"] + if metric + metric_ids << metric.id + row=Sonar::TimemachineRow.new(metric) + rows_by_metric_id[metric.id]=row + end + end + if metric_ids.empty? + # No metric has been selected, it's the first time the widget is displayed: 'ncloc' is the default metric + ncloc = Metric.find(:first, :conditions => "name = 'ncloc'") + metric_ids << ncloc.id + end + number_of_columns = widget_properties["numberOfColumns"] + + # Retrieve the measures for each metric on each snapshot + options = {} + from_date = dashboard_configuration.from_datetime + if from_date + options[:from] = from_date + end + snapshots=Snapshot.for_timemachine_widget(@resource, number_of_columns, options) + sids = snapshots.collect { |s| s.id }.uniq + measures=ProjectMeasure.find(:all, + :conditions => + ["snapshot_id IN (:snapshot_id) AND metric_id IN (:metric_id) AND rule_id IS NULL AND characteristic_id IS NULL AND person_id IS NULL", + {:snapshot_id => sids, :metric_id => metric_ids} + ] + ) + + + # Prepare the rows to display + snapshot_by_id={} + snapshots.each do |s| + snapshot_by_id[s.id]=s + end + measures.each do |measure| + next unless measure.metric + + if measure.metric.timemachine? && (measure.value || measure.text_value) + row=rows_by_metric_id[measure.metric_id] + + #optimization : avoid eager loading of snapshots + measure.snapshot=snapshot_by_id[measure.snapshot_id] + row.add_measure(measure) + end + end + + # Create the list of rows to display in the same order as defined by the user + rows=[] + metric_ids.each do |metric_id| + row = rows_by_metric_id[metric_id] + if row + rows< + +<% if widget_properties["title"] %> +
+

<%= h(widget_properties["title"]) -%>

+
+<% end %> + +
+ + + + + + <% + snapshots.each do |snapshot| + event = snapshot.event('Version') + %> + + <% end %> + <% if display_sparkline %> + + <% end %> + + + + + <% + rows.select { |row| row.metric.val_type != Metric::VALUE_TYPE_DISTRIB }.each do |row| + %> + + + <% + snapshots.each do |snapshot| + measure=row.measure(snapshot) + %> + + <% end %> + <% + if display_sparkline + sparkline_url = sparkline_urls_by_row[row] + %> + + <% end %> + + <% end %> + + +
+ <%= l snapshot.created_at.to_date -%> +
+ <%= event.name unless event==nil -%> +
+ <%= row.metric.short_name %> + <%= format_measure(measure, :skip_span_id => true) %> + <%= image_tag(sparkline_url) if sparkline_url %> +
+ +
diff --git a/server/sonar-server/src/main/resources/org/sonar/server/dashboard/widget/timeline.html.erb b/server/sonar-server/src/main/resources/org/sonar/server/dashboard/widget/timeline.html.erb new file mode 100644 index 00000000000..7e7ad6ec44f --- /dev/null +++ b/server/sonar-server/src/main/resources/org/sonar/server/dashboard/widget/timeline.html.erb @@ -0,0 +1,193 @@ +<% + # Retrieve widget settings + metric_data_map = {} + metric_map = {} + metrics_specified = false + (1..3).each do |index| + metric=widget_properties["metric#{index}"] + # we check that the current resource has the selected metric on the last snapshot + # => if not, we do not display this metric at all + if metric + metrics_specified = true + if measure(metric) + metric_data_map[metric.id] = [] + metric_map[metric.id] = metric + end + end + end + unless metrics_specified + # No metric has been selected, it's the first time the widget is displayed: 'ncloc' is the default metric + ncloc = Metric.by_name('ncloc') + metric_data_map[ncloc.id] = [] + metric_map[ncloc.id] = ncloc + end + chartHeight = widget_properties["chartHeight"] + + unless metric_data_map.values.empty? + # Retrieve metric trend information + options = {} + from_date = dashboard_configuration.from_datetime + if from_date + options[:from] = from_date + end + metric_count_per_snapshot_id = {} + TrendsChart.time_machine_measures(@resource, metric_data_map.keys, options).each() do |trend_item| + sid = trend_item["sid"] + if metric_count_per_snapshot_id[sid] + metric_count_per_snapshot_id[sid] += 1 + else + metric_count_per_snapshot_id[sid] = 1 + end + metric_data_map[trend_item["metric_id"].to_i] << {:date => Time.at(trend_item["created_at"].to_i/1000), :value => trend_item["value"], :sid => trend_item["sid"]} + end + + # Create JS structures to print out in the HTML page + js_data = "[" + js_snapshots = "[" + js_metrics = "[" + total_number_of_metrics = metric_map.keys.size() + metric_data_map.keys.each_with_index() do |metric_id, index| + unless metric_data_map[metric_id].empty? + js_metrics += "\"" + metric_map[metric_id].short_name + "\"," + js_data += "[" + metric_data_map[metric_id].each() do |metric_data| + # for every metric value, we need to check that the corresponding snapshot has values for each metric + if metric_count_per_snapshot_id[metric_data[:sid]]==total_number_of_metrics + m_date = metric_data[:date] + m_value = sprintf("%0.02f", metric_data[:value]) + m_value_localized = ProjectMeasure.new(:metric => metric_map[metric_id]).format_numeric_value(metric_data[:value], {}) + js_data += "{x:d(" + js_data += m_date.year.to_s + js_data += "," + # Need to decrease by 1 the month as the JS Date object start months at 0 (= January) + js_data += (m_date.month - 1).to_s + js_data += "," + js_data += m_date.day.to_s + js_data += "," + js_data += m_date.hour.to_s + js_data += "," + js_data += m_date.min.to_s + js_data += "," + js_data += m_date.sec.to_s + js_data += "),y:" + js_data += m_value + js_data += ",yl:\"" + js_data += m_value_localized + js_data += "\"}," + if index == 0 + # we fill the js_snapshots array (no need to do this more than once) + js_snapshots += "{sid:" + js_snapshots += metric_data[:sid].to_s + js_snapshots += ",d:\"" + js_snapshots += human_short_date m_date + js_snapshots += "\"}," + end + end + end + js_data = js_data.chomp(',') + "]," + end + end + js_data = js_data.chomp(',') + "]" + js_snapshots = js_snapshots.chomp(',') + "]" + js_metrics = js_metrics.chomp(',') + "]" + + # Prepare also event structure if required + unless widget_properties["hideEvents"] + events = {} + unless from_date + # find the oldest date + metric_data_map.values.each() do |metric_data_array| + first_date = metric_data_array[0][:date] + from_date = first_date if !from_date || from_date > first_date + end + end + Event.find(:all, :conditions => ["component_uuid=? AND event_date>=?", @resource.uuid, from_date.to_i*1000], :order => 'event_date').each() do |event| + if events[event.event_date] + events[event.event_date] << event + else + date_entry = [event] + events[event.event_date] = date_entry + end + end + js_events = "[" + events.keys().sort.each() do |e_date| + e_details = events[e_date] + js_events += "{sid:" + js_events += e_details[0].snapshot_id.to_s + js_events += ",d:d(" + js_events += e_date.year.to_s + js_events += "," + # Need to decrease by 1 the month as the JS Date object start months at 0 (= January) + js_events += (e_date.month - 1).to_s + js_events += "," + js_events += e_date.day.to_s + js_events += "," + js_events += e_date.hour.to_s + js_events += "," + js_events += e_date.min.to_s + js_events += "," + js_events += e_date.sec.to_s + js_events += "),l:[" + e_details.each() do |e| + js_events += "{n:\"" + js_events += json_escape(e.name) + js_events += "\"}," + end + js_events = js_events.chomp(',') + "]}," + end + js_events = js_events.chomp(',') + "]" + end + end + + +%> + + + + +<% if widget_properties["chartTitle"] %> +

<%= h(widget_properties["chartTitle"]) -%>

+<% end %> + + + + +<% + unless metric_data_map.values.empty? + + if metric_data_map.values[0].size == 1 +%> + + <%= message('widget.timeline.timeline_not_displayed') -%> + +<% else %> + <% timeline = 'timeline' + widget.id.to_s %> + +
+ + +<% + end + end +%> + diff --git a/server/sonar-server/src/main/resources/org/sonar/server/dashboard/widget/treemap.html.erb b/server/sonar-server/src/main/resources/org/sonar/server/dashboard/widget/treemap.html.erb new file mode 100644 index 00000000000..f6a1fbc2b6b --- /dev/null +++ b/server/sonar-server/src/main/resources/org/sonar/server/dashboard/widget/treemap.html.erb @@ -0,0 +1,85 @@ +<% + containerId = 'project-file-widget' + widget.id.to_s + colorMetric = widget_properties['colorMetric'] + sizeMetric = widget_properties['sizeMetric'] + chartTitle = widget_properties['chartTitle'] + maxItems = widget_properties['maxItems'].to_i +%> + +
+ + + + <% if chartTitle %> +

<%= h(chartTitle) -%>

+ <% end %> + +
+ + + + diff --git a/server/sonar-server/src/main/resources/org/sonar/server/dashboard/widget/welcome.html.erb b/server/sonar-server/src/main/resources/org/sonar/server/dashboard/widget/welcome.html.erb new file mode 100644 index 00000000000..a3e651d4f03 --- /dev/null +++ b/server/sonar-server/src/main/resources/org/sonar/server/dashboard/widget/welcome.html.erb @@ -0,0 +1 @@ +<%= message('widget.welcome.html') -%> \ No newline at end of file diff --git a/server/sonar-server/src/test/java/org/sonar/server/charts/AbstractChartTest.java b/server/sonar-server/src/test/java/org/sonar/server/charts/AbstractChartTest.java new file mode 100644 index 00000000000..e1110fa24e8 --- /dev/null +++ b/server/sonar-server/src/test/java/org/sonar/server/charts/AbstractChartTest.java @@ -0,0 +1,99 @@ +/* + * SonarQube, open source software quality management tool. + * Copyright (C) 2008-2014 SonarSource + * mailto:contact AT sonarsource DOT com + * + * SonarQube 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. + * + * SonarQube 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 this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.charts; + +import org.apache.commons.io.FileUtils; +import org.jfree.chart.ChartUtilities; +import org.jfree.ui.ApplicationFrame; +import org.jfree.ui.RefineryUtilities; + +import javax.swing.JPanel; + +import java.awt.Dimension; +import java.awt.Graphics; +import java.awt.image.BufferedImage; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.OutputStream; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Date; + +import static org.junit.Assert.assertTrue; + +public abstract class AbstractChartTest { + protected void assertChartSizeGreaterThan(BufferedImage img, int size) throws IOException { + ByteArrayOutputStream output = new ByteArrayOutputStream(); + ChartUtilities.writeBufferedImageAsPNG(output, img); + assertTrue("PNG size in bits=" + output.size(), output.size() > size); + } + + protected void assertChartSizeLesserThan(BufferedImage img, int size) throws IOException { + ByteArrayOutputStream output = new ByteArrayOutputStream(); + ChartUtilities.writeBufferedImageAsPNG(output, img); + assertTrue("PNG size in bits=" + output.size(), output.size() < size); + } + + protected void saveChart(BufferedImage img, String name) throws IOException { + File target = new File("target/tmp-chart", name); + FileUtils.forceMkdir(target.getParentFile()); + ByteArrayOutputStream imgOutput = new ByteArrayOutputStream(); + ChartUtilities.writeBufferedImageAsPNG(imgOutput, img); + OutputStream out = new FileOutputStream(target); + out.write(imgOutput.toByteArray()); + out.close(); + + } + + protected static void displayTestPanel(BufferedImage image) { + ApplicationFrame frame = new ApplicationFrame("testframe"); + BufferedPanel imgPanel = new BufferedPanel(image); + frame.setContentPane(imgPanel); + frame.pack(); + RefineryUtilities.centerFrameOnScreen(frame); + frame.setVisible(true); + } + + protected static Date stringToDate(String sDate) throws ParseException { + SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yy hh'h'mm"); + return sdf.parse(sDate); + } + + private static class BufferedPanel extends JPanel { + private final BufferedImage chartImage; + + public BufferedPanel(BufferedImage chartImage) { + this.chartImage = chartImage; + } + + @Override + protected void paintComponent(Graphics graphics) { + super.paintComponent(graphics); + graphics.drawImage(chartImage, 0, 0, null); + } + + @Override + public Dimension getPreferredSize() { + return new Dimension(chartImage.getWidth(), chartImage.getHeight()); + } + } +} diff --git a/server/sonar-server/src/test/java/org/sonar/server/charts/DistributionAreaChartTest.java b/server/sonar-server/src/test/java/org/sonar/server/charts/DistributionAreaChartTest.java new file mode 100644 index 00000000000..0d40c7031a5 --- /dev/null +++ b/server/sonar-server/src/test/java/org/sonar/server/charts/DistributionAreaChartTest.java @@ -0,0 +1,62 @@ +/* + * SonarQube, open source software quality management tool. + * Copyright (C) 2008-2014 SonarSource + * mailto:contact AT sonarsource DOT com + * + * SonarQube 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. + * + * SonarQube 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 this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.charts; + +import org.junit.Test; +import org.sonar.api.charts.ChartParameters; + +import java.awt.image.BufferedImage; +import java.io.IOException; + +public class DistributionAreaChartTest extends AbstractChartTest { + + @Test + public void oneSerie() throws IOException { + DistributionAreaChart chart = new DistributionAreaChart(); + BufferedImage image = chart.generateImage(new ChartParameters("v=0%3D5%3B1%3D22%3B2%3D2")); + assertChartSizeGreaterThan(image, 1000); + saveChart(image, "DistributionAreaChartTest/oneSerie.png"); + } + + @Test + public void manySeries() throws IOException { + DistributionAreaChart chart = new DistributionAreaChart(); + BufferedImage image = chart.generateImage(new ChartParameters("v=0%3D5%3B1%3D22%3B2%3D2|0%3D7%3B1%3D15%3B2%3D4")); + assertChartSizeGreaterThan(image, 1000); + saveChart(image, "DistributionAreaChartTest/manySeries.png"); + } + + @Test + public void manySeriesWithDifferentCategories() throws IOException { + DistributionAreaChart chart = new DistributionAreaChart(); + BufferedImage image = chart.generateImage(new ChartParameters("v=0%3D5%3B1%3D22%3B2%3D2|2%3D7%3B4%3D15%3B9%3D4")); + assertChartSizeGreaterThan(image, 1000); + saveChart(image, "DistributionAreaChartTest/manySeriesWithDifferentCategories.png"); + } + + @Test + public void manySeriesIncludingAnEmptySerie() throws IOException { + // the third serie should not have the second default color, but the third one ! + DistributionAreaChart chart = new DistributionAreaChart(); + BufferedImage image = chart.generateImage(new ChartParameters("v=0%3D5%3B1%3D22%3B2%3D2||2%3D7%3B4%3D15%3B9%3D4")); + assertChartSizeGreaterThan(image, 1000); + saveChart(image, "DistributionAreaChartTest/manySeriesIncludingAnEmptySerie.png"); + } +} diff --git a/server/sonar-server/src/test/java/org/sonar/server/charts/DistributionBarChartTest.java b/server/sonar-server/src/test/java/org/sonar/server/charts/DistributionBarChartTest.java new file mode 100644 index 00000000000..55dd0f4a100 --- /dev/null +++ b/server/sonar-server/src/test/java/org/sonar/server/charts/DistributionBarChartTest.java @@ -0,0 +1,89 @@ +/* + * SonarQube, open source software quality management tool. + * Copyright (C) 2008-2014 SonarSource + * mailto:contact AT sonarsource DOT com + * + * SonarQube 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. + * + * SonarQube 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 this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.charts; + +import org.junit.Test; +import org.sonar.api.charts.ChartParameters; + +import java.awt.image.BufferedImage; +import java.io.IOException; + +public class DistributionBarChartTest extends AbstractChartTest { + DistributionBarChart chart = new DistributionBarChart(); + + @Test + public void simpleSample() throws IOException { + BufferedImage image = chart.generateImage(new ChartParameters("v=0%3D5%3B1%3D22%3B2%3D2")); + assertChartSizeGreaterThan(image, 1000); + saveChart(image, "DistributionBarChartTest/simpleSample.png"); + } + + @Test + public void addXSuffix() throws IOException { + // should suffix x labels with + + BufferedImage image = chart.generateImage(new ChartParameters("v=0%3D5%3B1%3D22%3B2%3D2&xsuf=%2B")); + assertChartSizeGreaterThan(image, 1000); + saveChart(image, "DistributionBarChartTest/addXSuffix.png"); + } + + @Test + public void addYSuffix() throws IOException { + // should suffix y labels with % + BufferedImage image = chart.generateImage(new ChartParameters("v=0%3D5%3B1%3D22%3B2%3D2&ysuf=%25")); + assertChartSizeGreaterThan(image, 1000); + saveChart(image, "DistributionBarChartTest/addYSuffix.png"); + } + + @Test + public void manySeries() throws IOException { + BufferedImage image = chart.generateImage(new ChartParameters("v=0%3D5%3B1%3D22%3B2%3D2|0%3D7%3B1%3D15%3B2%3D4")); + assertChartSizeGreaterThan(image, 1000); + saveChart(image, "DistributionBarChartTest/manySeries.png"); + } + + @Test + public void manySeriesIncludingAnEmptySerie() throws IOException { + // the third serie should not have the second default color, but the third one ! + BufferedImage image = chart.generateImage(new ChartParameters("v=0%3D5%3B1%3D22%3B2%3D2||0%3D7%3B1%3D15%3B2%3D4")); + assertChartSizeGreaterThan(image, 1000); + saveChart(image, "DistributionBarChartTest/manySeriesIncludingAnEmptySerie.png"); + } + + @Test + public void overridenSize() throws IOException { + BufferedImage image = chart.generateImage(new ChartParameters("v=0%3D5%3B1%3D22%3B2%3D2|0%3D7%3B1%3D15%3B2%3D4&w=500&h=200")); + assertChartSizeGreaterThan(image, 1000); + saveChart(image, "DistributionBarChartTest/overridenSize.png"); + } + + @Test + public void changeColor() throws IOException { + BufferedImage image = chart.generateImage(new ChartParameters("v=0%3D5%3B1%3D22%3B2%3D2&c=777777&bgc=777777")); + assertChartSizeGreaterThan(image, 1000); + saveChart(image, "DistributionBarChartTest/changeColor.png"); + } + + @Test + public void smallSize() throws IOException { + BufferedImage image = chart.generateImage(new ChartParameters("v=0%3D5%3B1%3D22%3B2%3D2%3B4%3D22%3B5%3D22%3B6%3D22&c=777777&w=120&h=80&fs=8")); + assertChartSizeGreaterThan(image, 500); + saveChart(image, "DistributionBarChartTest/smallSize.png"); + } +} diff --git a/server/sonar-server/src/test/java/org/sonar/server/dashboard/template/GlobalDefaultDashboardTest.java b/server/sonar-server/src/test/java/org/sonar/server/dashboard/template/GlobalDefaultDashboardTest.java new file mode 100644 index 00000000000..f9f784bd830 --- /dev/null +++ b/server/sonar-server/src/test/java/org/sonar/server/dashboard/template/GlobalDefaultDashboardTest.java @@ -0,0 +1,90 @@ +/* + * SonarQube, open source software quality management tool. + * Copyright (C) 2008-2014 SonarSource + * mailto:contact AT sonarsource DOT com + * + * SonarQube 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. + * + * SonarQube 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 this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.dashboard.template; + +import java.util.List; +import org.junit.Before; +import org.junit.Test; +import org.sonar.api.web.Dashboard; +import org.sonar.api.web.Dashboard.Widget; +import org.sonar.core.measure.db.MeasureFilterDao; +import org.sonar.core.measure.db.MeasureFilterDto; +import org.sonar.server.dashboard.widget.MeasureFilterAsTreemapWidget; +import org.sonar.server.dashboard.widget.MeasureFilterListWidget; +import org.sonar.server.dashboard.widget.WelcomeWidget; +import org.sonar.server.measure.template.MyFavouritesFilter; +import org.sonar.server.measure.template.ProjectFilter; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +public class GlobalDefaultDashboardTest { + GlobalDefaultDashboard template; + MeasureFilterDao dao; + + @Before + public void init() { + dao = mock(MeasureFilterDao.class); + template = new GlobalDefaultDashboard(dao); + } + + @Test + public void should_have_a_name() { + assertThat(template.getName()).isEqualTo("Home"); + } + + @Test + public void should_create_global_dashboard_with_four_widgets() { + when(dao.findSystemFilterByName(MyFavouritesFilter.NAME)).thenReturn( + new MeasureFilterDto().setId(100L) + ); + when(dao.findSystemFilterByName(ProjectFilter.NAME)).thenReturn( + new MeasureFilterDto().setId(101L) + ); + Dashboard dashboard = template.createDashboard(); + List firstColumn = dashboard.getWidgetsOfColumn(1); + assertThat(firstColumn).hasSize(2); + assertThat(firstColumn.get(0).getId()).isEqualTo(WelcomeWidget.ID); + assertThat(firstColumn.get(1).getId()).isEqualTo(MeasureFilterListWidget.ID); + assertThat(firstColumn.get(1).getProperty("filter")).isEqualTo("100"); + + List secondColumn = dashboard.getWidgetsOfColumn(2); + assertThat(secondColumn).hasSize(2); + assertThat(secondColumn.get(0).getId()).isEqualTo(MeasureFilterListWidget.ID); + assertThat(secondColumn.get(0).getProperty("filter")).isEqualTo("101"); + assertThat(secondColumn.get(1).getId()).isEqualTo(MeasureFilterAsTreemapWidget.ID); + assertThat(secondColumn.get(1).getProperty("filter")).isEqualTo("101"); + } + + @Test + public void should_not_fail_if_filter_widgets_not_found() { + when(dao.findSystemFilterByName(MyFavouritesFilter.NAME)).thenReturn(null); + when(dao.findSystemFilterByName(ProjectFilter.NAME)).thenReturn(null); + + Dashboard dashboard = template.createDashboard(); + List firstColumn = dashboard.getWidgetsOfColumn(1); + assertThat(firstColumn).hasSize(1); + assertThat(firstColumn.get(0).getId()).isEqualTo(WelcomeWidget.ID); + + List secondColumn = dashboard.getWidgetsOfColumn(2); + assertThat(secondColumn).isEmpty(); + } +} diff --git a/server/sonar-server/src/test/java/org/sonar/server/dashboard/template/ProjectDefaultDashboardTest.java b/server/sonar-server/src/test/java/org/sonar/server/dashboard/template/ProjectDefaultDashboardTest.java new file mode 100644 index 00000000000..2050d5c78c5 --- /dev/null +++ b/server/sonar-server/src/test/java/org/sonar/server/dashboard/template/ProjectDefaultDashboardTest.java @@ -0,0 +1,43 @@ +/* + * SonarQube, open source software quality management tool. + * Copyright (C) 2008-2014 SonarSource + * mailto:contact AT sonarsource DOT com + * + * SonarQube 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. + * + * SonarQube 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 this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.dashboard.template; + +import org.junit.Test; +import org.sonar.api.web.Dashboard; +import org.sonar.api.web.DashboardLayout; + +import static org.assertj.core.api.Assertions.assertThat; + +public class ProjectDefaultDashboardTest { + ProjectDefaultDashboard template = new ProjectDefaultDashboard(); + + @Test + public void should_have_a_name() { + assertThat(template.getName()).isEqualTo("Dashboard"); + } + + @Test + public void should_create_dashboard() { + Dashboard dashboard = template.createDashboard(); + + assertThat(dashboard.getLayout()).isEqualTo(DashboardLayout.TWO_COLUMNS); + assertThat(dashboard.getWidgets()).hasSize(9); + } +} diff --git a/server/sonar-server/src/test/java/org/sonar/server/dashboard/template/ProjectIssuesDashboardTest.java b/server/sonar-server/src/test/java/org/sonar/server/dashboard/template/ProjectIssuesDashboardTest.java new file mode 100644 index 00000000000..b84c0a00ae1 --- /dev/null +++ b/server/sonar-server/src/test/java/org/sonar/server/dashboard/template/ProjectIssuesDashboardTest.java @@ -0,0 +1,71 @@ +/* + * SonarQube, open source software quality management tool. + * Copyright (C) 2008-2014 SonarSource + * mailto:contact AT sonarsource DOT com + * + * SonarQube 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. + * + * SonarQube 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 this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +package org.sonar.server.dashboard.template; + +import org.junit.Before; +import org.junit.ClassRule; +import org.junit.Test; +import org.junit.experimental.categories.Category; +import org.sonar.api.web.Dashboard; +import org.sonar.api.web.DashboardLayout; +import org.sonar.core.issue.db.IssueFilterDao; +import org.sonar.core.persistence.DbTester; +import org.sonar.test.DbTests; + +import static org.assertj.core.api.Assertions.assertThat; + +@Category(DbTests.class) +public class ProjectIssuesDashboardTest { + + @ClassRule + public static final DbTester dbTester = new DbTester(); + + ProjectIssuesDashboard template; + + @Before + public void setUp() { + IssueFilterDao issueFilterDao = new IssueFilterDao(dbTester.myBatis()); + template = new ProjectIssuesDashboard(issueFilterDao); + } + + @Test + public void should_have_a_name() { + assertThat(template.getName()).isEqualTo("Issues"); + } + + @Test + public void should_create_dashboard() { + dbTester.prepareDbUnit(getClass(), "filters.xml"); + Dashboard dashboard = template.createDashboard(); + + assertThat(dashboard.getLayout()).isEqualTo(DashboardLayout.TWO_COLUMNS); + assertThat(dashboard.getWidgets()).hasSize(5); + } + + @Test + public void should_provide_clean_error_message_on_failure() { + try { + template.createDashboard(); + } catch (IllegalStateException illegalState) { + assertThat(illegalState).hasMessage("Could not find a provided issue filter with name 'Unresolved Issues'"); + } + } +} diff --git a/server/sonar-server/src/test/java/org/sonar/server/dashboard/template/ProjectTimeMachineDashboardTest.java b/server/sonar-server/src/test/java/org/sonar/server/dashboard/template/ProjectTimeMachineDashboardTest.java new file mode 100644 index 00000000000..84f96ed662d --- /dev/null +++ b/server/sonar-server/src/test/java/org/sonar/server/dashboard/template/ProjectTimeMachineDashboardTest.java @@ -0,0 +1,50 @@ +/* + * SonarQube, open source software quality management tool. + * Copyright (C) 2008-2014 SonarSource + * mailto:contact AT sonarsource DOT com + * + * SonarQube 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. + * + * SonarQube 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 this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.dashboard.template; + +import org.junit.Test; +import org.sonar.api.web.Dashboard; +import org.sonar.api.web.Dashboard.Widget; +import org.sonar.api.web.DashboardLayout; + +import static org.assertj.core.api.Assertions.assertThat; + +public class ProjectTimeMachineDashboardTest { + ProjectTimeMachineDashboard template = new ProjectTimeMachineDashboard(); + + @Test + public void should_have_a_name() { + assertThat(template.getName()).isEqualTo("TimeMachine"); + } + + @Test + public void should_create_dashboard() { + Dashboard dashboard = template.createDashboard(); + + assertThat(dashboard.getLayout()).isEqualTo(DashboardLayout.TWO_COLUMNS); + assertThat(dashboard.getWidgets()).hasSize(7); + + for (Widget widget : dashboard.getWidgets()) { + if (widget.getId().equals("time_machine")) { + assertThat(widget.getProperty("displaySparkLine")).isEqualTo("true"); + } + } + } +} diff --git a/server/sonar-server/src/test/java/org/sonar/server/dashboard/widget/CoreWidgetsTest.java b/server/sonar-server/src/test/java/org/sonar/server/dashboard/widget/CoreWidgetsTest.java new file mode 100644 index 00000000000..bc15edfa8c9 --- /dev/null +++ b/server/sonar-server/src/test/java/org/sonar/server/dashboard/widget/CoreWidgetsTest.java @@ -0,0 +1,102 @@ +/* + * SonarQube, open source software quality management tool. + * Copyright (C) 2008-2014 SonarSource + * mailto:contact AT sonarsource DOT com + * + * SonarQube 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. + * + * SonarQube 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 this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.dashboard.widget; + +import com.google.common.base.Function; +import com.google.common.base.Throwables; +import com.google.common.collect.Collections2; +import com.google.common.collect.Iterables; +import com.google.common.collect.Sets; +import java.util.Collection; +import java.util.Set; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; +import org.junit.Test; +import org.reflections.Reflections; + +import static com.google.common.collect.Lists.newArrayList; +import static org.assertj.core.api.Assertions.assertThat; + +public class CoreWidgetsTest { + + @Test + public void widget_ids_should_be_unique() { + Collection widgets = widgets(); + Collection widgetIds = Collections2.transform(widgets, new Function() { + public String apply(@Nonnull CoreWidget widget) { + return widget.getId(); + } + }); + assertThat(widgetIds).hasSize(Sets.newHashSet(widgetIds).size()); + } + + @Test + public void widget_templates_should_be_unique() { + Collection widgets = widgets(); + Collection templates = Collections2.transform(widgets, new Function() { + public String apply(@Nonnull CoreWidget widget) { + return widget.getTemplatePath(); + } + }); + assertThat(templates).hasSize(Sets.newHashSet(templates).size()); + } + + @Test + public void widget_titles_should_be_unique() { + Collection widgets = widgets(); + Collection templates = Collections2.transform(widgets, new Function() { + public String apply(@Nonnull CoreWidget widget) { + return widget.getTitle(); + } + }); + assertThat(templates).hasSize(Sets.newHashSet(templates).size()); + } + + @Test + public void should_find_templates() { + for (CoreWidget widget : widgets()) { + assertThat(widget.getClass().getResource(widget.getTemplatePath())) + .as("Template not found: " + widget.getTemplatePath()) + .isNotNull(); + } + } + + @Test + public void should_find_core_widgets() { + assertThat(widgets().size()).isGreaterThan(23); + } + + private Set> widgetClasses() { + String[] packages = {"org.sonar.server.dashboard.widget"}; + return new Reflections(packages).getSubTypesOf(CoreWidget.class); + } + + private Collection widgets() { + return newArrayList(Iterables.transform(widgetClasses(), new Function, CoreWidget>() { + public CoreWidget apply(@Nullable Class aClass) { + try { + return aClass.newInstance(); + } catch (Exception e) { + throw Throwables.propagate(e); + } + } + })); + } +} diff --git a/server/sonar-server/src/test/java/org/sonar/server/measure/template/MyFavouritesFilterTest.java b/server/sonar-server/src/test/java/org/sonar/server/measure/template/MyFavouritesFilterTest.java new file mode 100644 index 00000000000..1aa6b5803b5 --- /dev/null +++ b/server/sonar-server/src/test/java/org/sonar/server/measure/template/MyFavouritesFilterTest.java @@ -0,0 +1,40 @@ +/* + * SonarQube, open source software quality management tool. + * Copyright (C) 2008-2014 SonarSource + * mailto:contact AT sonarsource DOT com + * + * SonarQube 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. + * + * SonarQube 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 this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.measure.template; + +import org.junit.Test; +import org.sonar.api.web.Filter; + +import static org.assertj.core.api.Assertions.assertThat; + +public class MyFavouritesFilterTest { + @Test + public void should_create_filter() { + MyFavouritesFilter template = new MyFavouritesFilter(); + + Filter filter = template.createFilter(); + + assertThat(template.getName()).isEqualTo("My favourites"); + assertThat(filter).isNotNull(); + assertThat(filter.isFavouritesOnly()).isTrue(); + assertThat(filter.getCriteria()).isEmpty(); + assertThat(filter.getColumns()).hasSize(3); + } +} diff --git a/server/sonar-server/src/test/java/org/sonar/server/measure/template/ProjectFilterTest.java b/server/sonar-server/src/test/java/org/sonar/server/measure/template/ProjectFilterTest.java new file mode 100644 index 00000000000..783b3f37a06 --- /dev/null +++ b/server/sonar-server/src/test/java/org/sonar/server/measure/template/ProjectFilterTest.java @@ -0,0 +1,39 @@ +/* + * SonarQube, open source software quality management tool. + * Copyright (C) 2008-2014 SonarSource + * mailto:contact AT sonarsource DOT com + * + * SonarQube 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. + * + * SonarQube 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 this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.measure.template; + +import org.junit.Test; +import org.sonar.api.web.Filter; + +import static org.assertj.core.api.Assertions.assertThat; + +public class ProjectFilterTest { + @Test + public void should_create_filter() { + ProjectFilter template = new ProjectFilter(); + + Filter filter = template.createFilter(); + + assertThat(template.getName()).isEqualTo("Projects"); + assertThat(filter).isNotNull(); + assertThat(filter.getCriteria()).hasSize(1); + assertThat(filter.getColumns()).hasSize(6); + } +} diff --git a/server/sonar-server/src/test/resources/org/sonar/server/dashboard/template/ProjectIssuesDashboardTest/filters.xml b/server/sonar-server/src/test/resources/org/sonar/server/dashboard/template/ProjectIssuesDashboardTest/filters.xml new file mode 100644 index 00000000000..8ec92ddcdbf --- /dev/null +++ b/server/sonar-server/src/test/resources/org/sonar/server/dashboard/template/ProjectIssuesDashboardTest/filters.xml @@ -0,0 +1,33 @@ + + + + + + + + +