package org.sonar.batch.protocol.viewer;
import java.awt.BorderLayout;
+import java.awt.Cursor;
import java.awt.Dimension;
import java.awt.EventQueue;
import java.io.File;
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 void updateSource(Component component) {
File sourceFile = reader.getFileStructure().fileFor(Domain.SOURCE, component.getRef());
+ sourceEditor.setText("");
+
if (sourceFile.exists()) {
try (Scanner s = new Scanner(sourceFile, StandardCharsets.UTF_8.name()).useDelimiter("\\Z")) {
- sourceEditor.setText(s.next());
+ if (s.hasNext()) {
+ sourceEditor.setText(s.next());
+ }
} catch (IOException ex) {
StringWriter errors = new StringWriter();
ex.printStackTrace(new PrintWriter(errors));
sourceEditor.setText(errors.toString());
}
- } else {
- sourceEditor.setText("");
}
}
return;
}
+ frame.setCursor(new Cursor(Cursor.WAIT_CURSOR));
updateDetails((Component) node.getUserObject());
+ frame.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
}