diff options
author | simonbrandhof <simon.brandhof@gmail.com> | 2010-11-05 12:48:07 +0000 |
---|---|---|
committer | simonbrandhof <simon.brandhof@gmail.com> | 2010-11-05 12:48:07 +0000 |
commit | 8257d999859de4fd4148f7d142cfd1ee5c908db6 (patch) | |
tree | 0870937396cebe44b8d9a42dd221959b1a57a4f1 /sonar-server | |
parent | 753e2a00b148b90ca0dab158db374ff8294c2d44 (diff) | |
download | sonarqube-8257d999859de4fd4148f7d142cfd1ee5c908db6.tar.gz sonarqube-8257d999859de4fd4148f7d142cfd1ee5c908db6.zip |
custom dashboards: add the annotation @WidgetLayout with values DEFAULT (gray border + padding) or NONE (no padding, no border)
Diffstat (limited to 'sonar-server')
7 files changed, 49 insertions, 24 deletions
diff --git a/sonar-server/src/main/java/org/sonar/server/ui/ViewProxy.java b/sonar-server/src/main/java/org/sonar/server/ui/ViewProxy.java index 7cb7159bcf0..59fae3ac6a5 100644 --- a/sonar-server/src/main/java/org/sonar/server/ui/ViewProxy.java +++ b/sonar-server/src/main/java/org/sonar/server/ui/ViewProxy.java @@ -37,8 +37,9 @@ public class ViewProxy<V extends View> implements Comparable<ViewProxy> { private String[] resourceLanguages = {}; private String[] defaultForMetrics = {}; private String description = ""; - private WidgetProperty[] properties = {}; - private String[] categories = {}; + private WidgetProperty[] widgetProperties = {}; + private String[] widgetCategories = {}; + private WidgetLayoutType widgetLayout = WidgetLayoutType.DEFAULT; private boolean isDefaultTab = false; private boolean isWidget = false; @@ -87,14 +88,19 @@ public class ViewProxy<V extends View> implements Comparable<ViewProxy> { description = descriptionAnnotation.value(); } - WidgetProperties widgetProperties = AnnotationUtils.getClassAnnotation(view, WidgetProperties.class); - if (widgetProperties != null) { - properties = widgetProperties.value(); + WidgetProperties propAnnotation = AnnotationUtils.getClassAnnotation(view, WidgetProperties.class); + if (propAnnotation != null) { + this.widgetProperties = propAnnotation.value(); } - WidgetCategory widgetCategory = AnnotationUtils.getClassAnnotation(view, WidgetCategory.class); - if (widgetCategory != null) { - categories = widgetCategory.value(); + WidgetCategory categAnnotation = AnnotationUtils.getClassAnnotation(view, WidgetCategory.class); + if (categAnnotation != null) { + widgetCategories = categAnnotation.value(); + } + + WidgetLayout layoutAnnotation = AnnotationUtils.getClassAnnotation(view, WidgetLayout.class); + if (layoutAnnotation != null) { + widgetLayout = layoutAnnotation.value(); } isWidget = (view instanceof Widget); @@ -116,12 +122,12 @@ public class ViewProxy<V extends View> implements Comparable<ViewProxy> { return description; } - public WidgetProperty[] getProperties() { - return properties; + public WidgetProperty[] getWidgetProperties() { + return widgetProperties; } - public String[] getCategories() { - return categories; + public String[] getWidgetCategories() { + return widgetCategories; } public String[] getSections() { @@ -160,13 +166,17 @@ public class ViewProxy<V extends View> implements Comparable<ViewProxy> { return view instanceof GwtPage; } + public WidgetLayoutType getWidgetLayout() { + return widgetLayout; + } + public boolean isEditable() { - return !ArrayUtils.isEmpty(properties); + return !ArrayUtils.isEmpty(widgetProperties); } public boolean hasRequiredProperties() { boolean requires = false; - for (WidgetProperty property : properties) { + for (WidgetProperty property : widgetProperties) { if (!property.optional() && StringUtils.isEmpty(property.defaultValue())) { requires = true; } 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 50d872a104c..289bb1b7138 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 @@ -111,7 +111,7 @@ class DashboardController < ApplicationController #TODO check owner of dashboard definition=java_facade.getWidget(widget.widget_key) errors_by_property_key={} - definition.getProperties().each do |property_def| + definition.getWidgetProperties().each do |property_def| value=params[property_def.key()] || property_def.defaultValue() value='false' if value.empty? && property_def.type.name()==WidgetProperty::TYPE_BOOLEAN @@ -201,10 +201,10 @@ class DashboardController < ApplicationController def load_widget_definitions(filter_on_category=nil) @widget_definitions=java_facade.getWidgets() @widget_categories=[] - @widget_definitions.each {|definition| @widget_categories<<definition.getCategories()} + @widget_definitions.each {|definition| @widget_categories<<definition.getWidgetCategories()} @widget_categories=@widget_categories.flatten.uniq.sort unless filter_on_category.blank? - @widget_definitions=@widget_definitions.select{|definition| definition.getCategories().to_a.include?(filter_on_category)} + @widget_definitions=@widget_definitions.select{|definition| definition.getWidgetCategories().to_a.include?(filter_on_category)} end end diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/dashboard/_configure_widget.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/dashboard/_configure_widget.html.erb index d592eceb471..86472f3de6b 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/dashboard/_configure_widget.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/dashboard/_configure_widget.html.erb @@ -21,7 +21,7 @@ <% form_remote_tag :url => {:action => 'save_widget', :wid => widget.id, :id => params[:id]}, :method => :post do -%> <table class="form"> <tbody> - <% definition.getProperties().each do |property_def| + <% definition.getWidgetProperties().each do |property_def| value=widget.property_value(property_def.key(), property_def.defaultValue()) %> <tr> @@ -57,7 +57,14 @@ <![endif]--> <div class="transparent"></div> <% if widget_body.include? '<' %> - <%= widget_body %> + <% + default_layout=(definition.getWidgetLayout().name()=='DEFAULT') + if default_layout + %> + <div class="widget"> + <% end %> + <%= widget_body -%> + <% if default_layout %><div class="clear"> </div></div><% end %> <% else %> <div class="widget"><p>No data</p></div> <% end %> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/dashboard/_widget.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/dashboard/_widget.html.erb index e6ff5c55943..c97d62e69ae 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/dashboard/_widget.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/dashboard/_widget.html.erb @@ -11,7 +11,14 @@ if widget_body.include?('<') %> - <%= widget_body %> + <% + default_layout=(definition.getWidgetLayout().name()=='DEFAULT') + if default_layout + %> + <div class="widget"> + <% end %> + <%= widget_body -%> + <% if default_layout %><div class="clear"> </div></div><% end %> <% end %> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/dashboards/_widget.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/dashboards/_widget.html.erb index d7c834d0f50..17d5e6f135e 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/dashboards/_widget.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/dashboards/_widget.html.erb @@ -1,5 +1,5 @@ <%
- properties_available=widget_view.getProperties() && widget_view.getProperties().size() != 0
+ properties_available=widget_view.getWidgetProperties() && widget_view.getWidgetProperties().size() != 0
if !properties_available || (widget && widget.state==Widget::STATE_ACTIVE)
begin
@@ -51,7 +51,7 @@ :before => "$(this).down('.widgetid').value=$(this).up('.block').identify().split('_').pop();hide_block_info($(this).up('.block'))" do -%>
<table class="form" align="center" style="border-collapse:separate;border-spacing:5px;">
<tbody>
- <% widget_view.getProperties().each do |property|
+ <% widget_view.getWidgetProperties().each do |property|
db_property_value=widget.widget_property_value(property.key()) if widget
entered_value=params[property.key()]
entered_value=property.defaultValue() if !entered_value || entered_value.empty?
diff --git a/sonar-server/src/main/webapp/stylesheets/dashboard.css b/sonar-server/src/main/webapp/stylesheets/dashboard.css index 321454fa79a..a275105d8c6 100644 --- a/sonar-server/src/main/webapp/stylesheets/dashboard.css +++ b/sonar-server/src/main/webapp/stylesheets/dashboard.css @@ -49,7 +49,7 @@ /*CONFIGURATION*/ #dashboard #widget_defs { - height: 130px; + height: 150px; overflow-y: auto; background-color: #FFF6BF; border: 2px solid #FFD324; @@ -70,6 +70,7 @@ margin: 3px; white-space: normal; vertical-align: top; + height: 80px; } #dashboard ul.widget_categs li { padding-right: 5px; 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 c93558678e0..edc78acaafa 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 @@ -119,7 +119,7 @@ public class ViewProxyTest { public void widgetShouldBeEditable() { ViewProxy proxy = new ViewProxy<Widget>(new EditableWidget()); assertThat(proxy.isEditable(), is(true)); - assertThat(proxy.getProperties().length, is(2)); + assertThat(proxy.getWidgetProperties().length, is(2)); } @Test |