aboutsummaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorFabrice Bellingard <fabrice.bellingard@sonarsource.com>2012-10-08 11:46:18 +0200
committerFabrice Bellingard <fabrice.bellingard@sonarsource.com>2012-10-08 16:14:52 +0200
commit3cee12889f13ab2784cf2db9138a7a417e8e4097 (patch)
tree35152cc22cd8c905c2459f14b27cbaea651512e7 /plugins
parent422de7b07eb1b281a27b7085e6fb49a36cf2eace (diff)
downloadsonarqube-3cee12889f13ab2784cf2db9138a7a417e8e4097.tar.gz
sonarqube-3cee12889f13ab2784cf2db9138a7a417e8e4097.zip
Refactor code
Diffstat (limited to 'plugins')
-rw-r--r--plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/TimeMachineWidget.java20
-rw-r--r--plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/TimelineWidget.java6
-rw-r--r--plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/WidgetsConstants.java34
3 files changed, 47 insertions, 13 deletions
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
index 564ffed857f..362a1437b83 100644
--- 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
@@ -31,16 +31,16 @@ import org.sonar.api.web.WidgetPropertyType;
@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 = {"key:^(?!new_).*"}),
- @WidgetProperty(key = "metric2", type = WidgetPropertyType.METRIC, options = {"key:^(?!new_).*"}),
- @WidgetProperty(key = "metric3", type = WidgetPropertyType.METRIC, options = {"key:^(?!new_).*"}),
- @WidgetProperty(key = "metric4", type = WidgetPropertyType.METRIC, options = {"key:^(?!new_).*"}),
- @WidgetProperty(key = "metric5", type = WidgetPropertyType.METRIC, options = {"key:^(?!new_).*"}),
- @WidgetProperty(key = "metric6", type = WidgetPropertyType.METRIC, options = {"key:^(?!new_).*"}),
- @WidgetProperty(key = "metric7", type = WidgetPropertyType.METRIC, options = {"key:^(?!new_).*"}),
- @WidgetProperty(key = "metric8", type = WidgetPropertyType.METRIC, options = {"key:^(?!new_).*"}),
- @WidgetProperty(key = "metric9", type = WidgetPropertyType.METRIC, options = {"key:^(?!new_).*"}),
- @WidgetProperty(key = "metric10", type = WidgetPropertyType.METRIC, options = {"key:^(?!new_).*"})
+ @WidgetProperty(key = "metric1", type = WidgetPropertyType.METRIC, defaultValue = "ncloc", options = {WidgetsConstants.FILTER_OUT_NEW_METRICS}),
+ @WidgetProperty(key = "metric2", type = WidgetPropertyType.METRIC, options = {WidgetsConstants.FILTER_OUT_NEW_METRICS}),
+ @WidgetProperty(key = "metric3", type = WidgetPropertyType.METRIC, options = {WidgetsConstants.FILTER_OUT_NEW_METRICS}),
+ @WidgetProperty(key = "metric4", type = WidgetPropertyType.METRIC, options = {WidgetsConstants.FILTER_OUT_NEW_METRICS}),
+ @WidgetProperty(key = "metric5", type = WidgetPropertyType.METRIC, options = {WidgetsConstants.FILTER_OUT_NEW_METRICS}),
+ @WidgetProperty(key = "metric6", type = WidgetPropertyType.METRIC, options = {WidgetsConstants.FILTER_OUT_NEW_METRICS}),
+ @WidgetProperty(key = "metric7", type = WidgetPropertyType.METRIC, options = {WidgetsConstants.FILTER_OUT_NEW_METRICS}),
+ @WidgetProperty(key = "metric8", type = WidgetPropertyType.METRIC, options = {WidgetsConstants.FILTER_OUT_NEW_METRICS}),
+ @WidgetProperty(key = "metric9", type = WidgetPropertyType.METRIC, options = {WidgetsConstants.FILTER_OUT_NEW_METRICS}),
+ @WidgetProperty(key = "metric10", type = WidgetPropertyType.METRIC, options = {WidgetsConstants.FILTER_OUT_NEW_METRICS})
})
public class TimeMachineWidget extends AbstractRubyTemplate implements RubyRailsWidget {
public String getId() {
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
index 5d8c0e303be..aa540fb8859 100644
--- 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
@@ -29,9 +29,9 @@ import org.sonar.api.web.WidgetPropertyType;
@WidgetCategory("History")
@WidgetProperties({
@WidgetProperty(key = "chartTitle", type = WidgetPropertyType.STRING),
- @WidgetProperty(key = "metric1", type = WidgetPropertyType.METRIC, defaultValue = "ncloc", options = {"key:^(?!new_).*"}),
- @WidgetProperty(key = "metric2", type = WidgetPropertyType.METRIC, options = {"key:^(?!new_).*"}),
- @WidgetProperty(key = "metric3", type = WidgetPropertyType.METRIC, options = {"key:^(?!new_).*"}),
+ @WidgetProperty(key = "metric1", type = WidgetPropertyType.METRIC, defaultValue = "ncloc", options = {WidgetsConstants.FILTER_OUT_NEW_METRICS}),
+ @WidgetProperty(key = "metric2", type = WidgetPropertyType.METRIC, options = {WidgetsConstants.FILTER_OUT_NEW_METRICS}),
+ @WidgetProperty(key = "metric3", type = WidgetPropertyType.METRIC, options = {WidgetsConstants.FILTER_OUT_NEW_METRICS}),
@WidgetProperty(key = "hideEvents", type = WidgetPropertyType.BOOLEAN),
@WidgetProperty(key = "chartHeight", type = WidgetPropertyType.INTEGER, defaultValue = "80")
})
diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/WidgetsConstants.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/WidgetsConstants.java
new file mode 100644
index 00000000000..7fab6f3c020
--- /dev/null
+++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/WidgetsConstants.java
@@ -0,0 +1,34 @@
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2012 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar 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.
+ *
+ * Sonar 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 Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+ */
+package org.sonar.plugins.core.widgets;
+
+import org.sonar.api.web.WidgetProperty;
+
+/**
+ * Constants shared accross multiple widgets
+ */
+interface WidgetsConstants {
+
+ /**
+ * Widget property option used to filter out all the metrics which keys start with "new_".
+ * @see WidgetProperty#options()
+ */
+ String FILTER_OUT_NEW_METRICS = "key:^(?!new_).*";
+}