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();
}
});
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();
// header
private Grid header = null;
- private ListBox filterBox = null;
+ private ListBox filterBox = null, periodBox = null;
private CheckBox expandCheckbox = null;
private String defaultFilter;
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");
header.setWidget(0, 4, expandCheckbox);
header.getCellFormatter().setStyleName(0, 4, "thin cell left");
- loadRulePriorities();
+ loadRuleSeverities();
return mainPanel;
}
}
}
- 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");
<% 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/>
/**
* @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 {
--- /dev/null
+<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
+++ /dev/null
-<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
--- /dev/null
+<%= 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
+++ /dev/null
-<%= 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
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;
*/
@Deprecated
public String[] getRuleCategories() {
- return ruleCategories;
+ return null;
}
/**
* @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;
}
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;
}
return excludeRuleSeverities;
}
- public void setExcludeRuleSeverities(boolean excludeRuleSeverities) {
+ public ResourceQuery setExcludeRuleSeverities(boolean excludeRuleSeverities) {
this.excludeRuleSeverities = excludeRuleSeverities;
+ return this;
}
/**
* @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;
}
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);
this.createdAt = createdAt;
return this;
}
+
+ /**
+ * @since 2.5
+ */
+ public boolean isCreatedAfter(Date date) {
+ return createdAt!=null && date!=null && !createdAt.before(date);
+ }
}