vasco 8 年之前
父節點
當前提交
a5be6a8769
共有 9 個文件被更改,包括 249 次插入21 次删除
  1. 184 0
      client/client.js
  2. 3 2
      client/gui_utils.js
  3. 12 6
      client/query_response.js
  4. 41 0
      client/window_management.js
  5. 2 7
      csworker.js
  6. 1 1
      mt/ptcal/dapi.py
  7. 2 2
      run_AToMPM.sh
  8. 2 2
      users/(default)/Models/SCCD/train.model
  9. 2 1
      users/(default)/prefs

+ 184 - 0
client/client.js

@@ -69,6 +69,10 @@ var __user = undefined,
 	 __edges = {},
 	 __canvas,
 	 __saveas;
+	 __option = '',
+	 __trafo = '',
+	 __msg = '',
+	 __name = '';
 /******************************** GLOBAL VARS *********************************/
 
 AtomPMClient = function(){
@@ -276,6 +280,8 @@ function _loadModel(fname)
 		else
 			__saveas = fname;
 		DataUtils.loadm(fname);
+		if (__msg != '')
+			WindowManagement.openDialog(_CUSTOM,{'widgets':[{'id':'1','type':'text','label':'text message','default':''}],"title":__msg});
 	}
 }
 
@@ -289,6 +295,8 @@ function _loadToolbar(fname)
 		DataUtils.loadbm(fname);
 	else if( __isIconMetamodel(fname) )
 		DataUtils.loadmm(fname);
+	if (__msg != '')
+		WindowManagement.openDialog(_CUSTOM,{'widgets':[{'id':'1','type':'text','label':'text message','default':''}],"title":__msg});
 }
 
 /* save model
@@ -536,6 +544,182 @@ function _loadModelInNewWindow(args/*fname[,callback-url]*/)
 	WindowManagement.spawnClient(args['fname'],args['callback-url']);
 }
 
