]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-3529 Display properties in same order as annotation
authorDavid Gageot <david@gageot.net>
Thu, 5 Jul 2012 07:00:27 +0000 (09:00 +0200)
committerDavid Gageot <david@gageot.net>
Thu, 5 Jul 2012 07:00:27 +0000 (09:00 +0200)
sonar-server/src/main/java/org/sonar/server/ui/ViewProxy.java
sonar-server/src/main/webapp/WEB-INF/app/views/dashboard/_widget_properties.html.erb

index 5945598ca9351c092067a3d48201b7356b1682c1..81422af11cbc080017ada0bc87ec3882f4c83999 100644 (file)
@@ -21,7 +21,8 @@ package org.sonar.server.ui;
 
 import com.google.common.collect.ImmutableSet;
 import com.google.common.collect.ImmutableSetMultimap;
-import com.google.common.collect.LinkedHashMultimap;
+import com.google.common.collect.LinkedListMultimap;
+import com.google.common.collect.ListMultimap;
 import com.google.common.collect.Maps;
 import com.google.common.collect.SetMultimap;
 import org.apache.commons.lang.ArrayUtils;
@@ -65,7 +66,7 @@ public class ViewProxy<V extends View> implements Comparable<ViewProxy> {
   private String[] defaultForMetrics = {};
   private String description = "";
   private Map<String, WidgetProperty> widgetPropertiesByKey = Maps.newHashMap();
-  private SetMultimap<WidgetPropertySet, WidgetProperty> widgetPropertiesBySet = LinkedHashMultimap.create();
+  private ListMultimap<WidgetPropertySet, WidgetProperty> widgetPropertiesBySet = LinkedListMultimap.create();
   private String[] widgetCategories = {};
   private WidgetLayoutType widgetLayout = WidgetLayoutType.DEFAULT;
   private boolean isDefaultTab = false;
@@ -225,8 +226,8 @@ public class ViewProxy<V extends View> implements Comparable<ViewProxy> {
     return widgetPropertiesByKey.values();
   }
 
-  public SetMultimap<WidgetPropertySet, WidgetProperty> getWidgetPropertiesBySet() {
-    return ImmutableSetMultimap.copyOf(widgetPropertiesBySet);
+  public ListMultimap<WidgetPropertySet, WidgetProperty> getWidgetPropertiesBySet() {
+    return widgetPropertiesBySet;
   }
 
   public WidgetProperty getWidgetProperty(String propertyKey) {
index b14797cfcc3979f02a81b8515a017ec103d26ece..348a6ab243db4f8c5a7d437eda42976b1c4687fc 100644 (file)
       </tr>
     <% end %>
 
-    <% widget.java_definition.getWidgetPropertiesBySet().asMap().sort { |(s1,p1), (s2,p2)| natural_comparison(s1.key, s2.key) }.each do |set,properties| %>
-        <% if widget.java_definition.getWidgetPropertiesBySet().asMap().size > 1 %>
-          <% if set.key().empty? %>
-             <tr>
-              <td celspan="2"><h3>other</h3></td>
-            </tr>
-          <% else %>
-            <tr>
-              <td celspan="2"><h3><%= set.key() -%></h3></td>
-            </tr>
-          <% end %>
-        <% end %>
-        <% properties.sort { |w1, w2| natural_comparison(w1.key, w2.key) }.each do |property_def| %>
-         <tr>
-            <td class="form-key-cell"><%= property_def.key() -%><%= " *" unless property_def.optional() -%></td>
-            <td class="form-val-cell" id="row_<%= property_def.key() -%>">
-                <%= property_value_field(property_def, widget.property_text_value(property_def.key())) -%>
-                <div class="form-val-note">
-                    <%= message("widget." + widget.key + ".param." + property_def.key(), :default => property_def.description()) -%>
-                </div>
-            </td>
-         </tr>
+    <% widget.java_definition.getWidgetPropertiesBySet().asMap().each do |set, properties| %>
+      <% if widget.java_definition.getWidgetPropertiesBySet().asMap().size > 1 or !set.key().empty? %>
+        <tr>
+          <td celspan="2"><h3><%= set.key().empty? ? 'other' : set.key() -%></h3></td>
+        </tr>
+      <% end %>
+      <% properties.each do |property_def| %>
+        <tr>
+          <td class="form-key-cell"><%= property_def.key() -%><%= " *" unless property_def.optional() -%></td>
+          <td class="form-val-cell" id="row_<%= property_def.key() -%>">
+            <%= property_value_field(property_def, widget.property_text_value(property_def.key())) -%>
+            <div class="form-val-note">
+              <%= message("widget." + widget.key + ".param." + property_def.key(), :default => property_def.description()) -%>
+            </div>
+          </td>
+        </tr>
       <% end %>
     <% end %>