From e3043fddcaf5e3ea4beb022c04d411661a3499bd Mon Sep 17 00:00:00 2001
From: ulrich <undisclosed>
Date: Tue, 14 Mar 2017 14:27:13 +0000
Subject: [PATCH] Syntax-Check fuer Java, Gutter Marker fuer Fehler, Tooltips fuer Fehlermeldungen

---
 web/ui/ui.js |   47 ++++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 44 insertions(+), 3 deletions(-)

diff --git a/web/ui/ui.js b/web/ui/ui.js
index 2cfd263..997e9ee 100644
--- a/web/ui/ui.js
+++ b/web/ui/ui.js
@@ -31,6 +31,7 @@
 var loc;
 var PERS_DIR = "Persoenlich";
 var PUB_DIR = "Oeffentlich";
+var compilerIssues;
 
 function fm_init() {
   $("#mce-editor").hide();
@@ -281,9 +282,24 @@
   var liste = fm_gewaehlte_dateien();
   var m = '?c=de.uhilger.filecms.api.CompileService&m=compile&p=' + pfad + '&p=' + encodeURIComponent(liste);
   var u = '../svc' + m;
-  fm_get(u, "text", function(resp) {
-    console.log('compile gab folgendes zurueck: ');
-    console.log(resp);
+  fm_get(u, "json", function(resp) {
+    cm.clearGutter("breakpoints");
+    
+    if(resp.List[0].CompilerIssue !== undefined) {
+      if(resp.List[0].CompilerIssue instanceof Array) {
+        var issueNo = 0;
+        while(issueNo < resp.List[0].CompilerIssue.length) {
+          // console.log(resp.List[0].CompilerIssue[issueNo].kind);
+          // console.log(resp.List[0].CompilerIssue[issueNo].lineNumber);
+          // console.log(resp.List[0].CompilerIssue[issueNo].sourceName);
+          // console.log(resp.List[0].CompilerIssue[issueNo].message);
+          fm_set_code_marker(resp.List[0].CompilerIssue[issueNo].lineNumber, resp.List[0].CompilerIssue[issueNo].kind + ' ' + resp.List[0].CompilerIssue[issueNo].message);
+          issueNo++;
+        }
+      } else {
+        fm_set_code_marker(resp.List[0].CompilerIssue.lineNumber, resp.List[0].CompilerIssue.kind + ' ' + resp.List[0].CompilerIssue.message);
+      }
+    }
   });
 }
 
@@ -843,6 +859,7 @@
 function fm_code_edit(content, m) {
   cm = CodeMirror.fromTextArea(document.getElementById("editspace"), {
     lineNumbers: true,
+    gutters: ["CodeMirror-linenumbers", "breakpoints"],
     mode: m,
     viewportMargin : Infinity,
     tabSize: 2,
@@ -859,6 +876,30 @@
   //cm.setValue(content);
   cm.setValue(unescapeHtml(content));
   cm.getDoc().markClean();
+  cm.on("gutterClick", function(theEditor, lineNumber) {
+    var info = theEditor.lineInfo(lineNumber);
+    //--lineNumber;
+    //console.log(info.gutterMarkers.breakpoints.message);
+    //var marker = info.gutterMarkers.breakpoints;
+    //$(marker).tooltip('toggle');
+  });
+}
+
+function fm_set_code_marker(lineNumber, message) {
+ cm.setGutterMarker(lineNumber-1, "breakpoints", makeMarker(message));
+}
+
+function makeMarker(msg) {
+  var marker = document.createElement("div");
+  marker.style.color = "#822";
+  marker.innerHTML = "●";
+  //marker.message = msg;
+  $(marker).tooltip({
+    placement: 'right',
+    title: msg,
+    offset: '10 -10'
+  });
+  return marker;
 }
 
 

--
Gitblit v1.9.3