+/**
+ * Function to load a model in a new window, it's part of Workflows components
+ * @param args json that contains the parameter list
+ */
+function _loadModelInWindow(args/*fname[]*/)
+{
+	var aid = args['atompmId'];
+	var jsontext = args['fname'];
+	var res = jsontext.replace('{', '{"');
+	var res = res.replace('}', '"}');
+	var res = res.replace(/:/g, '":"');
+	var res = res.replace(/,/g, '","');
+	var res = res.replace(/;/g, ',');
+	loc = JSON.parse(res);
+	var path = parseInt(aid)+2;
+	var msg = parseInt(aid)+1;
+	vas = '';
+	if (loc[path] == undefined){
+		vas = 'VAS';
+		path = parseInt(aid);}
+	as = loc[aid].indexOf("MM");
+	cs = loc[aid].indexOf("Icons");
+	tr = loc[aid].indexOf("R_");
+	tf = loc[path].indexOf("T_");
+	option = '';
+	if( as > 0 )
+		option = 'AS';
+	else if(cs > 0 )
+		option = 'CS';
+	else if(tr > 0 )
+		option = 'TR';
+	else if(tf > 0 )
+		option = 'TF';
+	else if (vas == 'VAS')
+		option = 'VAS';;
+	WindowManagement.spawnClientOption(loc[aid],'',loc[path],option,loc[msg]);
+}
+
+/**
+ * Function to open a popup dialog for run-time parameters, it's part of Workflows components 
+ * @param args list of parameters of the workflow
+ */
+
+function _openNewDialog(args)
+{
+	var jsontext = JSON.stringify(args['args']),
+	jsontext=JSON.parse(jsontext),
+	ext = args['labels'],
+	pid = args['paramId'],
+	res = ext.replace('{', '{"'),
+	res = res.replace('}', '"}'),
+	res = res.replace(/:/g, '":"'),
+	res = res.replace(/,/g, '","'),
+	msg =  args['msg'];
+	if( ext == '{}' )
+		WindowManagement.openDialog(_ERROR, 'No parameters to load');
+	else {
+		ext = JSON.parse(res);		
+		data = '';
+		i = 0;
+		callback = 
+			function(inputs) 
+		 	{
+				for( var x in inputs ){
+					if (data){ 
+						data += ',';
+					}
+					lab = jsontext.widgets[i].label;
+					n = lab.lastIndexOf("(");
+					lab = lab.substring(n);
+					i = i + 1;
+					t = [];	
+					switch(lab) {
+						case '(OpenModel)Location@2':
+							data += x+':'+inputs[x]+'.'+ext[x];
+						break;
+						case '(SaveModel)Location@2':
+							if (ext[x] == 'Icons.model' || ext[x] == 'Icons.metamodel'|| ext[x] == 'Icons.pattern.metamodel')						
+								data += x+':'+inputs[x]+ext[x];
+							else
+								data += x+':'+inputs[x]+'.'+ext[x];								
+						break;
+						case '(LoadToolbar)Location@2':
+							toolbars = inputs[x].split(";");
+							extensions = ext[x].split(";");
+							for ( var n in toolbars){
+								if (extensions[n] == 'Icons.model' || extensions[n] == 'Icons.metamodel'|| extensions[n] == 'Icons.pattern.metamodel')
+									t[n] = toolbars[n]+extensions[n];
+								else
+									t[n] = toolbars[n]+'.'+extensions[n];
+							}
+							txt = t.join(";");
+							data += x+':'+txt;
+						break;
+						case '(GeneratePMM)Location@2':
+							data += x+':'+inputs[x]+'.'+ext[x];
+						break;	
+						case '(OpenTransformation)Location@2':
+							data += x+':'+inputs[x]+'.'+ext[x];
+						break;			
+					} 
+					_updateAttr({"asid":x,"attr":"Location@2","val":inputs[x]});
+				}
+				data += ','+msg;				
+				data = '{'+data;
+				data += '}'
+				_updateAttr({"asid":pid,"attr":"parameterList","val":data});
+				play = function()
+               {
+					_httpReq(
+                       'PUT',
+                       '/__mt/execmode?wid='+__wid,
+                       {'mode':'play'});
+               };
+				_httpReq(
+					'PUT',
+					'/__mt/current.transform?wid='+__wid,
+					{'transfs':['/Formalisms/Workflows/simulate/T_WorkflowsAddDependParam.model'],
+					'username':__user},
+					play);
+			 };
+		WindowManagement.openDialog(
+				_CUSTOM,
+				args['args'],
+				 callback);
+	}
+}
+
+/**
+ * Function to load a toolbar in a new window, it's part of Workflows components 
+ * @param args json that contains the parameter list
+ */
+function _loadToolbarInWindow(args/*fname[]*/)	
+{
+	var aid = args['atompmId'];
+	var jsontext = args['fname'];
+	var res = jsontext.replace('{', '{"');
+	var res = res.replace('}', '"}');
+	var res = res.replace(/:/g, '":"');
+	var res = res.replace(/,/g, '","');
+	var res = res.replace(/;/g, ',');
+	loc = JSON.parse(res);
+	var path = parseInt(aid)+2;
+	var msg = parseInt(aid)+1;
+	as = loc[aid].indexOf("SimpleClassDiagram");
+	cs = loc[aid].indexOf("ConcreteSyntax");
+	tr = loc[aid].indexOf("Rule");
+	tf = loc[aid].indexOf("MoTif");
+	option = '';
+	if( as > 0 )
+		option = 'AS';
+	else if(cs > 0 )
+		option = 'CS';
+	else if(tr > 0 )
+		option = 'TR';
+	else if(tf > 0 )
+		option = 'TF';;	
+	WindowManagement.spawnClientOption(loc[path],loc[aid],option,'',loc[msg]);
+}
+
+/**
+ * Function to compile a Pattern metamodel, it's part of Workflows components 
+ * @param args json that contains the parameter list
+ */
+function _compilePMMInWindow(args/*fname[]*/)	
+{
+	var aid = args['atompmId'];
+	var jsontext = args['fname'];
+	var res = jsontext.replace('{', '{"');
+	var res = res.replace('}', '"}');
+	var res = res.replace(/:/g, '":"');
+	var res = res.replace(/,/g, '","');
+	loc = JSON.parse(res);
+	console.log(loc[aid]);	
+	CompileUtils.compileToPatternMM(loc[aid]);
+}
 
 /* tag the specified node with some text, possibly appending it to an existing 
 	tag...  the 'timeout' parameter, if specified, indicates how long the tag 

+ 3 - 2
client/gui_utils.js

@@ -515,7 +515,8 @@ GUIUtils = function(){
 				
 				return true;
 			}
-			else if( event.keyCode == KEY_ENTER )
+			/*rolled back behaviour by popular demand (Eugene) - Vasco 4-2-17 */
+			else if( event.keyCode == KEY_ENTER /* ENTER */ && currentKeys[ KEY_SHIFT ] == 1)
 			{
                 if (rows > 1) {
                     // only for multi-line input fields
@@ -531,7 +532,7 @@ GUIUtils = function(){
 			}
 		});
         input.keyup( function (event) {
-			if( event.keyCode == KEY_ENTER )
+			if( event.keyCode == KEY_ENTER /* ENTER */ && currentKeys[ KEY_SHIFT ] == 1)
 			{
 				event.stopPropagation();
                 event.preventDefault();

+ 12 - 6
client/query_response.js

@@ -147,6 +147,16 @@ function __handleChangelog(changelog,seqNum,hitchhiker)
 				{
 					var newVal = step['new_val'],
 						 icon	  = __icons[step['id']]['icon'];
+						 
+					/* bugfix where newVal would get a string instead of the array of values 
+					should search for reason why it has string in the first place - Vasco - 02-02-2017*/
+					if( typeof newVal == 'string'){
+						newVal = newVal.replace('[','');
+						newVal = newVal.replace(']','');
+						newVal = newVal.split(',');
+					}
+					/* endbugfix*/
+					
 					if( step['attr'] == 'position' )
 					{
 						var bbox = icon.getBBox();
@@ -273,12 +283,8 @@ function __handleChangelog(changelog,seqNum,hitchhiker)
 						 		utils.contains(['r','rays'],attr) )
 						__editStar(vobj,attr,step['new_val']);
 
-                    if( vobj.type == 'text' )
-						var newVal = step['new_val'];
-                    else {
-                        try 			{var newVal = utils.jsonp(step['new_val']);}
-                        catch(err)	{var newVal = step['new_val'];}
-                    }
+					try 			{var newVal = utils.jsonp(step['new_val']);}
+					catch(err)	{var newVal = step['new_val'];}
 					if( attr == 'style' )
 						vobj.attr( newVal );
 					else if( attr == 'src' )

+ 41 - 0
client/window_management.js

@@ -815,6 +815,47 @@ WindowManagement = function(){
 	
 		onspawn();
 	};
+
+	/* NOTE:: Automating activities 
+	    spawn a new instance of atompm... if a model is specified (as 'fname'), it is
+		loaded into the new instance, if a toolbar is especified (as 'tbname'), it's loaded
+		into the new instance, if a message is especified a popup message will show in
+		the instance*/	
+	this.spawnClientOption = function (fname,tbname,option,trafo,msg)
+	{
+		var c 		= window.open(window.location.href, '_blank'),
+		onspawn = 
+			 function()
+			 {
+				if( (fname|| tbname)	 &&
+					  (c.__wid == undefined 	 || 
+					   c.__aswid == undefined 	 || 
+					   c._loadModel == undefined	 ||
+					   c._loadToolbar == undefined) )
+			 		 return window.setTimeout(onspawn,250);				 
+				 c.__user = __user;
+				 c.__name = fname;
+				 c.__option = option;
+				 c.__trafo = trafo;
+				 c.__msg = msg;
+				if (trafo == undefined){
+					trafo = option
+				}
+				if( tbname ){
+						toolbars = tbname.split(",");
+						for ( var n in toolbars){
+							c._loadToolbar(toolbars[n]);
+						}						
+				}				
+				if( fname ){
+						c.__saveas = fname;
+						if( option.length > 2 ){
+							c._loadModel(fname);
+						}
+				}	
+			  };
+		onspawn();
+	};
 	
 	/* initialize a headless client, i.e. a client with a proper backend but whose
 	socket-message handling code is user-defined

+ 2 - 7
csworker.js

@@ -711,13 +711,8 @@ with AToMPM.  If not, see <http://www.gnu.org/licenses/>.
 					continue;
 
 				var ldi 		= vobjs[vid]['$linkDecoratorInfo']['value'],
-					 pp  		= _svg.fns.getPointOnPathAtRatio(path,ldi.xratio);
-					 
-				if (pp == undefined) {
-					continue;
-				}
-                
-				var	 yoffset	= new _svg.types.Point(0,ldi.yoffset).rotate(pp.O),
+					 pp  		= _svg.fns.getPointOnPathAtRatio(path,ldi.xratio),
+					 yoffset	= new _svg.types.Point(0,ldi.yoffset).rotate(pp.O),
 					 endAt	= (ldi.xratio >= 1 ? 
 						 				new _svg.types.Point(100,0).rotate(pp.O) :
 										new _svg.types.Point(0,0)),

+ 1 - 1
mt/ptcal/dapi.py

@@ -192,7 +192,7 @@ class DesignerAPI :
 		for pLabel in self._pl2gi :
 			n = self._graph.vs[self._pl2gi[pLabel]]
 			if fulltypes == None or n[HC.FULLTYPE] in fulltypes :
-				pLabels.append(pLabel)
+				pLabels.append(n)
 		return pLabels
 
 

+ 2 - 2
run_AToMPM.sh

@@ -14,8 +14,8 @@ if [ ! -d "dependencies" ]; then
     cd dependencies
     # First fetch Node.JS
     curl -L -O http://msdl.uantwerpen.be/AToMPM/node-v4.5.0.tar.gz
-    tar -xvzf node-v4.5.0.tar.gz
-    cd node-v4.5.0
+    tar -xvzf node*
+    cd node*
     ./configure --prefix=$working_dir/dependencies/node.js
     make -j5
     make install

+ 2 - 2
users/(default)/Models/SCCD/train.model

@@ -1030,7 +1030,7 @@
 								}
 							],
 							"returntype": "",
-							"body": "self.root, self.acceleration, self.speed = root, 0.0, 0.0/*newline*/self.root.trainIs(self)"
+							"body": "self.root, self.acceleration, self.velocity = root, 0.0, 0.0/*newline*/self.root.trainIs(self)"
 						},
 						{
 							"name": "updateState",
@@ -1152,4 +1152,4 @@
 			"/Formalisms/SCCD/SCCD"
 		]
 	}
-}
+}

+ 2 - 1
users/(default)/prefs

@@ -20,7 +20,8 @@
 		"value": [
 			"/Toolbars/CompileMenu/CompileMenu.buttons.model",
 			"/Toolbars/TransformationController/TransformationController.buttons.model",
-			"/Toolbars/TransformationEditor/TransformationEditor.buttons.model"
+			"/Toolbars/TransformationEditor/TransformationEditor.buttons.model",
+			"/Formalisms/Workflows/Workflow.buttons.model"
 		]
 	},
 	"autoloaded-model": {