import java.sql.Date;
import java.text.SimpleDateFormat;
import java.util.Scanner;
-
import javax.swing.JEditorPane;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeModel;
import javax.swing.tree.TreeSelectionModel;
-
import org.sonar.batch.protocol.output.BatchReport;
import org.sonar.batch.protocol.output.BatchReport.Component;
import org.sonar.batch.protocol.output.BatchReport.Metadata;
private JScrollPane coverageTab;
private JEditorPane coverageEditor;
private TextLineNumber textLineNumber;
+ private JScrollPane duplicationTab;
+ private JEditorPane duplicationEditor;
/**
* Create the application.
updateHighlighting(component);
updateSource(component);
updateCoverage(component);
+ updateDuplications(component);
}
- private void updateCoverage(Component component) {
- coverageEditor.setText("");
+ private void updateDuplications(Component component) {
+ duplicationEditor.setText("");
if (reader.hasCoverage(component.getRef())) {
- try (CloseableIterator<BatchReport.Coverage> it = reader.readComponentCoverage(component.getRef())) {
+ try (CloseableIterator<BatchReport.Duplication> it = reader.readComponentDuplications(component.getRef())) {
while (it.hasNext()) {
- BatchReport.Coverage coverage = it.next();
- coverageEditor.getDocument().insertString(coverageEditor.getDocument().getEndPosition().getOffset(), coverage.toString() + "\n", null);
+ BatchReport.Duplication dup = it.next();
+ duplicationEditor.getDocument().insertString(duplicationEditor.getDocument().getEndPosition().getOffset(), dup.toString() + "\n", null);
}
} catch (Exception e) {
- throw new IllegalStateException("Can't read code coverage for " + getNodeName(component), e);
+ throw new IllegalStateException("Can't read duplications for " + getNodeName(component), e);
}
}
}
+ private void updateCoverage(Component component) {
+ coverageEditor.setText("");
+ try (CloseableIterator<BatchReport.Coverage> it = reader.readComponentCoverage(component.getRef())) {
+ while (it.hasNext()) {
+ BatchReport.Coverage coverage = it.next();
+ coverageEditor.getDocument().insertString(coverageEditor.getDocument().getEndPosition().getOffset(), coverage.toString() + "\n", null);
+ }
+ } catch (Exception e) {
+ throw new IllegalStateException("Can't read code coverage for " + getNodeName(component), e);
+ }
+ }
+
private void updateSource(Component component) {
File sourceFile = reader.getFileStructure().fileFor(Domain.SOURCE, component.getRef());
sourceEditor.setText("");
private void updateHighlighting(Component component) {
highlightingEditor.setText("");
- if (reader.hasSyntaxHighlighting(component.getRef())) {
- try (CloseableIterator<BatchReport.SyntaxHighlighting> it = reader.readComponentSyntaxHighlighting(component.getRef())) {
- while (it.hasNext()) {
- BatchReport.SyntaxHighlighting rule = it.next();
- highlightingEditor.getDocument().insertString(highlightingEditor.getDocument().getEndPosition().getOffset(), rule.toString() + "\n", null);
- }
- } catch (Exception e) {
- throw new IllegalStateException("Can't read syntax highlighting for " + getNodeName(component), e);
+ try (CloseableIterator<BatchReport.SyntaxHighlighting> it = reader.readComponentSyntaxHighlighting(component.getRef())) {
+ while (it.hasNext()) {
+ BatchReport.SyntaxHighlighting rule = it.next();
+ highlightingEditor.getDocument().insertString(highlightingEditor.getDocument().getEndPosition().getOffset(), rule.toString() + "\n", null);
}
+ } catch (Exception e) {
+ throw new IllegalStateException("Can't read syntax highlighting for " + getNodeName(component), e);
}
}
coverageEditor = new JEditorPane();
coverageTab.setViewportView(coverageEditor);
+ duplicationTab = new JScrollPane();
+ tabbedPane.addTab("Duplications", null, duplicationTab, null);
+
+ duplicationEditor = new JEditorPane();
+ duplicationTab.setViewportView(duplicationEditor);
+
treeScrollPane = new JScrollPane();
treeScrollPane.setPreferredSize(new Dimension(200, 400));
splitPane.setLeftComponent(treeScrollPane);