From: David Gageot Date: Thu, 5 Jul 2012 14:06:52 +0000 (+0200) Subject: SONAR-3432 Add text property type for widgets X-Git-Tag: 3.2~229 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=eaf902e6bae6e62eaca8378a41d2bc011e04d057;p=sonarqube.git SONAR-3432 Add text property type for widgets --- diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/web/WidgetPropertyType.java b/sonar-plugin-api/src/main/java/org/sonar/api/web/WidgetPropertyType.java index 7be2caf8b2c..5d333988554 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/web/WidgetPropertyType.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/web/WidgetPropertyType.java @@ -20,10 +20,44 @@ package org.sonar.api.web; public enum WidgetPropertyType { + /** + * Integer value, positive or negative + */ INTEGER, + + /** + * True/False + */ BOOLEAN, + + /** + * Floating point number + */ FLOAT, + + /** + * Basic single line input field + */ STRING, - METRIC, // @since 2.10 - FILTER // @since 3.1 + + /** + * Sonar Metric + * + * @since 2.10 + */ + METRIC, + + /** + * Filter id + * + * @since 3.1 + */ + FILTER, + + /** + * Multiple line text-area + * + * @since 3.2 + */ + TEXT } diff --git a/sonar-server/src/main/webapp/WEB-INF/app/helpers/properties_helper.rb b/sonar-server/src/main/webapp/WEB-INF/app/helpers/properties_helper.rb index 9376b0b6497..c203272c239 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/helpers/properties_helper.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/helpers/properties_helper.rb @@ -24,18 +24,18 @@ module PropertiesHelper if definition.type.name()==PropertyType::TYPE_INTEGER text_field_tag definition.key(), val, :size => 10 - elsif definition.type.name()==PropertyType::TYPE_FLOAT - text_field_tag definition.key(), val, :size => 10 - elsif definition.type.name()==PropertyType::TYPE_BOOLEAN check_box_tag definition.key(), "true", val=='true' - elsif definition.type.name()==PropertyType::TYPE_METRIC - select_tag definition.key(), options_grouped_by_domain(Metric.all.select{|m| m.display?}.sort_by{|m| m.short_name}, val, :include_empty => true) + elsif definition.type.name()==PropertyType::TYPE_FLOAT + text_field_tag definition.key(), val, :size => 10 elsif definition.type.name()==PropertyType::TYPE_STRING text_field_tag definition.key(), val, :size => 10 + elsif definition.type.name()==PropertyType::TYPE_METRIC + select_tag definition.key(), options_grouped_by_domain(Metric.all.select{|m| m.display?}.sort_by(&:short_name), val, :include_empty => true) + elsif definition.type.name()==PropertyType::TYPE_FILTER user_filters = options_key(value, ::Filter.find(:all, :conditions => ['user_id=?', current_user.id]).sort_by(&:id)) shared_filters = options_key(value, ::Filter.find(:all, :conditions => ['(user_id<>? or user_id is null) and shared=?', current_user.id, true]).sort_by(&:id)) @@ -44,6 +44,9 @@ module PropertiesHelper filter_link = link_to message('widget.filter.edit'), {:controller => :filters, :action => :manage}, :class => 'link-action' "#{filters_combo} #{filter_link}" + + elsif definition.type.name()==PropertyType::TYPE_TEXT + text_area_tag definition.key(), val, :size => '40x6' else hidden_field_tag definition.key() end diff --git a/sonar-server/src/main/webapp/WEB-INF/app/models/property_type.rb b/sonar-server/src/main/webapp/WEB-INF/app/models/property_type.rb index 30780a6c2f9..c5227fff69d 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/models/property_type.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/models/property_type.rb @@ -24,6 +24,7 @@ class PropertyType TYPE_STRING = 'STRING' TYPE_METRIC = 'METRIC' TYPE_FILTER = 'FILTER' + TYPE_TEXT = 'TEXT' def self.text_to_value(text, type) case type