]> source.dussan.org Git - sonarqube.git/commitdiff
add tab for ActiveRules to scanner report viewer
authorSébastien Lesaint <sebastien.lesaint@sonarsource.com>
Mon, 15 May 2017 08:55:48 +0000 (10:55 +0200)
committerSébastien Lesaint <sebastien.lesaint@sonarsource.com>
Mon, 15 May 2017 08:56:16 +0000 (10:56 +0200)
sonar-scanner-protocol/src/main/java/org/sonar/scanner/protocol/viewer/ScannerReportViewerApp.java

index 846e57db4a7ad03cbb9b84a6c12718e0c779c40f..f78175e033c713a5a19750435fe2addae386aed5 100644 (file)
@@ -95,6 +95,8 @@ public class ScannerReportViewerApp {
   private JEditorPane measuresEditor;
   private JScrollPane scmTab;
   private JEditorPane scmEditor;
+  private JScrollPane activeRuleTab;
+  private JEditorPane activeRuleEditor;
 
   /**
    * Create the application.
@@ -184,6 +186,7 @@ public class ScannerReportViewerApp {
     metadata = reader.readMetadata();
     updateTitle();
     loadComponents();
+    updateActiveRules();
   }
 
   private void loadComponents() {
@@ -317,6 +320,18 @@ public class ScannerReportViewerApp {
     }
   }
 
+  private void updateActiveRules() {
+    activeRuleEditor.setText("");
+
+    StringBuilder builder = new StringBuilder();
+    try (CloseableIterator<ScannerReport.ActiveRule> activeRuleCloseableIterator = reader.readActiveRules()) {
+      while (activeRuleCloseableIterator.hasNext()) {
+        builder.append(activeRuleCloseableIterator.next().toString()).append("\n");
+      }
+      activeRuleEditor.setText(builder.toString());
+    }
+  }
+
   private void updateHighlighting(Component component) {
     highlightingEditor.setText("");
     try (CloseableIterator<ScannerReport.SyntaxHighlightingRule> it = reader.readComponentSyntaxHighlighting(component.getRef())) {
@@ -468,6 +483,12 @@ public class ScannerReportViewerApp {
     scmEditor = new JEditorPane();
     scmTab.setViewportView(scmEditor);
 
+    activeRuleTab = new JScrollPane();
+    tabbedPane.addTab("ActiveRules", null, activeRuleTab, null);
+
+    activeRuleEditor = new JEditorPane();
+    activeRuleTab.setViewportView(activeRuleEditor);
+
     treeScrollPane = new JScrollPane();
     treeScrollPane.setPreferredSize(new Dimension(200, 400));
     splitPane.setLeftComponent(treeScrollPane);