From a450f233393a9e3297fea633373635d060a3c709 Mon Sep 17 00:00:00 2001 From: ulrich <undisclosed> Date: Mon, 20 Mar 2017 13:46:41 +0000 Subject: [PATCH] Compile all mitsamt Resultaten --- web/WEB-INF/web.xml | 2 web/ui/index.html | 18 +++++- web/ui/stile.css | 6 + src/java/de/uhilger/filecms/data/CompilerIssue.java | 10 +- src/java/de/uhilger/filecms/api/CompileService.java | 28 +++++++- web/ui/ui.js | 82 ++++++++++++++++++++++++++- 6 files changed, 128 insertions(+), 18 deletions(-) diff --git a/src/java/de/uhilger/filecms/api/CompileService.java b/src/java/de/uhilger/filecms/api/CompileService.java index ceb507e..b0ce388 100644 --- a/src/java/de/uhilger/filecms/api/CompileService.java +++ b/src/java/de/uhilger/filecms/api/CompileService.java @@ -34,6 +34,7 @@ import javax.tools.JavaFileObject; import javax.tools.StandardJavaFileManager; import javax.tools.ToolProvider; +import org.apache.commons.io.FileUtils; /** * @@ -53,16 +54,27 @@ DiagnosticCollector<JavaFileObject> diagnostics = new DiagnosticCollector(); StandardJavaFileManager fileManager = compiler.getStandardFileManager(diagnostics, null, null); Iterable<? extends JavaFileObject> compilationUnits = fileManager.getJavaFileObjectsFromFiles(files); - compiler.getTask(null, null, diagnostics, null, null, compilationUnits).call(); + + File buildDir = new File(targetDir.getParentFile(), "build"); + final Iterable<String> options = Arrays.asList(new String[]{"-Xlint", + /*"-cp", project.getClassPath(),*/ + /* + ausgehend von src eins hoeher, dann nach build + */ + "-d", buildDir.getAbsolutePath() + }); + FileUtils.deleteDirectory(buildDir); + buildDir.mkdir(); + compiler.getTask(null, null, diagnostics, options, null, compilationUnits).call(); fileManager.close(); - collectResults(diagnostics, compilerIssues); + collectResults(diagnostics, compilerIssues, relPath); } catch(Exception ex) { logger.log(Level.SEVERE, ex.getLocalizedMessage(), ex); } return compilerIssues; } - private void collectResults(DiagnosticCollector<JavaFileObject> diagnostics, List<CompilerIssue> compilerIssues) { + private void collectResults(DiagnosticCollector<JavaFileObject> diagnostics, List<CompilerIssue> compilerIssues, String relPath) { List compileResults = diagnostics.getDiagnostics(); Iterator i = compileResults.iterator(); while (i.hasNext()) { @@ -74,7 +86,13 @@ issue.setKind(err.getKind().name()); issue.setLineNumber(err.getLineNumber()); issue.setMessage(err.getMessage(Locale.GERMANY)); - issue.setSoureName(err.getSource().getName()); + + String srcName = err.getSource().getName().replace("\\", "/"); + String cleanRelPath = relPath.replace(HOME_DIR_NAME + "/", "").replace(PUB_DIR_NAME + "/", ""); + int pos = srcName.indexOf(cleanRelPath); + String className = srcName.substring(pos + cleanRelPath.length()); + issue.setSourceName(className.replace("/", ".").substring(1)); + //issue.setSourceName(srcName + "\r\n" + relPath); compilerIssues.add(issue); } } @@ -142,7 +160,7 @@ } fileManager.close(); List<CompilerIssue> compilerIssues = new ArrayList(); - collectResults(diagnostics, compilerIssues); + collectResults(diagnostics, compilerIssues, relPath); return compilerIssues; } diff --git a/src/java/de/uhilger/filecms/data/CompilerIssue.java b/src/java/de/uhilger/filecms/data/CompilerIssue.java index 5239489..d7c22a0 100644 --- a/src/java/de/uhilger/filecms/data/CompilerIssue.java +++ b/src/java/de/uhilger/filecms/data/CompilerIssue.java @@ -22,17 +22,17 @@ * */ public class CompilerIssue { - private String soureName; + private String sourceName; private String message; private String kind; private long lineNumber; - public String getSoureName() { - return soureName; + public String getSourceName() { + return sourceName; } - public void setSoureName(String soureName) { - this.soureName = soureName; + public void setSourceName(String sourceName) { + this.sourceName = sourceName; } public String getMessage() { diff --git a/web/WEB-INF/web.xml b/web/WEB-INF/web.xml index 05d807e..87b2ceb 100644 --- a/web/WEB-INF/web.xml +++ b/web/WEB-INF/web.xml @@ -7,7 +7,7 @@ Bleibt der Eintrag leer oder wird er ganz weggelassen, wird ein hart kodierter Pfad fuer die WebBox verwendet.</description> <param-name>datenAblage</param-name> - <param-value>/home/ulli/srv/wbx_probe/daten</param-value> + <param-value>C:\Users\hilgeru\Documents\daten</param-value> </context-param> <listener> <description>Der Initialiser setzt globale Variable fuer die Dateiverwaltung</description> diff --git a/web/ui/index.html b/web/ui/index.html index a1a33ad..5e15fc2 100644 --- a/web/ui/index.html +++ b/web/ui/index.html @@ -10,6 +10,14 @@ <link rel="stylesheet" type="text/css" href="/jslib/font-awesome/css/font-awesome.min.css"> <link rel="stylesheet" type="text/css" href="/jslib/lightbox/lightbox.css"> <link rel="stylesheet" type="text/css" href="stile.css"> + <script id="tpl-ci" type="x-tmpl-mustache"> + {{#issues}} + <p class="compiler-issue"> + {{sourceName}}, line {{lineNumber}}<br> + {{kind}}: {{message}} + </p> + {{/issues}} + </script> <script id="tpl-kacheln" type="x-tmpl-mustache"> {{#files}} <figure class="figure datei-figure text-center text-warning align-top datei-elem"> @@ -111,6 +119,7 @@ <a id="m-test" class="dropdown-item" href="#">Test</a> <a id="m-test-2" class="dropdown-item" href="#">Compile</a> <a id="m-test-3" class="dropdown-item" href="#">Compile all</a> + <a id="m-compile-results" class="dropdown-item" href="#">Compile results</a> <div class="dropdown-divider"></div> <a id="logout" class="dropdown-item" href="#">Abmelden</a> </div> @@ -205,11 +214,14 @@ <!-- Modal ok / cancel Ende --> </div> <!-- Fusszeile --> - <!-- <div class="sued"> - Fußzeile + <button id="fusszeile-schliessen" type="button" class="close" aria-label="Close"> + <span aria-hidden="true">×</span> + </button> + <div class="system-out"> + + </div> </div> - --> <!-- Skripte --> <script src="/jslib/jquery/jquery.min.js"></script> <script src="/jslib/codemirror/lib/codemirror.js"></script> diff --git a/web/ui/stile.css b/web/ui/stile.css index 8f704e5..b636ae2 100644 --- a/web/ui/stile.css +++ b/web/ui/stile.css @@ -73,7 +73,11 @@ } .sued { - background-color: lightgray; + background-color: #eee; +} +.system-out { + height: 8em; + overflow-y: auto; } .west { flex-grow: 0; diff --git a/web/ui/ui.js b/web/ui/ui.js index 8182c68..d01cf03 100644 --- a/web/ui/ui.js +++ b/web/ui/ui.js @@ -40,6 +40,7 @@ $("#mce-editor").hide(); $('.codeeditor-space').hide(); $('.code-editor-container').hide(); + $('.sued').hide(); //$('.ost').attr('flex-basis', 0); $('#newTextFile').on('click', fm_menu_neue_textdatei); $('#newDoc').on('click', fm_menu_neues_dokument); @@ -63,10 +64,12 @@ $('#m-test').on('click', fm_menu_test); $('#m-test-2').on('click', fm_menu_compile); $('#m-test-3').on('click', fm_menu_compile_all); + $('#m-compile-results').on('click', fm_fusszeile_zeigen); $('#saveModal').on('hidden.bs.modal', function (e) { $('#modal_ok').attr('onclick','').unbind('click'); }); $('#logout').click(fm_logout); + $('#fusszeile-schliessen').on('click', fm_fusszeile_schliessen); fm_get_login(); fm_get_list(''); fm_init_uploader(); @@ -89,6 +92,14 @@ } catch (err) { } }, 200); +} + +function fm_fusszeile_schliessen() { + $('.sued').hide(); +} + +function fm_fusszeile_zeigen() { + $('.sued').show(); } function fm_get_path(uid) { @@ -266,6 +277,7 @@ */ function fm_gewaehlte_dateien() { var gewaehlte = $('.datei-gewaehlt'); + /* //console.log('anzahl: ' + gewaehlte.length); var fnames = new Array(); var i = 0; @@ -281,7 +293,27 @@ // {"List":[{"java.lang.String":"test3.txt"},{"java.lang.String":"Test1.txt"},{"java.lang.String":"Test2.txt"}]} // und wird auf dem Server zu einer List[ArrayList<String>] bei der jede ArrayList<String> nur ein Element hat return liste; + */ + return fm_dateiliste_bilden(gewaehlte); } + +function fm_dateiliste_bilden(gewaehlte) { + var fnames = new Array(); + var i = 0; + while(i < gewaehlte.length) { + var str = { "java.lang.String": $(gewaehlte[i]).text()}; + fnames.push(str); + //console.log('loeschen ' + pfad + ' ' + $(gewaehlte[i]).text()); + //i += 2; + i++; + } + var liste = '{"List":' + JSON.stringify(fnames) + '}'; + // 'liste' enthaelt: + // {"List":[{"java.lang.String":"test3.txt"},{"java.lang.String":"Test1.txt"},{"java.lang.String":"Test2.txt"}]} + // und wird auf dem Server zu einer List[ArrayList<String>] bei der jede ArrayList<String> nur ein Element hat + return liste; +} + /* --------- Dateifunktionen Ende ---------- */ function fm_menu_test() { @@ -335,21 +367,53 @@ if(resp.List[0].CompilerIssue !== undefined) { var lno; var eMsg; + var issueList = new Array(); if(resp.List[0].CompilerIssue instanceof Array) { var issueNo = 0; while(issueNo < resp.List[0].CompilerIssue.length) { + /* + $('.system-out').append(' +++ ---- +++ '); + $('.system-out').append(resp.List[0].CompilerIssue[issueNo].kind); + $('.system-out').append(resp.List[0].CompilerIssue[issueNo].lineNumber); + $('.system-out').append(resp.List[0].CompilerIssue[issueNo].sourceName); + $('.system-out').append(resp.List[0].CompilerIssue[issueNo].message); + */ + var issue = new CompilerIssue( + resp.List[0].CompilerIssue[issueNo].sourceName, + resp.List[0].CompilerIssue[issueNo].message, + resp.List[0].CompilerIssue[issueNo].kind, + resp.List[0].CompilerIssue[issueNo].lineNumber + ); + issueList.push(issue); + + /* console.log(' +++ ---- +++ '); 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); + */ issueNo++; } } else { - lno = resp.List[0].CompilerIssue.lineNumber; - eMsg = resp.List[0].CompilerIssue.kind + ' ' + resp.List[0].CompilerIssue.message; - console.log(lno + ' ' + eMsg); + //lno = resp.List[0].CompilerIssue.lineNumber; + //eMsg = resp.List[0].CompilerIssue.kind + ' ' + resp.List[0].CompilerIssue.message; + //$('.system-out').append(lno + ' ' + eMsg); + //console.log(lno + ' ' + eMsg); + var issue = new CompilerIssue( + resp.List[0].CompilerIssue.sourceName, + resp.List[0].CompilerIssue.message, + resp.List[0].CompilerIssue.kind, + resp.List[0].CompilerIssue.lineNumber + ); + issueList.push(issue); } + var theList = new IssueList(issueList); + var template = $('#tpl-ci').html(); + Mustache.parse(template); // optional, speeds up future uses + $('.system-out').empty(); + $('.system-out').html(Mustache.render(template, theList)); + $('.sued').show(); } }); } @@ -1045,6 +1109,18 @@ /* ----- Objekte ----- */ +function IssueList(il) { + this.issues = il; +} + +function CompilerIssue(sn, ms, ki, ln) { + var self = this; + this.sourceName = sn; + this.message = ms; + this.kind = ki; + this.lineNumber = ln; +} + function FileList(fl) { this.files = fl; } -- Gitblit v1.9.3