From: David Gageot Date: Mon, 21 May 2012 12:58:05 +0000 (+0200) Subject: Now there are PROJECT and GLOBAL constants in WidgetScope X-Git-Tag: 3.1~155 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=14e2305837e05c61c0d5eee90726998ed1e50633;p=sonarqube.git Now there are PROJECT and GLOBAL constants in WidgetScope --- diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/FilterWidget.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/FilterWidget.java index 067ead594eb..76beef5339f 100644 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/FilterWidget.java +++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/FilterWidget.java @@ -27,8 +27,10 @@ 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.*; + @WidgetCategory({"Filters", "Global"}) -@WidgetScope("GLOBAL") +@WidgetScope(GLOBAL) @WidgetProperties({ @WidgetProperty(key = "filter", type = WidgetPropertyType.FILTER, optional = false) }) diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/web/WidgetScope.java b/sonar-plugin-api/src/main/java/org/sonar/api/web/WidgetScope.java index afee3f127b8..5dd02fdb280 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/web/WidgetScope.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/web/WidgetScope.java @@ -33,5 +33,8 @@ import java.lang.annotation.*; @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.TYPE) public @interface WidgetScope { - String[] value() default "PROJECT"; + String PROJECT = "PROJECT"; + String GLOBAL = "GLOBAL"; + + String[] value() default PROJECT; } diff --git a/sonar-server/src/main/java/org/sonar/server/ui/ViewProxy.java b/sonar-server/src/main/java/org/sonar/server/ui/ViewProxy.java index 82bc76adf9e..29d869e050a 100644 --- a/sonar-server/src/main/java/org/sonar/server/ui/ViewProxy.java +++ b/sonar-server/src/main/java/org/sonar/server/ui/ViewProxy.java @@ -113,13 +113,13 @@ public class ViewProxy implements Comparable { WidgetScope scopeAnnotation = AnnotationUtils.getClassAnnotation(view, WidgetScope.class); if (scopeAnnotation != null) { checkValidScope(view, scopeAnnotation); - isGlobal = ImmutableSet.copyOf(scopeAnnotation.value()).contains("GLOBAL"); + isGlobal = ImmutableSet.copyOf(scopeAnnotation.value()).contains(WidgetScope.GLOBAL); } } private static void checkValidScope(V view, WidgetScope scopeAnnotation) { for (String scope : scopeAnnotation.value()) { - if (!scope.equals("PROJECT") && !scope.equalsIgnoreCase("GLOBAL")) { + if (!scope.equals(WidgetScope.PROJECT) && !scope.equalsIgnoreCase(WidgetScope.GLOBAL)) { throw new IllegalArgumentException(String.format("Invalid widget scope %s for widget %s", scope, view.getClass().getSimpleName())); } }