diff options
-rw-r--r-- | plugins/sonar-core-gwt/src/main/java/org/sonar/plugins/core/violationsviewer/client/ViolationsPanel.java | 10 | ||||
-rw-r--r-- | plugins/sonar-core-gwt/src/main/java/org/sonar/plugins/core/violationsviewer/client/ViolationsViewer.java | 42 | ||||
-rw-r--r-- | plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/description.html.erb | 2 | ||||
-rw-r--r-- | sonar-gwt-api/src/main/java/org/sonar/gwt/ui/Icons.java | 18 | ||||
-rw-r--r-- | sonar-server/src/main/webapp/WEB-INF/app/views/gwt/_base.html.erb | 51 | ||||
-rw-r--r-- | sonar-server/src/main/webapp/WEB-INF/app/views/gwt/_base.rhtml | 29 | ||||
-rw-r--r-- | sonar-server/src/main/webapp/WEB-INF/app/views/gwt/page.html.erb (renamed from sonar-server/src/main/webapp/WEB-INF/app/views/gwt/page.rhtml) | 0 | ||||
-rw-r--r-- | sonar-ws-client/src/main/java/org/sonar/wsclient/services/ResourceQuery.java | 30 | ||||
-rw-r--r-- | sonar-ws-client/src/main/java/org/sonar/wsclient/services/Violation.java | 7 |
9 files changed, 113 insertions, 76 deletions
diff --git a/plugins/sonar-core-gwt/src/main/java/org/sonar/plugins/core/violationsviewer/client/ViolationsPanel.java b/plugins/sonar-core-gwt/src/main/java/org/sonar/plugins/core/violationsviewer/client/ViolationsPanel.java index b5122536668..8f2f85acabd 100644 --- a/plugins/sonar-core-gwt/src/main/java/org/sonar/plugins/core/violationsviewer/client/ViolationsPanel.java +++ b/plugins/sonar-core-gwt/src/main/java/org/sonar/plugins/core/violationsviewer/client/ViolationsPanel.java @@ -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(); diff --git a/plugins/sonar-core-gwt/src/main/java/org/sonar/plugins/core/violationsviewer/client/ViolationsViewer.java b/plugins/sonar-core-gwt/src/main/java/org/sonar/plugins/core/violationsviewer/client/ViolationsViewer.java index 2afccc73f57..35e00a660d7 100644 --- a/plugins/sonar-core-gwt/src/main/java/org/sonar/plugins/core/violationsviewer/client/ViolationsViewer.java +++ b/plugins/sonar-core-gwt/src/main/java/org/sonar/plugins/core/violationsviewer/client/ViolationsViewer.java @@ -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"); diff --git a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/description.html.erb b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/description.html.erb index 5ad038419f8..69edd07cbe9 100644 --- a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/description.html.erb +++ b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/description.html.erb @@ -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/> diff --git a/sonar-gwt-api/src/main/java/org/sonar/gwt/ui/Icons.java b/sonar-gwt-api/src/main/java/org/sonar/gwt/ui/Icons.java index 10ff4cee076..1f26758cb0f 100644 --- a/sonar-gwt-api/src/main/java/org/sonar/gwt/ui/Icons.java +++ b/sonar-gwt-api/src/main/java/org/sonar/gwt/ui/Icons.java @@ -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 index 00000000000..4f57e2112ff --- /dev/null +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/gwt/_base.html.erb @@ -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 index bc640bf864f..00000000000 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/gwt/_base.rhtml +++ /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.rhtml b/sonar-server/src/main/webapp/WEB-INF/app/views/gwt/page.html.erb index f1cf389a57c..f1cf389a57c 100644 --- 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.html.erb diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/ResourceQuery.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/ResourceQuery.java index 7c9955d3b3f..ee8fc17f77a 100644 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/ResourceQuery.java +++ b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/ResourceQuery.java @@ -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); diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/Violation.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/Violation.java index ff0c3f22ce9..eb89f5ec880 100644 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/Violation.java +++ b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/Violation.java @@ -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); + } } |