diff options
author | Simon Brandhof <simon.brandhof@gmail.com> | 2012-05-25 19:47:38 +0200 |
---|---|---|
committer | Simon Brandhof <simon.brandhof@gmail.com> | 2012-05-25 19:47:47 +0200 |
commit | 86c1e331b375f8e24ec479b2e6acb30235b5a84a (patch) | |
tree | 88d26685c04320c4b8390a300901ce8e47bc6122 /plugins | |
parent | 8e26488fe53000880048ec6965e358d1bc9206a2 (diff) | |
download | sonarqube-86c1e331b375f8e24ec479b2e6acb30235b5a84a.tar.gz sonarqube-86c1e331b375f8e24ec479b2e6acb30235b5a84a.zip |
Refactor AbstractFilterDashboard : use Open/Close principle
Diffstat (limited to 'plugins')
3 files changed, 15 insertions, 6 deletions
diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/dashboards/AbstractFilterDashboard.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/dashboards/AbstractFilterDashboard.java index 60d35b21c9e..7d4d2d25ed0 100644 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/dashboards/AbstractFilterDashboard.java +++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/dashboards/AbstractFilterDashboard.java @@ -34,7 +34,7 @@ abstract class AbstractFilterDashboard extends DashboardTemplate { protected abstract String getFilterKey(); @Override - public Dashboard createDashboard() { + public final Dashboard createDashboard() { Dashboard dashboard = Dashboard.create() .setGlobal(true) .setLayout(DashboardLayout.ONE_COLUMN); @@ -43,6 +43,13 @@ abstract class AbstractFilterDashboard extends DashboardTemplate { .addWidget("filter", 1) .setProperty(FilterWidget.FILTER, getFilterKey()); + doCompleteDashboard(dashboard); return dashboard; } + + /** + * Override this method to complete dashboard + */ + protected void doCompleteDashboard(Dashboard dashboard) { + } } diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/dashboards/MyFavouritesDashboard.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/dashboards/MyFavouritesDashboard.java index 0e05c7ec82e..23a66302d01 100644 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/dashboards/MyFavouritesDashboard.java +++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/dashboards/MyFavouritesDashboard.java @@ -35,11 +35,11 @@ public final class MyFavouritesDashboard extends AbstractFilterDashboard { @Override protected String getFilterKey() { - return new MyFavouritesFilter().getName(); + return MyFavouritesFilter.NAME; } @Override - public Dashboard createDashboard() { - return super.createDashboard().setActivated(false); + protected void doCompleteDashboard(Dashboard dashboard) { + dashboard.setActivated(false); } }
\ No newline at end of file diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/filters/MyFavouritesFilter.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/filters/MyFavouritesFilter.java index 128152622f2..32fd31d0373 100644 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/filters/MyFavouritesFilter.java +++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/filters/MyFavouritesFilter.java @@ -31,9 +31,11 @@ import org.sonar.api.web.FilterTemplate; * @since 3.1 */ public class MyFavouritesFilter extends FilterTemplate { + public static final String NAME = "My favourites"; + @Override public String getName() { - return "My favourites"; + return NAME; } @Override @@ -41,7 +43,7 @@ public class MyFavouritesFilter extends FilterTemplate { Filter filter = Filter.create(); filter.setDisplayAs(Filter.LIST); filter.setFavouritesOnly(true); - filter.add(Criterion.createForQualifier("VW", "SVW", "TRK", "BRC", "DIR", "PAC", "FIL", "CLA", "UTS", "LIB")); + filter.add(Criterion.createForQualifier("VW", "SVW", "TRK", "BRC", "DIR", "PAC", "FIL", "CLA", "UTS")); filter.add(FilterColumn.create("metric", CoreMetrics.ALERT_STATUS_KEY, FilterColumn.DESC, false)); filter.add(FilterColumn.create("name", null, FilterColumn.ASC, false)); filter.add(FilterColumn.create("metric", CoreMetrics.NCLOC_KEY, FilterColumn.DESC, false)); |