Browse Source

Give user errors when compiling. Provide navbar ID.

Bentley James Oakes 7 years ago
parent
commit
236f7e6118
2 changed files with 46 additions and 20 deletions
  1. 45 20
      client/compile_utils.js
  2. 1 0
      client/file_browser.js

+ 45 - 20
client/compile_utils.js

@@ -343,26 +343,51 @@ CompileUtils = function(){
 	/**
 	/**
 	 * Compile the current model to an Abstract Syntax Metamodel
 	 * Compile the current model to an Abstract Syntax Metamodel
 	 */
 	 */
-	this.compileToASMM = function(fname){
-		if( ! __isAbstractSyntaxMetamodel(fname) )
-			WindowManagement.openDialog(
-				_ERROR,
-				'invalid extension... abstract syntax metamodels are "*.metamodel" files');
-		else
-			HttpUtils.httpReq('PUT', HttpUtils.url(fname,__FORCE_GET));
-	};
-	
-	/**
-	 * Compile the current model to a Concrete Syntax Metamodel
-	 */
-	this.compileToCSMM = function(fname){
-		if( ! __isIconMetamodel(fname) )
-			WindowManagement.openDialog(
-				_ERROR,
-				'invalid extension... icon definition metamodels are "*Icons.metamodel" files');
-		else
-			HttpUtils.httpReq('PUT', HttpUtils.url(fname,__FORCE_GET));
-	};
+    this.compileToASMM = function (fname) {
+        if (!__isAbstractSyntaxMetamodel(fname))
+            WindowManagement.openDialog(
+                _ERROR,
+                'invalid extension... abstract syntax metamodels are "*.metamodel" files');
+        else
+            HttpUtils.httpReq('PUT', HttpUtils.url(fname, __FORCE_GET), null,
+                function (status, text) {
+                    //there was a problem
+                    if (!utils.isHttpSuccessCode(status)) {
+                        //let resp = JSON.parse(text);
+                        WindowManagement.openDialog(_ERROR, JSON.stringify(text));
+                    }
+
+                });
+    };
+
+    /**
+     * Compile the current model to a Concrete Syntax Metamodel
+     */
+    this.compileToCSMM = function (fname) {
+        if (!__isIconMetamodel(fname))
+            WindowManagement.openDialog(
+                _ERROR,
+                'invalid extension... icon definition metamodels are "*Icons.metamodel" files');
+        else
+            HttpUtils.httpReq('PUT', HttpUtils.url(fname, __FORCE_GET), null,
+                function (status, text) {
+                    //there was a problem
+                    if (!utils.isHttpSuccessCode(status)) {
+                        let resp = text;
+                        if (!(resp.startsWith("500"))) {
+                            resp = JSON.parse(text);
+                        }
+
+                        if (resp["code"] && resp["code"].includes("ENOENT")) {
+                            let msg = "ERROR: Corresponding metamodel could not be found in same directory!";
+                            WindowManagement.openDialog(_ERROR, msg);
+                        } else {
+                            WindowManagement.openDialog(_ERROR, JSON.stringify(text));
+                        }
+                    }
+
+                });
+    };
 	
 	
 	/**
 	/**
 	 * Compiles the current model to an Icon Pattern Metamodel
 	 * Compiles the current model to an Icon Pattern Metamodel

+ 1 - 0
client/file_browser.js

@@ -368,6 +368,7 @@ class FileBrowser{
                     subfolders.forEach(function (subfolder) {
                     subfolders.forEach(function (subfolder) {
                         var navbutton = $('<button>');
                         var navbutton = $('<button>');
                         navbutton.html(subfolder);
                         navbutton.html(subfolder);
+                        navbutton.attr('id', 'navbar_' + subfolder);
                         navbutton.click(navbuttononclick);
                         navbutton.click(navbuttononclick);
                         navdiv.append(navbutton);
                         navdiv.append(navbutton);
                     });
                     });