2 * Sonar, open source software quality management tool.
3 * Copyright (C) 2008-2012 SonarSource
4 * mailto:contact AT sonarsource DOT com
6 * Sonar is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 3 of the License, or (at your option) any later version.
11 * Sonar is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with Sonar; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
20 package org.sonar.plugins.core.dashboards;
22 import org.sonar.api.web.Dashboard;
23 import org.sonar.api.web.DashboardLayout;
24 import org.sonar.api.web.DashboardTemplate;
25 import org.sonar.core.measure.MeasureFilterDao;
26 import org.sonar.core.measure.MeasureFilterDto;
27 import org.sonar.plugins.core.filters.MyFavouritesFilter;
28 import org.sonar.plugins.core.filters.ProjectFilter;
29 import org.sonar.plugins.core.widgets.MeasureFilterListWidget;
30 import org.sonar.plugins.core.widgets.MeasureFilterTreemapWidget;
31 import org.sonar.plugins.core.widgets.WelcomeWidget;
34 * Projects global dashboard for Sonar
38 public final class GlobalDefaultDashboard extends DashboardTemplate {
40 private MeasureFilterDao filterDao;
42 public GlobalDefaultDashboard(MeasureFilterDao filterDao) {
43 this.filterDao = filterDao;
47 public Dashboard createDashboard() {
48 Dashboard dashboard = Dashboard.create()
50 .setLayout(DashboardLayout.TWO_COLUMNS);
52 dashboard.addWidget(WelcomeWidget.ID, 1);
54 MeasureFilterDto filter = findSystemFilter(MyFavouritesFilter.NAME);
57 .addWidget(MeasureFilterListWidget.ID, 1)
58 .setProperty(MeasureFilterListWidget.FILTER_PROPERTY, filter.getId().toString())
59 .setProperty(MeasureFilterListWidget.PAGE_SIZE_PROPERTY, "50");
62 filter = findSystemFilter(ProjectFilter.NAME);
65 .addWidget(MeasureFilterListWidget.ID, 2)
66 .setProperty(MeasureFilterListWidget.FILTER_PROPERTY, filter.getId().toString())
67 .setProperty(MeasureFilterListWidget.PAGE_SIZE_PROPERTY, "20");
70 .addWidget(MeasureFilterTreemapWidget.ID, 2)
71 .setProperty(MeasureFilterListWidget.FILTER_PROPERTY, filter.getId().toString())
72 .setProperty(MeasureFilterTreemapWidget.SIZE_METRIC_PROPERTY, "ncloc")
73 .setProperty(MeasureFilterTreemapWidget.COLOR_METRIC_PROPERTY, "violations_density");
80 public String getName() {
84 private MeasureFilterDto findSystemFilter(String name) {
85 return filterDao.findSystemFilterByName(name);