]> source.dussan.org Git - sonarqube.git/commitdiff
remove ISO categories from ws-client ResourceQuery + minor improvements of GWT API
authorsimonbrandhof <simon.brandhof@gmail.com>
Wed, 15 Dec 2010 18:06:13 +0000 (18:06 +0000)
committersimonbrandhof <simon.brandhof@gmail.com>
Wed, 15 Dec 2010 18:06:13 +0000 (18:06 +0000)
plugins/sonar-core-gwt/src/main/java/org/sonar/plugins/core/violationsviewer/client/ViolationsPanel.java
plugins/sonar-core-gwt/src/main/java/org/sonar/plugins/core/violationsviewer/client/ViolationsViewer.java
plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/description.html.erb
sonar-gwt-api/src/main/java/org/sonar/gwt/ui/Icons.java
sonar-server/src/main/webapp/WEB-INF/app/views/gwt/_base.html.erb [new file with mode: 0644]
sonar-server/src/main/webapp/WEB-INF/app/views/gwt/_base.rhtml [deleted file]
sonar-server/src/main/webapp/WEB-INF/app/views/gwt/page.html.erb [new file with mode: 0644]
sonar-server/src/main/webapp/WEB-INF/app/views/gwt/page.rhtml [deleted file]
sonar-ws-client/src/main/java/org/sonar/wsclient/services/ResourceQuery.java
sonar-ws-client/src/main/java/org/sonar/wsclient/services/Violation.java

