]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-1450: Add creation date of violation to violations tab
authorGodin <mandrikov@gmail.com>
Wed, 1 Dec 2010 13:38:41 +0000 (13:38 +0000)
committerGodin <mandrikov@gmail.com>
Wed, 1 Dec 2010 13:38:41 +0000 (13:38 +0000)
plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/violationsviewer/client/ViolationsPanel.java
sonar-gwt-api/src/main/java/org/sonar/gwt/Utils.java

index 5554154532c823ce05366dc05c746df3da2cbf4d..fc911727fa8aeacffd70c7719b4801883927d1d3 100644 (file)
@@ -68,8 +68,8 @@ public class ViolationsPanel extends SourcePanel {
     filteredViolationsByLine.clear();
     for (Violation violation : violations) {
       if (filter == null || filter.equals("") || violation.getRuleKey().equals(filter) || violation.getPriority().equals(filter)) {
-        Integer line=0;
-        if (violation.getLine()!=null) {
+        Integer line = 0;
+        if (violation.getLine() != null) {
           line = violation.getLine();
         }
         List<Violation> lineViolations = filteredViolationsByLine.get(line);
@@ -115,7 +115,6 @@ public class ViolationsPanel extends SourcePanel {
     return rows;
   }
 
-
   public static class ViolationRow extends Row {
     private Violation violation;
 
@@ -141,7 +140,12 @@ public class ViolationsPanel extends SourcePanel {
     @Override
     public String getColumn4() {
       return "<div class=\"warn\">" + Icons.forPriority(violation.getPriority()).getHTML() + "</img> "
-          + "<a href=\"" + Links.urlForRule(violation.getRuleKey(), false) + "\" onclick=\"window.open(this.href,'rule','height=800,width=900,scrollbars=1,resizable=1');return false;\" title=\"" + violation.getRuleKey() + "\"><b>" + Utils.escapeHtml(violation.getRuleName()) + "</b></a> : " + Utils.escapeHtml(violation.getMessage()) + "</div>";
+          + Utils.formatDateTime(violation.getCreatedAt())
+          + " <a href=\"" + Links.urlForRule(violation.getRuleKey(), false)
+          + "\" onclick=\"window.open(this.href,'rule','height=800,width=900,scrollbars=1,resizable=1');return false;\" title=\""
+          + violation.getRuleKey() + "\"><b>"
+          + Utils.escapeHtml(violation.getRuleName()) + "</b></a> : "
+          + Utils.escapeHtml(violation.getMessage()) + "</div>";
     }
   }
 
index 65abbadb5a1031ebe09c8e7e4f1f93542bf978ae..4b6205071fc2422b5e5aa03c7b6f8c3b33647997 100644 (file)
  */
 package org.sonar.gwt;
 
+import java.util.Date;
+
+import com.google.gwt.i18n.client.DateTimeFormat;
+
 import com.google.gwt.i18n.client.NumberFormat;
 import com.google.gwt.user.client.DOM;
 import com.google.gwt.user.client.Element;
@@ -57,6 +61,20 @@ public final class Utils {
   public static String formatNumber(double number) {
     return NumberFormat.getDecimalFormat().format(number);
   }
+  
+  /**
+   * @since 2.5
+   */
+  public static String formatDate(Date date) {
+    return date == null ? "" : DateTimeFormat.getFormat("dd/MM/yy").format(date);
+  }
+  
+  /**
+   * @since 2.5
+   */
+  public static String formatDateTime(Date date) {
+    return date == null ? "" : DateTimeFormat.getFormat("dd/MM/yy HH:mm").format(date);
+  }
 
   public static native void showError(String message) /*-{
     $wnd.error(message);