project = false,
global = true,
category = CoreProperties.CATEGORY_GENERAL),
- @Property(
- key = "sonar.test",
- defaultValue = "complexity",
- name = "Metric",
- project = true,
- global = true,
- category = CoreProperties.CATEGORY_GENERAL,
- type = PropertyType.METRIC),
- @Property(
- key = "sonar.testmetric",
- name = "Metric",
- project = true,
- global = true,
- category = CoreProperties.CATEGORY_GENERAL,
- type = PropertyType.METRIC),
- @Property(
- key = "sonar.test2",
- name = "Single",
- defaultValue = "2",
- project = true,
- global = true,
- category = CoreProperties.CATEGORY_GENERAL,
- type = PropertyType.SINGLE_SELECT_LIST,
- options = {"1", "2", "3"}),
- @Property(
- key = "sonar.testsinglelist",
- name = "Single2",
- project = true,
- global = true,
- category = CoreProperties.CATEGORY_GENERAL,
- type = PropertyType.SINGLE_SELECT_LIST,
- options = {"1", "2", "3"}),
- @Property(
- key = "sonar.test3",
- name = "Password",
- project = true,
- global = true,
- category = CoreProperties.CATEGORY_GENERAL,
- type = PropertyType.PASSWORD,
- options = {"1", "2", "3"}),
@Property(
key = CoreProperties.LINKS_HOME_PAGE,
defaultValue = "",
@WidgetCategory("History")
@WidgetProperties({
- @WidgetProperty(key = "chartTitle", type = WidgetPropertyType.STRING, description = "chartTitle description"),
- @WidgetProperty(key = "metric1", type = WidgetPropertyType.METRIC, defaultValue = "ncloc", options = {WidgetConstants.FILTER_OUT_NEW_METRICS}, description = "metric1 description"),
- @WidgetProperty(key = "metric2", type = WidgetPropertyType.METRIC, options = {WidgetConstants.FILTER_OUT_NEW_METRICS}, description = "metric2 description"),
- @WidgetProperty(key = "metric3", type = WidgetPropertyType.METRIC, options = {WidgetConstants.FILTER_OUT_NEW_METRICS}, description = "metric3 description"),
- @WidgetProperty(key = "hideEvents", type = WidgetPropertyType.BOOLEAN, description = "hideEvents description"),
- @WidgetProperty(key = "hideEvents2", type = WidgetPropertyType.BOOLEAN, description = "hideEvents description", defaultValue = "true"),
- @WidgetProperty(key = "chartHeight", type = WidgetPropertyType.INTEGER, defaultValue = "80", description = "chartHeight description"),
-
- @WidgetProperty(key = "text", type = WidgetPropertyType.TEXT, description = "text description"),
- @WidgetProperty(key = "password", type = WidgetPropertyType.PASSWORD, description = "password description", defaultValue = "123"),
- @WidgetProperty(key = "password2", type = WidgetPropertyType.PASSWORD, description = "password2 description"),
- @WidgetProperty(key = "float", type = WidgetPropertyType.FLOAT, description = "float description"),
- @WidgetProperty(key = "regex", type = WidgetPropertyType.REGULAR_EXPRESSION, description = "regex description"),
- @WidgetProperty(key = "filter", type = WidgetPropertyType.FILTER, description = "filter description"),
- @WidgetProperty(
- key = "list",
- defaultValue = "2",
- type = WidgetPropertyType.SINGLE_SELECT_LIST,
- options = {"1", "2", "3"},
- description = "list description"),
- @WidgetProperty(
- key = "list2",
- type = WidgetPropertyType.SINGLE_SELECT_LIST,
- options = {"1", "2", "3"},
- description = "list2 description")
+ @WidgetProperty(key = "chartTitle", type = WidgetPropertyType.STRING),
+ @WidgetProperty(key = "metric1", type = WidgetPropertyType.METRIC, defaultValue = "ncloc", options = {WidgetConstants.FILTER_OUT_NEW_METRICS}),
+ @WidgetProperty(key = "metric2", type = WidgetPropertyType.METRIC, options = {WidgetConstants.FILTER_OUT_NEW_METRICS}),
+ @WidgetProperty(key = "metric3", type = WidgetPropertyType.METRIC, options = {WidgetConstants.FILTER_OUT_NEW_METRICS}),
+ @WidgetProperty(key = "hideEvents", type = WidgetPropertyType.BOOLEAN),
+ @WidgetProperty(key = "chartHeight", type = WidgetPropertyType.INTEGER, defaultValue = "80")
})
public class TimelineWidget extends CoreWidget {
public TimelineWidget() {
password_field_tag name, value, {:size => options[:size] || 25}.update(html_options)
when PropertyType::TYPE_BOOLEAN
- if options[:default]
- select_options = "<option value='' #{ 'selected' if value.blank? }>#{ options[:default] }</option>"
+ if !options[:default].blank?
+ select_options = "<option value='' #{ 'selected' if value.blank? }>#{ message('default') }</option>"
select_options += "<option value='true' #{ 'selected' if value=='true' }>#{ message('true') }</option>"
select_options += "<option value='false' #{ 'selected' if value=='false' }>#{ message('false') }</option>"
select_tag name, select_options, html_options
default_value = options[:default].blank? ? '' : message('default')
select_options = "<option value=''>#{ default_value }</option>"
options[:values].each do |option|
- if screen == SCREEN_WIDGET
- message = message("widget.#{options[:extra_values][:key]}.option.#{name}.#{option}.name", :default => option)
- else
- message = option_name(options[:extra_values][:property], options[:extra_values][:field], option)
- end
+ message = screen == SCREEN_WIDGET ? option_name_with_key(options[:extra_values][:key], nil, option, 'widget') :
+ option_name(options[:extra_values][:property], options[:extra_values][:field], option)
select_options += "<option value='#{ html_escape option }' #{ 'selected' if value && value==option }>#{ message }</option>"
end
select_tag name, select_options, html_options
end
end
+ def option_name_with_key(property_key, field_key, option, key_prefix = '')
+ prefix = ''
+ prefix = key_prefix + "." if !key_prefix.blank?
+ if field_key
+ # Old key used for retro-compatibility
+ message = message(prefix +"option.#{property_key}.#{field_key}.#{option}.name", :default => '')
+ message = message(prefix +"property.#{property_key}.#{field_key}.option.#{option}.name", :default => option) unless message != ''
+ message
+ else
+ # Old key used for retro-compatibility
+ message = message(prefix +"option.#{property_key}.#{option}.name", :default => '')
+ message = message(prefix +"property.#{property_key}.option.#{option}.name", :default => option) unless message != ''
+ message
+ end
+ end
+
end
end
def option_name(property, field, option)
- if field
- message("option.#{property.key}.#{field.key}.#{option}.name", :default => option)
- else
- message("option.#{property.key}.#{option}.name", :default => option)
- end
+ option_name_with_key(property.key, field ? field.key : nil, option, nil)
end
def category_help(category)
<%= property_value_field(property_def, widget.property_text_value(property_def.key()), widget) -%>
<div class="form-val-note">
<%
+ # Old key used for retro-compatibility
property_description = message("widget." + widget.key + ".param." + property_def.key(), :default => '')
property_description = message("widget." + widget.key + ".property." + property_def.key() + ".desc", :default => property_def.description()) unless property_description != ''
-%>
-<%= property_input_field(id, PropertyType::TYPE_BOOLEAN, value, PropertiesHelper::SCREEN_SETTINGS, {:id => id, :default => message('default')}) %>
\ No newline at end of file
+<%= property_input_field(name, PropertyType::TYPE_BOOLEAN, value, PropertiesHelper::SCREEN_SETTINGS, {:id => id, :default => (defined? defaultValue) ? property.defaultValue : nil }) %>
\ No newline at end of file
options = {:id => id}
options[:size] = (defined? size) ? size : 50
%>
-<%= property_input_field(id, PropertyType::TYPE_FLOAT, value, PropertiesHelper::SCREEN_SETTINGS, options) %>
\ No newline at end of file
+<%= property_input_field(name, PropertyType::TYPE_FLOAT, value, PropertiesHelper::SCREEN_SETTINGS, options) %>
\ No newline at end of file
options = {:id => id}
options[:size] = (defined? size) ? size : 50
%>
-<%= property_input_field(id, PropertyType::TYPE_INTEGER, value, PropertiesHelper::SCREEN_SETTINGS, options) %>
\ No newline at end of file
+<%= property_input_field(name, PropertyType::TYPE_INTEGER, value, PropertiesHelper::SCREEN_SETTINGS, options) %>
\ No newline at end of file
+<%
+ defaultValue = (defined? defaultValue) ? property.defaultValue : nil
+%>
<select name="<%= name -%>" id="<%= id -%>">
- <option value=""><%= !property.defaultValue.blank? ? message('default') : nil -%></option>
+ <option value=""><%= !defaultValue.blank? ? message('default') : nil -%></option>
<%
metrics_per_domain={}
metrics_filtered_by(property.options).each do |metric|
options = {:id => id}
options[:size] = (defined? size) ? size : 50
%>
-<%= property_input_field(id, PropertyType::TYPE_PASSWORD, value, PropertiesHelper::SCREEN_SETTINGS, options) %>
\ No newline at end of file
+<%= property_input_field(name, PropertyType::TYPE_PASSWORD, value, PropertiesHelper::SCREEN_SETTINGS, options) %>
\ No newline at end of file
options = {:id => id}
options[:size] = (defined? size) ? size : 50
%>
-<%= property_input_field(id, PropertyType::TYPE_REGULAR_EXPRESSION, value, PropertiesHelper::SCREEN_SETTINGS, options) %>
\ No newline at end of file
+<%= property_input_field(name, PropertyType::TYPE_REGULAR_EXPRESSION, value, PropertiesHelper::SCREEN_SETTINGS, options) %>
\ No newline at end of file
options = {:id => id}
options[:size] = (defined? size) ? size : 50
%>
-<%= property_input_field(id, PropertyType::TYPE_STRING, value, PropertiesHelper::SCREEN_SETTINGS, options) %>
\ No newline at end of file
+<%= property_input_field(name, PropertyType::TYPE_STRING, value, PropertiesHelper::SCREEN_SETTINGS, options) %>
\ No newline at end of file
options = {:id => id}
options[:cols] = (defined? size) ? size : 50
%>
-<%= property_input_field(id, PropertyType::TYPE_TEXT, value, PropertiesHelper::SCREEN_SETTINGS, {:id => id, :cols => (defined? size) ? size : nil}) %>
+<%= property_input_field(name, PropertyType::TYPE_TEXT, value, PropertiesHelper::SCREEN_SETTINGS, {:id => id, :cols => (defined? size) ? size : nil}) %>