index b5122536668976d74118a2baebe1add2f7f228bc..8f2f85acabdf2ac50fd1cf367062c03031c7f28d 100644 (file)
@@ -39,16 +39,16 @@ public class ViolationsPanel extends SourcePanel {
 
   public ViolationsPanel(Resource resource, String filter) {
     super(resource);
-    loadViolations(resource, filter);
+    loadViolations(resource, filter, null);
   }
 
-  protected void loadViolations(final Resource resource, final String filter) {
+  protected void loadViolations(final Resource resource, final String filter, final Date fromDate) {
     Sonar.getInstance().findAll(ViolationQuery.createForResource(resource), new AbstractListCallback<Violation>() {
 
       @Override
       protected void doOnResponse(List<Violation> violations) {
         ViolationsPanel.this.violations = violations;
-        filter(filter);
+        filter(filter, fromDate);
         setStarted();
       }
     });
@@ -62,10 +62,10 @@ public class ViolationsPanel extends SourcePanel {
     this.expand = expand;
   }
 
-  public void filter(String filter) {
+  public void filter(String filter, Date fromDate) {
     filteredViolationsByLine.clear();
     for (Violation violation : violations) {
-      if (filter == null || filter.equals("") || violation.getRuleKey().equals(filter) || violation.getPriority().equals(filter)) {
+      if (filter == null || filter.equals("") || violation.getRuleKey().equals(filter) || violation.getSeverity().equals(filter) || violation.isCreatedAfter(fromDate)) {
         Integer line = 0;
         if (violation.getLine() != null) {
           line = violation.getLine();
index 2afccc73f57354d794210f6504015cdbcf160758..35e00a660d799da2aceb2fef5c297b28d4c0275d 100644 (file)
@@ -48,7 +48,7 @@ public class ViolationsViewer extends Page {
 
   // header
   private Grid header = null;
-  private ListBox filterBox = null;
+  private ListBox filterBox = null, periodBox = null;
   private CheckBox expandCheckbox = null;
   private String defaultFilter;
 
@@ -73,22 +73,27 @@ public class ViolationsViewer extends Page {
     initDefaultFilter();
     sourcePanel = new ViolationsPanel(resource, defaultFilter);
 
-    header.setHTML(0, 1, "<div class='cell'><span class='note'>" + I18nConstants.INSTANCE.filter() + "</span></div>");
     header.getCellFormatter().setStyleName(0, 1, "right");
 
     filterBox = new ListBox();
     filterBox.addItem(I18nConstants.INSTANCE.noFilters(), "");
     filterBox.setStyleName("small");
-
     filterBox.addChangeHandler(new ChangeHandler() {
       public void onChange(ChangeEvent event) {
         String filter = filterBox.getValue(filterBox.getSelectedIndex());
         loadSources();
-        sourcePanel.filter(filter);
+        sourcePanel.filter(filter, null);
         sourcePanel.refresh();
       }
     });
 
+    periodBox = new ListBox();
+    periodBox.addItem(I18nConstants.INSTANCE.noFilters(), "");
+    periodBox.setStyleName("small");
+
+    header.setWidget(0, 1, periodBox);
+    header.getCellFormatter().setStyleName(0, 1, "thin cell right");
+
     header.setWidget(0, 2, filterBox);
     header.getCellFormatter().setStyleName(0, 2, "thin cell right");
 
@@ -106,7 +111,7 @@ public class ViolationsViewer extends Page {
     header.setWidget(0, 4, expandCheckbox);
     header.getCellFormatter().setStyleName(0, 4, "thin cell left");
 
-    loadRulePriorities();
+    loadRuleSeverities();
     return mainPanel;
   }
 
@@ -117,42 +122,41 @@ public class ViolationsViewer extends Page {
     }
   }
 
-  private void loadRulePriorities() {
+  private void loadRuleSeverities() {
     final ResourceQuery query = ResourceQuery.createForResource(resource, Metrics.BLOCKER_VIOLATIONS,
-        Metrics.CRITICAL_VIOLATIONS, Metrics.MAJOR_VIOLATIONS, Metrics.MINOR_VIOLATIONS, Metrics.INFO_VIOLATIONS)
-        .setExcludeRulePriorities(true);
+        Metrics.CRITICAL_VIOLATIONS, Metrics.MAJOR_VIOLATIONS, Metrics.MINOR_VIOLATIONS, Metrics.INFO_VIOLATIONS);
     Sonar.getInstance().find(query, new AbstractCallback<Resource>(loading) {
       @Override
       protected void doOnResponse(Resource resource) {
         setResourceHasViolations(resource);
-        displayRulePriorities(resource);
+        displayRuleSeverities(resource);
         loadRules(resource);
       }
     });
   }
 
-  private void displayRulePriorities(Resource resource) {
+  private void displayRuleSeverities(Resource resource) {
     final Grid grid = new Grid(1, 10);
     header.setWidget(0, 0, grid);
 
-    displayRulePriority(grid, 0, "BLOCKER", resource.getMeasure(Metrics.BLOCKER_VIOLATIONS));
-    displayRulePriority(grid, 2, "CRITICAL", resource.getMeasure(Metrics.CRITICAL_VIOLATIONS));
-    displayRulePriority(grid, 4, "MAJOR", resource.getMeasure(Metrics.MAJOR_VIOLATIONS));
-    displayRulePriority(grid, 6, "MINOR", resource.getMeasure(Metrics.MINOR_VIOLATIONS));
-    displayRulePriority(grid, 8, "INFO", resource.getMeasure(Metrics.INFO_VIOLATIONS));
+    displayRuleSeverity(grid, 0, "BLOCKER", resource.getMeasure(Metrics.BLOCKER_VIOLATIONS));
+    displayRuleSeverity(grid, 2, "CRITICAL", resource.getMeasure(Metrics.CRITICAL_VIOLATIONS));
+    displayRuleSeverity(grid, 4, "MAJOR", resource.getMeasure(Metrics.MAJOR_VIOLATIONS));
+    displayRuleSeverity(grid, 6, "MINOR", resource.getMeasure(Metrics.MINOR_VIOLATIONS));
+    displayRuleSeverity(grid, 8, "INFO", resource.getMeasure(Metrics.INFO_VIOLATIONS));
   }
 
-  private void displayRulePriority(final Grid grid, final int column, final String priority, final Measure measure) {
+  private void displayRuleSeverity(final Grid grid, final int column, final String severity, final Measure measure) {
     String value = "0";
     if (measure != null) {
       value = measure.getFormattedValue();
-      filterBox.addItem(priority + " (" + value + ")", priority);
-      if (priority.equals(defaultFilter)) {
+      filterBox.addItem(severity + " (" + value + ")", severity);
+      if (severity.equals(defaultFilter)) {
         filterBox.setSelectedIndex(filterBox.getItemCount() - 1);
       }
     }
 
-    grid.setHTML(0, column, Icons.forPriority(priority).getHTML());
+    grid.setHTML(0, column, Icons.forSeverity(severity).getHTML());
     grid.setHTML(0, column + 1, value);
     grid.getCellFormatter().setStyleName(0, column, "thin metric right");
     grid.getCellFormatter().setStyleName(0, column + 1, "thin left value");
index 5ad038419f88b66ebacc24faae22ff9b3e71b19b..69edd07cbe9f66f615ead1dab9259ba3254bb887 100644 (file)
@@ -32,7 +32,7 @@
     <% end %>
     <% unless @project.project_links.empty? %>
       <tr>
-        <td>Links: </td>
+        <td valign="top">Links: </td>
         <td id="resource_links">
         <% @project.project_links.sort.each do |link| %>
           <%= link_to(image_tag(link.icon, :alt => link.name), link.href , :popup => true, :class => 'nolink') -%> <%= link_to(h(link.name), link.href, :popup => true) -%><br/>
index 10ff4cee076109fb3a9d97eae9ce3e145bee8913..1f26758cb0f9ee4713f694770586992d4980fa65 100644 (file)
@@ -79,22 +79,30 @@ public final class Icons {
 
   /**
    * @since 2.2
+   * @deprecated since 2.5 use {@link Icons#forSeverity(String)}
    */
   public static AbstractImagePrototype forPriority(final String priority) {
+    return forSeverity(priority);
+  }
+
+  /**
+   * @since 2.5
+   */
+  public static AbstractImagePrototype forSeverity(final String severity) {
     AbstractImagePrototype image;
-    if ("BLOCKER".equals(priority)) {
+    if ("BLOCKER".equals(severity)) {
       image = get().priorityBlocker();
 
-    } else if ("CRITICAL".equals(priority)) {
+    } else if ("CRITICAL".equals(severity)) {
       image = get().priorityCritical();
 
-    } else if ("MAJOR".equals(priority)) {
+    } else if ("MAJOR".equals(severity)) {
       image = get().priorityMajor();
 
-    } else if ("MINOR".equals(priority)) {
+    } else if ("MINOR".equals(severity)) {
       image = get().priorityMinor();
 
-    } else if ("INFO".equals(priority)) {
+    } else if ("INFO".equals(severity)) {
       image = get().priorityInfo();
 
     } else {
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/gwt/_base.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/gwt/_base.html.erb
new file mode 100644 (file)
index 0000000..4f57e21
--- /dev/null
@@ -0,0 +1,51 @@
+<script type="text/javascript">
+  var config = {
+    "sonar_url":"<%= url_for(:controller => '/', :action => '', :only_path => true, :trailing_slash => false)[0...-2] -%>",
+    "version":"<%= sonar_version -%>",
+    "popup":<%= popup -%>
+<% if metric %>
+    ,"metric": "<%= metric -%>"
+<% end
+   if resource
+%>
+    ,"resource_key": "<%= resource.id -%>",
+    "resource":[{"id": <%= resource.id -%>, "key":"<%= resource.key -%>","scope": "<%= resource.scope -%>", "qualifier": "<%= resource.qualifier -%>", "name": "<%= resource.name -%>", "lang":"<%= resource.language -%>"}]
+    <% end %>
+    <% if @snapshot %>
+      <% if @snapshot.project_snapshot.period1_mode %>
+        ,"period1": "<%= @snapshot.project_snapshot.period1_mode -%>"
+        ,"period1_date": "<%= @snapshot.project_snapshot.period1_date.strftime("%Y-%m-%dT%H:%M:%S%z") -%>"
+      <% end
+         if @snapshot.project_snapshot.period2_mode %>
+        ,"period2": "<%= @snapshot.project_snapshot.period2_mode -%>"
+        ,"period2_date": "<%= @snapshot.project_snapshot.period2_date.strftime("%Y-%m-%dT%H:%M:%S%z") -%>"
+      <% end
+         if @snapshot.project_snapshot.period3_mode %>
+        ,"period3": "<%= @snapshot.project_snapshot.period3_mode -%>"
+        ,"period3_date": "<%= @snapshot.project_snapshot.period3_date.strftime("%Y-%m-%dT%H:%M:%S%z") -%>"
+      <% end
+         if @snapshot.project_snapshot.period4_mode %>
+        ,"period4": "<%= @snapshot.project_snapshot.period4_mode -%>"
+        ,"period4_date": "<%= @snapshot.project_snapshot.period4_date.strftime("%Y-%m-%dT%H:%M:%S%z") -%>"
+      <% end
+         if @snapshot.project_snapshot.period5_mode %>
+        ,"period5": "<%= @snapshot.project_snapshot.period5_mode -%>"
+        ,"period5_date": "<%= @snapshot.project_snapshot.period5_date.strftime("%Y-%m-%dT%H:%M:%S%z") -%>"
+      <% end %>
+    <% end %>
+  };
+
+  var rp = {
+  <%
+    index=0
+    params.each do |key,value|  
+  %>
+    <%= ',' if index>0 -%>"<%= key -%>":"<%= value -%>"
+  <%
+      index+=1
+    end
+  %>
+  };
+
+  var modules = new Object();
+</script>
\ No newline at end of file
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/gwt/_base.rhtml b/sonar-server/src/main/webapp/WEB-INF/app/views/gwt/_base.rhtml
deleted file mode 100644 (file)
index bc640bf..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-<script type="text/javascript">
-  var config = {
-    "sonar_url":"<%= url_for(:controller => '/', :action => '', :only_path => true, :trailing_slash => false)[0...-2] -%>",
-    "version":"<%= sonar_version -%>",
-    "popup":<%= popup -%>
-<% if metric %>
-    ,"metric": "<%= metric -%>"
-<% end
-   if resource
-%>
-    ,"resource_key": "<%= resource.id -%>",
-    "resource":[{"id": <%= resource.id -%>, "key":"<%= resource.key -%>","scope": "<%= resource.scope -%>", "qualifier": "<%= resource.qualifier -%>", "name": "<%= resource.name -%>", "lang":"<%= resource.language -%>"}]
-    <% end %>
-  };
-
-  var rp = {
-  <%
-    index=0
-    params.each do |key,value|  
-  %>
-    <%= ',' if index>0 -%>"<%= key -%>":"<%= value -%>"
-  <%
-      index+=1
-    end
-  %>
-  };
-
-  var modules = new Object();
-</script>
\ No newline at end of file
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/gwt/page.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/gwt/page.html.erb
new file mode 100644 (file)
index 0000000..f1cf389
--- /dev/null
@@ -0,0 +1,7 @@
+<%= render :partial => 'gwt/base', :locals => {:resource => @project, :popup => false, :metric => nil} %>
+<div id="gwtpage"> </div>
+
+<!-- for SmartGWT -->
+<script> var isomorphicDir = "<%= "#{ApplicationController.root_context}/deploy/gwt/#{@gwt_id}" -%>/sc/";</script>
+
+<script type="text/javascript" src="<%= "#{ApplicationController.root_context}/deploy/gwt/#{@gwt_id}/#{@gwt_id}.nocache.js?#{sonar_version}" -%>"></script>
\ No newline at end of file
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/gwt/page.rhtml b/sonar-server/src/main/webapp/WEB-INF/app/views/gwt/page.rhtml
deleted file mode 100644 (file)
index f1cf389..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-<%= render :partial => 'gwt/base', :locals => {:resource => @project, :popup => false, :metric => nil} %>
-<div id="gwtpage"> </div>
-
-<!-- for SmartGWT -->
-<script> var isomorphicDir = "<%= "#{ApplicationController.root_context}/deploy/gwt/#{@gwt_id}" -%>/sc/";</script>
-
-<script type="text/javascript" src="<%= "#{ApplicationController.root_context}/deploy/gwt/#{@gwt_id}/#{@gwt_id}.nocache.js?#{sonar_version}" -%>"></script>
\ No newline at end of file
index 7c9955d3b3fa65771812797e014f68e25eb21e63..ee8fc17f77a390d7a76b7251ff3fd745243f0eb3 100644 (file)
@@ -31,17 +31,10 @@ public class ResourceQuery extends Query<Resource> {
   private String[] qualifiers;
   private String[] metrics;
   private String[] rules;
-
-  /**
-   * @deprecated since 2.5 See http://jira.codehaus.org/browse/SONAR-2007
-   */
-  private String[] ruleCategories;
-
   private String[] ruleSeverities;
   private String[] characteristicKeys;
   private String model;
   private boolean excludeRules = true;
-  private boolean excludeRuleCategories = true;
   private boolean excludeRuleSeverities = true;
   private Boolean includeTrends = null;
   private Boolean verbose = Boolean.FALSE;
@@ -141,7 +134,7 @@ public class ResourceQuery extends Query<Resource> {
    */
   @Deprecated
   public String[] getRuleCategories() {
-    return ruleCategories;
+    return null;
   }
 
   /**
@@ -149,8 +142,6 @@ public class ResourceQuery extends Query<Resource> {
    * @deprecated since 2.5 See http://jira.codehaus.org/browse/SONAR-2007
    */
   public ResourceQuery setRuleCategories(String... ruleCategories) {
-    this.ruleCategories = ruleCategories;
-    this.excludeRuleCategories = false;
     return this;
   }
 
@@ -196,12 +187,17 @@ public class ResourceQuery extends Query<Resource> {
     return this;
   }
 
+  /**
+   * @deprecated since 2.5 not used anymore
+   */
   public boolean isExcludeRuleCategories() {
-    return excludeRuleCategories;
+    return false;
   }
 
-  public ResourceQuery setExcludeRuleCategories(boolean excludeRuleCategories) {
-    this.excludeRuleCategories = excludeRuleCategories;
+  /**
+   * @deprecated since 2.5 not used anymore
+   */
+  public ResourceQuery setExcludeRuleCategories(boolean b) {
     return this;
   }
 
@@ -212,8 +208,9 @@ public class ResourceQuery extends Query<Resource> {
     return excludeRuleSeverities;
   }
 
-  public void setExcludeRuleSeverities(boolean excludeRuleSeverities) {
+  public ResourceQuery setExcludeRuleSeverities(boolean excludeRuleSeverities) {
     this.excludeRuleSeverities = excludeRuleSeverities;
+    return this;
   }
 
   /**
@@ -228,8 +225,8 @@ public class ResourceQuery extends Query<Resource> {
    * @deprecated since 2.5 use {@link #setExcludeRuleSeverities(boolean)} instead. See http://jira.codehaus.org/browse/SONAR-1829
    */
   @Deprecated
-  public ResourceQuery setExcludeRulePriorities(boolean excludeRulePriorities) {
-    this.excludeRuleSeverities = excludeRulePriorities;
+  public ResourceQuery setExcludeRulePriorities(boolean b) {
+    this.excludeRuleSeverities = b;
     return this;
   }
 
@@ -262,7 +259,6 @@ public class ResourceQuery extends Query<Resource> {
     appendUrlParameter(url, "depth", depth);
     appendUrlParameter(url, "limit", limit);
     appendRuleField(url, "rules", excludeRules, rules);
-    appendRuleField(url, "rule_categories", excludeRuleCategories, ruleCategories);
     appendRuleField(url, "rule_priorities", excludeRuleSeverities, ruleSeverities);
     appendUrlParameter(url, "includetrends", includeTrends);
     appendUrlParameter(url, "model", model);
index ff0c3f22ce9289b329f96519d2613275be6e138d..eb89f5ec8806416fb0a68396d952029e14cf3d7d 100644 (file)
@@ -147,4 +147,11 @@ public class Violation extends Model {
     this.createdAt = createdAt;
     return this;
   }
+
+  /**
+   * @since 2.5
+   */
+  public boolean isCreatedAfter(Date date) {
+    return createdAt!=null && date!=null && !createdAt.before(date);
+  }
 }