From 1e67149fab20a225574ad00a97b1b87afc8365ac Mon Sep 17 00:00:00 2001 From: David Gageot Date: Thu, 4 Oct 2012 17:11:52 +0200 Subject: [PATCH] SONAR-3529 Improve property sets --- .../src/main/java/org/sonar/api/PropertyField.java | 5 ----- .../java/org/sonar/api/config/PropertyFieldDefinition.java | 6 ------ .../webapp/WEB-INF/app/controllers/settings_controller.rb | 4 ++++ .../WEB-INF/app/views/settings/_set_instance.html.erb | 2 +- .../views/settings/_type_PROPERTY_SET_DEFINITION.html.erb | 2 ++ 5 files changed, 7 insertions(+), 12 deletions(-) diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/PropertyField.java b/sonar-plugin-api/src/main/java/org/sonar/api/PropertyField.java index d0ca927ac25..ae15c394602 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/PropertyField.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/PropertyField.java @@ -40,11 +40,6 @@ public @interface PropertyField { */ String key(); - /** - * The empty string "" is considered as null, so it's not possible to have empty strings for default values. - */ - String defaultValue() default ""; - /** * This name will be displayed on the Settings page. This can be overridden/translated * by adding a a value for: field.{key of parent property}.{key of this field}.name in the language bundle. diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/config/PropertyFieldDefinition.java b/sonar-plugin-api/src/main/java/org/sonar/api/config/PropertyFieldDefinition.java index cc73824eb87..dfa4171792a 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/config/PropertyFieldDefinition.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/config/PropertyFieldDefinition.java @@ -32,7 +32,6 @@ import java.util.List; */ public final class PropertyFieldDefinition { private final String key; - private final String defaultValue; private final String name; private final String description; private final int indicativeSize; @@ -41,7 +40,6 @@ public final class PropertyFieldDefinition { private PropertyFieldDefinition(PropertyField annotation) { this.key = annotation.key(); - this.defaultValue = annotation.defaultValue(); this.name = annotation.name(); this.description = annotation.description(); this.indicativeSize = annotation.indicativeSize(); @@ -61,10 +59,6 @@ public final class PropertyFieldDefinition { return key; } - public String getDefaultValue() { - return defaultValue; - } - public String getName() { return name; } diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/settings_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/settings_controller.rb index c64c1f025a2..a373a86c460 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/settings_controller.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/settings_controller.rb @@ -60,6 +60,10 @@ class SettingsController < ApplicationController # clear Property.with_key_prefix(key + '.').with_resource(resource_id).delete_all + if params[key][:auto_generate] + set_keys = Array.new(set_keys.size - 1) { |i| i.to_s } + end + # set keys update_property(key, set_keys, resource_id) set_keys.each do |set_key| diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/settings/_set_instance.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/settings/_set_instance.html.erb index 25f871da344..b2007ca090c 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/settings/_set_instance.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/settings/_set_instance.html.erb @@ -5,7 +5,7 @@ <% if key_field -%> <%= render "settings/type_#{key_field.type}", :property => key_field, :field => key_field, :value => set_key, :name => "property_sets[#{property.key}][]", :id => "input_#{h key_field.key}", :size => key_field.indicativeSize -%> <% else -%> - <%= hidden_field_tag "property_sets[#{property.key}][]", set_key -%> + <%= hidden_field_tag "property_sets[#{property.key}][]", 'auto-generated' -%> <% end -%> <% property.fields.reject { |field| field.key == 'key' }.each do |field| -%> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/settings/_type_PROPERTY_SET_DEFINITION.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/settings/_type_PROPERTY_SET_DEFINITION.html.erb index 9a601b52a04..ab21f5fc322 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/settings/_type_PROPERTY_SET_DEFINITION.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/settings/_type_PROPERTY_SET_DEFINITION.html.erb @@ -5,6 +5,8 @@ <% if key_field(property) -%> <%= message('key') -%> + <% else %> + <%= hidden_field_tag "#{property.key}[auto_generate]", true -%> <% end -%> <% property.fields.reject { |field| field.key == 'key' }.each do |field| -%> -- 2.39.5