diff options
author | simonbrandhof <simon.brandhof@gmail.com> | 2010-11-01 14:20:55 +0000 |
---|---|---|
committer | simonbrandhof <simon.brandhof@gmail.com> | 2010-11-01 14:20:55 +0000 |
commit | 61a84575510a2cdde57ce7b2139c52458903df52 (patch) | |
tree | 6d7f34da22a1c084b2ef3c9b4c8339ddb66d09e3 /sonar-server | |
parent | e22ca92f752d628a2371d7a95a50e71dfabcfc69 (diff) | |
download | sonarqube-61a84575510a2cdde57ce7b2139c52458903df52.tar.gz sonarqube-61a84575510a2cdde57ce7b2139c52458903df52.zip |
SONAR-1643 add example of widget properties in plugin archetype + use enumeration for the type of widget property
Diffstat (limited to 'sonar-server')
7 files changed, 13 insertions, 99 deletions
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/dashboard_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/dashboard_controller.rb index 958ac6eb0bf..b554f01d01a 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/dashboard_controller.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/dashboard_controller.rb @@ -108,11 +108,11 @@ class DashboardController < ApplicationController errors_by_property_key={} definition.getProperties().each do |property_def| value=params[property_def.key()] || property_def.defaultValue() - value='false' if value.empty? && property_def.type()==WidgetProperty::TYPE_BOOLEAN + value='false' if value.empty? && property_def.type.name()==WidgetProperty::TYPE_BOOLEAN errors=WidgetProperty.validate_definition(property_def, value) if errors.empty? - widget.set_property(property_def.key(), value, property_def.type()) + widget.set_property(property_def.key(), value, property_def.type.name()) else widget.unset_property(property_def.key()) errors_by_property_key[property_def.key()]=errors diff --git a/sonar-server/src/main/webapp/WEB-INF/app/helpers/dashboards_helper.rb b/sonar-server/src/main/webapp/WEB-INF/app/helpers/dashboards_helper.rb deleted file mode 100644 index 4893c32db0d..00000000000 --- a/sonar-server/src/main/webapp/WEB-INF/app/helpers/dashboards_helper.rb +++ /dev/null @@ -1,66 +0,0 @@ -# -# Sonar, entreprise quality control tool. -# Copyright (C) 2009 SonarSource SA -# 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 -# -module DashboardsHelper - include ActionView::Helpers::UrlHelper - include WidgetPropertiesHelper - - def item_by_metric_id(items, metric_id) - return nil if items.nil? - items.each do |item| - return item if (item.metric.id==metric_id and item.rules_category_id.nil?) - end - nil - end - - def active_widgets_ids_formatted(column) - active_widget_ids=[] - @dashboard.widgets.find(:all, :conditions => {:column_index => column}, :order => :order_index).each do |widget| - widget_view=nil - found_index=-1 - @widgets.each_with_index {|item, index| - if item.getId()==widget.widget_key - found_index=index - end - } - if found_index>-1 - active_widget_ids=active_widget_ids << (widget.widget_key+"_"+found_index.to_s()) - end - end - return "\'"+active_widget_ids.join("\',\'")+"\'" - end - - def item_by_metric_name_and_categ_id(items, metric_name, rules_category_id) - return nil if items.nil? - items.each do |item| - return item if (item.metric.name==metric_name and - item.rules_category_id == rules_category_id and - item.rule_id.nil?) - end - nil - end - - def formatted_value(measure, default='') - measure ? measure.formatted_value : default - end - - def measure(metric_key) - @snapshot.measure(metric_key) - end -end
\ No newline at end of file diff --git a/sonar-server/src/main/webapp/WEB-INF/app/helpers/widget_properties_helper.rb b/sonar-server/src/main/webapp/WEB-INF/app/helpers/widget_properties_helper.rb index 9b353e4f638..bded9a5f141 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/helpers/widget_properties_helper.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/helpers/widget_properties_helper.rb @@ -20,36 +20,18 @@ module WidgetPropertiesHelper
- def valid_property_value?(type, value, parameter="")
- if type==WidgetProperty::TYPE_INTEGER
- value.to_i.to_s == value
-
- elsif type==WidgetProperty::TYPE_FLOAT
- true if Float(value) rescue false
-
- elsif type==WidgetProperty::TYPE_BOOLEAN
- value=="1" || value=="0"
-
- elsif type==WidgetProperty::TYPE_STRING
- true
-
- else
- false
- end
- end
-
def property_value_field(definition, value)
val=value || definition.defaultValue()
- if definition.type()==WidgetProperty::TYPE_INTEGER
+ if definition.type.name()==WidgetProperty::TYPE_INTEGER
text_field_tag definition.key(), val, :size => 10
- elsif definition.type()==WidgetProperty::TYPE_FLOAT
+ elsif definition.type.name()==WidgetProperty::TYPE_FLOAT
text_field_tag definition.key(), val, :size => 10
- elsif definition.type()==WidgetProperty::TYPE_BOOLEAN
+ elsif definition.type.name()==WidgetProperty::TYPE_BOOLEAN
check_box_tag definition.key(), "true", val=='true'
- elsif definition.type()==WidgetProperty::TYPE_STRING
+ elsif definition.type.name()==WidgetProperty::TYPE_STRING
text_field_tag definition.key(), val, :size => 10
else
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/models/widget.rb b/sonar-server/src/main/webapp/WEB-INF/app/models/widget.rb index 4cbc5280f80..4546bc3ad62 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/models/widget.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/models/widget.rb @@ -27,9 +27,6 @@ class Widget < ActiveRecord::Base validates_presence_of :widget_key
validates_length_of :widget_key, :within => 1..256
- #---------------------------------------------------------------------
- # WIDGET PROPERTIES
- #---------------------------------------------------------------------
def property(key)
properties().each do |p|
return p if (p.key==key)
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/models/widget_property.rb b/sonar-server/src/main/webapp/WEB-INF/app/models/widget_property.rb index 3a0706c886b..df755df8221 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/models/widget_property.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/models/widget_property.rb @@ -66,15 +66,15 @@ class WidgetProperty < ActiveRecord::Base if value.empty?
errors<<"Missing value" unless definition.optional()
else
- errors<<"Please type an integer (example: 123)" if definition.type()==TYPE_INTEGER && value.to_i.to_s!=value
- if definition.type()==TYPE_FLOAT
+ errors<<"Please type an integer (example: 123)" if definition.type.name()==TYPE_INTEGER && value.to_i.to_s!=value
+ if definition.type.name()==TYPE_FLOAT
begin
Float(value)
rescue
errors<<"Please type a number (example: 123.45)"
end
end
- errors<<"Please check value" if definition.type()==TYPE_BOOLEAN && !(value=="true" || value=="false")
+ errors<<"Please check value" if definition.type.name()==TYPE_BOOLEAN && !(value=="true" || value=="false")
end
errors
end
diff --git a/sonar-server/src/main/webapp/stylesheets/dashboard.css b/sonar-server/src/main/webapp/stylesheets/dashboard.css index a34478cdaa6..58ec7523270 100644 --- a/sonar-server/src/main/webapp/stylesheets/dashboard.css +++ b/sonar-server/src/main/webapp/stylesheets/dashboard.css @@ -55,11 +55,12 @@ } #dashboard .widget_def { - border-right: 2px solid #FFD324; + border-right: 1px dashed #FFD324; padding: 5px; display: inline-block; - width: 180px; + width: 160px; white-space: normal; + vertical-align: top; } /*OPERATIONS*/ diff --git a/sonar-server/src/test/java/org/sonar/server/ui/ViewProxyTest.java b/sonar-server/src/test/java/org/sonar/server/ui/ViewProxyTest.java index 52eb5197aa7..c93558678e0 100644 --- a/sonar-server/src/test/java/org/sonar/server/ui/ViewProxyTest.java +++ b/sonar-server/src/test/java/org/sonar/server/ui/ViewProxyTest.java @@ -154,7 +154,7 @@ class FakeView implements View { @WidgetProperties({ @WidgetProperty(key="foo", optional = false), - @WidgetProperty(key="bar", defaultValue = "30", type = "INTEGER") + @WidgetProperty(key="bar", defaultValue = "30", type = WidgetPropertyType.INTEGER) }) class EditableWidget implements Widget { |