@PropertyField(
key = "url",
name = "Url",
+ description = "l'url du serveur jira",
type = PropertyType.STRING),
@PropertyField(
key = "port",
@Target(ElementType.TYPE)
public @interface PropertyField {
/**
- * Unique key within a property.
+ * Unique key within a property. It shouldn't be prefixed.
*/
String key();
*/
String defaultValue() default "";
+ /**
+ * This name will be displayed on the Settings page. This can be overridden/translated
+ * by adding a a value for: <code>field.{key of parent property}.{key of this field}.name</code> in the language bundle.
+ */
String name();
+ /**
+ * If not empty, this description will be displayed on the Settings page. This can be overridden/translated
+ * by adding a a value for: <code>field.{key of parent property}.{key of this field}.description</code> in the language bundle.
+ */
String description() default "";
PropertyType type() default PropertyType.STRING;
}
public Result validate(@Nullable String value) {
+ return validate(type, value, options);
+ }
+
+ static Result validate(PropertyType type, @Nullable String value, String[] options) {
if (StringUtils.isNotBlank(value)) {
if (type == PropertyType.BOOLEAN) {
if (!StringUtils.equalsIgnoreCase(value, "true") && !StringUtils.equalsIgnoreCase(value, "false")) {
import org.sonar.api.PropertyField;
import org.sonar.api.PropertyType;
+import javax.annotation.Nullable;
+
/**
* @since 3.3
*/
return definitions;
}
-
public String getKey() {
return key;
}
public String getDescription() {
return description;
}
+
+ public PropertyDefinition.Result validate(@Nullable String value) {
+ return PropertyDefinition.validate(type, value, options);
+ }
}
end
def property_name(property)
- message("property.#{property.key()}.name", :default => property.name())
+ message("property.#{property.key}.name", :default => property.name())
end
def property_description(property)
- message("property.#{property.key()}.description", :default => property.description())
+ message("property.#{property.key}.description", :default => property.description)
+ end
+
+ def field_name(property, field)
+ message("field.#{property.key}.#{field.key}.name", :default => field.name)
+ end
+
+ def field_description(property, field)
+ message("field.#{property.key}.#{field.key}.description", :default => field.description)
end
def property_help(property)
- message("property.#{property.key()}.help", :default => '')
+ message("property.#{property.key}.help", :default => '')
end
def property_value(property)
end
def input_name(property)
- "settings[#{h property.key}]" + (property.multi_values ? '[]' : '')
+ name = "settings[#{h property.key}]"
+ if property.multi_values
+ name += '[]'
+ end
+ name
end
end
def validate
if java_definition
- validation_result=java_definition.validate(text_value)
+ validation_result = java_definition.validate(text_value)
errors.add_to_base(validation_result.getErrorKey()) unless validation_result.isValid()
end
end
<% value = property_value(property) -%>
<% if property.multi_values -%>
- <% value.each_with_index do |sub_value, index| -%>
+ <% value.each do |sub_value| -%>
<%= render "settings/multi_value", :property => property, :value => sub_value, :delete_link => true -%>
<% end -%>
<div class="template" style="display:none;">
<script>
$j('.delete').live('click', function () {
- $j(this).parent('.multi_value').remove();
+ $j(this).parents('.multi_value').remove();
return false;
});
--- /dev/null
+<div class="multi_value">
+ <div class="field">
+ <label><%= message('key') %>:</label>
+ <%= text_field_tag "property_sets[#{property.key}][]", set_key, :size => 50 -%>
+ <a href="#" class="delete link-action"><%= message('delete') -%></a>
+ </div>
+
+ <% property.fields.each do |field| -%>
+ <div class="field">
+ <label><%= field_name(property, field) -%>: </label>
+
+ <% value = Property.value("#{property.key}.#{set_key}.#{field.key}", resource_id) if set_key -%>
+ <%= render "settings/type_#{field.type}", :property => field, :value => value, :name => "#{property.key}[#{field.key}][]", :id => "input_#{h field.key}" -%>
+
+ <% desc=field_description(property, field) -%>
+ <% unless desc.blank? %>
+ <p class="note"><%= desc -%></p>
+ <% end -%>
+ </div>
+ <% end -%>
+ <br/>
+</div>
<div id="plugins">
- <h1 class="marginbottom10"><%= message(@resource ? 'project_settings.page' : 'settings.page' ) -%></h1>
+ <h1 class="marginbottom10"><%= message(@resource ? 'project_settings.page' : 'settings.page') -%></h1>
<table width="100%">
<tr>
-<%= render "settings/type_#{property_type(property, value)}", :property => property, :value => value -%>
+<%= render "settings/type_#{property_type(property, value)}", :property => property, :value => value, :name => input_name(property), :id => "input_#{h property.key}" -%>
-<select name="<%= input_name(property) -%>" id="input_<%= h property.getKey() -%>">
+<select name="<%= name -%>" id="<%= id -%>">
<option value="" <%= 'selected' if value.blank? -%>><%= message('default') -%></option>
<option value="true" <%= 'selected' if value=='true' -%>><%= message('true') -%></option>
<option value="false" <%= 'selected' if value=='false' -%>><%= message('false') -%></option>
-<input type="text" name="<%= input_name(property) -%>" value="<%= h value if value -%>" size="50" id="input_<%= h property.getKey() -%>"/>
\ No newline at end of file
+<input type="text" name="<%= name -%>" value="<%= h value if value -%>" size="50" id="<%= id -%>"/>
\ No newline at end of file
-<input type="text" name="<%= input_name(property) -%>" value="<%= h value if value -%>" size="50" id="input_<%= h property.getKey()-%>"/>
\ No newline at end of file
+<input type="text" name="<%= name -%>" value="<%= h value if value -%>" size="50" id="<%= id-%>"/>
\ No newline at end of file
<% if !value || value.blank? %>
- <textarea rows="5" cols="80" class="width100" name="<%= input_name(property) -%>" id="input_<%= h property.getKey() -%>"></textarea>
+ <textarea rows="5" cols="80" class="width100" name="<%= name -%>" id="<%= id -%>"></textarea>
<%
else
license = controller.java_facade.parseLicense(value)
date = license.getExpirationDateAsString()
%>
<div class="width100">
- <textarea rows="6" name="<%= input_name(property) -%>" id="input_<%= h property.getKey() -%>" style="float: left;width: 390px"><%= h value -%></textarea>
+ <textarea rows="6" name="<%= name -%>" id="<%= id -%>" style="float: left;width: 390px"><%= h value -%></textarea>
<div style="margin-left: 400px">
<table>
-<select name="<%= input_name(property) -%>" id="input_<%= h property.getKey() -%>">
+<select name="<%= name -%>" id="<%= id -%>">
<option value=""><%= message('default') -%></option>
<%
metrics_per_domain={}
-<input type="password" name="<%= input_name(property) -%>" value="<%= h value if value -%>" size="50" id="input_<%= h property.getKey() -%>"/>
\ No newline at end of file
+<input type="password" name="<%= name -%>" value="<%= h value if value -%>" size="50" id="<%= id -%>"/>
\ No newline at end of file
-<select name="<%= input_name(property) -%>" id="input_<%= h property.getKey() -%>">
+<select name="<%= name -%>" id="<%= id -%>">
<option value=""><%= message('default') -%></option>
<% Property.values(property.propertySetKey).reject(&:blank?).each do |set_key| -%>
<% resource_id = @resource.id if @resource -%>
<% Property.values(property.key, resource_id).reject(&:blank?).each do |set_key| -%>
- <div class="multi_value">
- <%= text_field_tag "property_sets[#{property.key}][]", set_key -%>
- <br/>
-
- <% property.fields.each do |field| -%>
- <label><%= field.key -%>: </label><br/>
- <%= text_field_tag "#{property.key}[#{field.key}][]", Property.value("#{property.key}.#{set_key}.#{field.key}", resource_id) -%>
- <br/>
- <% end -%>
-
- <a href="#" class="delete link-action"><%= message('delete') -%></a>
- <br/><br/>
- </div>
+ <%= render 'settings/set_instance', :property => property, :set_key => set_key, :resource_id => resource_id %>
<% end -%>
<div class="template" style="display:none;">
- <div class="multi_value">
- <%= text_field_tag "property_sets[#{property.key}][]" %>
- <br/>
-
- <% property.fields.each do |field| -%>
- <label><%= field.key -%>: </label><br/>
- <%= text_field_tag "#{property.key}[#{field.key}][]" -%>
- <br/>
- <% end -%>
-
- <a href="#" class="delete link-action"><%= message('delete') -%></a>
- <br/><br/>
- </div>
+ <%= render 'settings/set_instance', :property => property, :set_key => nil, :resource_id => resource_id %>
</div>
<button class="add_value"><%= message('settings.add') -%></button>
-<input type="text" name="<%= input_name(property) -%>" value="<%= h value if value -%>" size="50" id="input_<%= h property.getKey() -%>"/>
\ No newline at end of file
+<input type="text" name="<%= name -%>" value="<%= h value if value -%>" size="50" id="<%= id -%>"/>
\ No newline at end of file
-<select name="<%= input_name(property) -%>" id="input_<%= h property.key-%>">
+<select name="<%= name -%>" id="<%= id -%>">
<option value=""><%= message('default') -%></option>
<% property.options.each do |option| %>
<option value="<%= h option -%>" <%= 'selected' if value && value==option -%>><%= h option -%></option>
-<input type="text" name="<%= input_name(property) -%>" value="<%= h value if value -%>" size="50" id="input_<%= property.key.parameterize -%>"/>
\ No newline at end of file
+<input type="text" name="<%= name -%>" value="<%= h value if value -%>" size="50" id="<%= id -%>"/>
\ No newline at end of file
-<textarea rows="5" cols="80" class="width100" name="<%= input_name(property) -%>" id="input_<%= h property.getKey() -%>"><%= h value if value -%></textarea>
\ No newline at end of file
+<textarea rows="5" cols="80" class="width100" name="<%= name -%>" id="<%= id -%>"><%= h value if value -%></textarea>
\ No newline at end of file
box-sizing: border-box; /* Opera/IE 8+ */
}
+.field {
+ margin-bottom: 5px;
+}
+
+.field label {
+ text-align: right;
+ width: 80px;
+ display: block;
+ float: left;
+ line-height: 1;
+ word-wrap: break-word;
+ position: relative;
+ padding-top: 5px;
+ padding-right: 5px;
+}
+
+.field .note {
+ margin-top: 3px;
+ margin-left: 90px;
+}