Selaa lähdekoodia

Enviando algumas modificações

Igor 5 vuotta sitten
vanhempi
commit
e8ceaad8ce

+ 13 - 1
css/ivprog-visual-1.0.css

@@ -130,7 +130,7 @@ body {
 
 .function_name_div, .function_return_div, .function_name_parameter, .created_div_valor_var, .function_return, .var_value_menu_div, .variable_rendered, .variable_rendered div, .var_attributed,
 .expression_operand_1, .expression_operand_2, .operator, .div_comment_text, .value_rendered, .parameters_function_called, .parameters_function_called div, .expression_elements,
-.expression_element, .var_rendered {
+.expression_element, .var_rendered, .menu_add_item, .component_element, .component_element {
 	display: inline;
 }
 
@@ -306,3 +306,15 @@ div.buttons_manage_columns {
 	float: right;
 	cursor: pointer;
 }
+
+.expression_drag {
+	cursor: col-resize;
+	border: 2px gray solid;
+	display: inline;
+	width: 5px;
+}
+
+.ui.icon.red.exclamation.triangle.error_icon {
+	float: left;
+    margin-left: -30px;
+}

+ 4 - 1
i18n/en/ui.json

@@ -39,5 +39,8 @@
   "text_dowhiletrue": "Do while true",
   "text_switch": "Switch",
   "text_functioncall": "Function call",
-  "text_value": "Value"
+  "text_value": "Value",
+  "text_operator": "Operator",
+  "text_parentheses": "Parentheses",
+  "text_change": "Change"
 }

+ 4 - 1
i18n/es/ui.json

@@ -39,5 +39,8 @@
   "text_dowhiletrue": "Do while true",
   "text_switch": "Switch",
   "text_functioncall": "Function call",
-  "text_value": "Value"
+  "text_value": "Value",
+  "text_operator": "Operator",
+  "text_parentheses": "Parentheses",
+  "text_change": "Change"
 }

+ 4 - 1
i18n/pt/ui.json

@@ -40,5 +40,8 @@
   "text_dowhiletrue": "Faça enquanto verdadeiro",
   "text_switch": "Escolha",
   "text_functioncall": "Chamada de função",
-  "text_value": "Valor"
+  "text_value": "Valor",
+  "text_operator": "Operador",
+  "text_parentheses": "Parênteses",
+  "text_change": "Alterar"
 }

+ 111 - 6
js/visualUI/code_generator.js

@@ -8,27 +8,41 @@ import * as CommandsManagement from './commands';
 
 export function generate () {
 
+	$('.ivprog_visual_panel').find('.error_icon').remove();
+
 	var code = LocalizedStrings.getUI('program') + ' { ';
 
 	code += globalsCode();
 
 	code += '\n';
 
+	var has_error = false;
+
 	for (var i = 0; i < window.program_obj.functions.length; i ++) {
-		code += functionsCode(window.program_obj.functions[i]);
+		var n_code = functionsCode(window.program_obj.functions[i]);
+		if (n_code == null) {
+			has_error = true;
+		}
+		code += n_code;
 		code += '\n';
 
 	}
 
 	code += '\n}';
 
-	return code;
+	if (has_error) {
+		return null;
+	} else {
+		return code;
+	}
 
 }
 
 function functionsCode (function_obj) {
 	var ret = '\n\t' + LocalizedStrings.getUI('function') + ' ';
 
+	var has_error = false;
+
 	switch (function_obj.return_type) {
 		case Types.INTEGER:
 			ret += LocalizedStrings.getUI('integer');
@@ -70,13 +84,34 @@ function functionsCode (function_obj) {
 	}
 
 	for (var j = 0; j < function_obj.commands.length; j++) {
-		ret += commandsCode(function_obj.commands[j]);
+		try {
+			ret += commandsCode(function_obj.commands[j]);
+		} catch (err) {
+
+			has_error = true;
+
+			console.error(err.message);
+
+			var todos = $('body').find('.command_container');
+			for (var i = 0; i < todos.length; i++) {
+
+				if ($(todos[i]).data('command') == function_obj.commands[j]) {
+					$( todos[i] ).prepend( ' <i class="ui icon red exclamation triangle error_icon"></i> ' );
+					break;
+				}
+			}
+			
+		}
+		
 	}
 
 	ret += '\n\t}';
 
-
-	return ret;
+	if (has_error) {
+		return null;
+	} else {
+		return ret;
+	}
 }
 
 function commandsCode (command_obj) {
@@ -92,7 +127,73 @@ function commandsCode (command_obj) {
 
 		case Models.COMMAND_TYPES.functioncall:
 			return functioncallsCode(command_obj);
+
+		case Models.COMMAND_TYPES.attribution:
+			return attributionsCode(command_obj);
+	}
+}
+
+function attributionsCode (command_obj) {
+	var ret = '\n\t\t';
+
+	ret += variableValueMenuCode(command_obj.variable) + ' = ';
+
+	for (var i = 0; i < command_obj.expression.length; i++) {
+		ret += elementExpressionCode(command_obj.expression[i]);
 	}
+
+	return ret;
+}
+
+function elementExpressionCode (expression_obj) {
+
+	var ret = ''; 
+
+	for (var i = 0; i < expression_obj.itens.length; i++) {
+
+
+		if (expression_obj.itens[i].type) {
+
+			ret += variableValueMenuCode(expression_obj.itens[i]);
+
+		} else if (expression_obj.itens[i].type_exp) {
+
+			if (expression_obj.itens[i].type_exp == Models.EXPRESSION_ELEMENTS.par_exp_par) {
+				ret += ' ( ';
+			}
+
+			ret += elementExpressionCode(expression_obj.itens[i]);
+
+			if (expression_obj.itens[i].type_exp == Models.EXPRESSION_ELEMENTS.par_exp_par) {
+				ret += ' ) ';
+			}
+
+		} else {
+
+			switch (expression_obj.itens[i]) {
+				case Models.ARITHMETIC_TYPES.plus:
+					ret += ' + ';
+					break;
+				case Models.ARITHMETIC_TYPES.minus:
+					ret += ' - ';
+					break;
+				case Models.ARITHMETIC_TYPES.multiplication:
+					ret += ' * ';
+					break;
+				case Models.ARITHMETIC_TYPES.division:
+					ret += ' / ';
+					break;
+				case Models.ARITHMETIC_TYPES.module:
+					ret += ' % ';
+					break;
+			}
+			
+		}
+
+	}
+
+	return ret;
+
 }
 
 function functioncallsCode (command_obj) {
@@ -144,7 +245,11 @@ function variableValueMenuCode (variable_obj) {
 
 
 	} else {
-		ret += variable_obj.content;
+		if (isNaN(variable_obj.content)) {
+			ret += '"' + variable_obj.content + '"';
+		} else {
+			ret += variable_obj.content;
+		}
 	}
 
 	return ret;

+ 323 - 15
js/visualUI/commands/attribution.js

@@ -14,42 +14,301 @@ export function createFloatingCommand () {
 
 export function renderCommand (command, function_obj) {
 	
-	var el = $('<div class="ui attribution command_container"> <i class="ui icon small arrow left command_drag"></i> <i class="ui icon times red button_remove_command"></i> <i class="ui icon redo alternate blue button_refresh_attribution"></i> <div class="var_attributed"></div> <span class="text_attr_receives">'+LocalizedStrings.getUI('text_receives')+'</span> '
+	var el = $('<div class="ui attribution command_container"><i class="ui icon small arrow left command_drag"></i> <i class="ui icon times red button_remove_command"></i> <i class="ui icon redo alternate blue button_refresh_attribution"></i> <div class="var_attributed"></div> <span class="text_attr_receives">'+LocalizedStrings.getUI('text_receives')+'</span> '
 		 + '<div class="expression_elements"></div> </div>');
 	el.data('command', command);
 
 	VariableValueMenu.renderMenu(command, command.variable, el.find('.var_attributed'), function_obj);
 
-	command.expression.push("(");
+	var exp = new Models.ExpressionElement(Models.EXPRESSION_ELEMENTS.op_exp, [Models.ARITHMETIC_TYPES.none, 
+		new Models.VariableValueMenu(VariableValueMenuManagement.VAR_OR_VALUE_TYPES.all, null, null, null, true)]);
 
-	command.expression.push(new Models.VariableValueMenu(VariableValueMenuManagement.VAR_OR_VALUE_TYPES.all, "1", null, null, true));
+	command.expression.push(exp);
 
-	command.expression.push(Models.ARITHMETIC_TYPES.plus);
+	addHandlers(command, function_obj, el);
+
+	renderExpressionElements(command, function_obj, el);
+
+	return el;
 
-	command.expression.push(new Models.VariableValueMenu(VariableValueMenuManagement.VAR_OR_VALUE_TYPES.all, window.program_obj.functions[0].variables_list[0], null, 
-		new Models.VariableValueMenu(VariableValueMenuManagement.VAR_OR_VALUE_TYPES.all, new Models.Variable(Types.REAL, "variable_2", 1)), null, null, true));
+}
 
+export function manageExpressionElements (command, ref_object, dom_object, menu_var_or_value, function_obj, selectedItem, expression_element) {
+	
+	var index_to_move = expression_element.itens.indexOf(ref_object);
 
-	command.expression.push(")");
+	switch (selectedItem.data('exp')) {
+		case Models.EXPRESSION_ELEMENTS.exp_op_exp:
 
-	command.expression.push(Models.ARITHMETIC_TYPES.minus);
+			var exp = new Models.ExpressionElement(Models.EXPRESSION_ELEMENTS.exp_op_exp, [expression_element.itens[index_to_move],
+	     		Models.ARITHMETIC_TYPES.plus, 
+				new Models.VariableValueMenu(VariableValueMenuManagement.VAR_OR_VALUE_TYPES.all, null, null, null, true)]);
 
-	command.expression.push(new Models.VariableValueMenu(VariableValueMenuManagement.VAR_OR_VALUE_TYPES.all, "2", null, null, true));
+			expression_element.itens[index_to_move] = exp;
 
-	/*VariableValueMenu.renderMenu(command, command.expression[0].content, el.find('.expression_operand_1'), function_obj);*/
+			break;
 
-	addHandlers(command, function_obj, el);
+		case Models.EXPRESSION_ELEMENTS.op_exp:
 
-	renderExpression(command, function_obj, el);
+			var exp = new Models.ExpressionElement(Models.EXPRESSION_ELEMENTS.op_exp, [Models.ARITHMETIC_TYPES.plus, 
+				expression_element.itens[index_to_move] ]);
 
-	return el;
+			expression_element.itens[index_to_move] = exp;
+
+			break;
+
+		case Models.EXPRESSION_ELEMENTS.par_exp_par:
+
+			var exp = new Models.ExpressionElement(Models.EXPRESSION_ELEMENTS.par_exp_par, [expression_element.itens[index_to_move]]);
+
+			expression_element.itens[index_to_move] = exp;
+
+			break;
+	}
+
+	renderExpressionElements(command, function_obj, dom_object);
+
+}
+
+function renderExpressionElements (command, function_obj, el) {
+	var expression_div = el.find('.expression_elements');
+	var command_container;
+
+	if (el.hasClass("command_container") == false) {
+		var hier = el.parentsUntil(".commands_list_div");
+
+		for (var i = 0; i < hier.length; i++) {
+			if ($(hier[i]).hasClass("command_container")) {
+				command_container = $(hier[i]);
+			}
+		}
+	}
+
+	if (command_container) {
+		expression_div = command_container.find('.expression_elements');
+	}
+
+	expression_div.text('');
+
+	for (var i = 0; i < command.expression.length; i++) {
+
+		var temp = $('<div class="expression_element"></div>');
+		temp.data('ref_element', command.expression[i]);
+		temp.data('ref_index', i);
+
+		expression_div.append(temp);
+
+		renderElement(command, function_obj, temp, command.expression[i]);
+	}
+
+	/*if (command_container) {
+		renderMenuAddExpression(command, function_obj, command_container, expression_div, command.expression);
+	} else {
+		renderMenuAddExpression(command, function_obj, el, expression_div, command.expression);
+	}*/
+}
+
+function renderOperator (command, function_obj, temp_op, expression_element, index_op) {
+
+	var context_menu = '<div class="ui dropdown"><div class="text">';
+
+	switch (expression_element.itens[index_op]) {
+		case Models.ARITHMETIC_TYPES.plus:
+			context_menu += '+';
+			break;
+
+		case Models.ARITHMETIC_TYPES.minus:
+			context_menu += '-';
+			break;
+
+		case Models.ARITHMETIC_TYPES.multiplication:
+			context_menu += '*';
+			break;
+
+		case Models.ARITHMETIC_TYPES.division:
+			context_menu += '/';
+			break;
+
+		case Models.ARITHMETIC_TYPES.module:
+			context_menu += '%';
+			break;
+
+		case Models.ARITHMETIC_TYPES.none:
+			context_menu += '...';
+			break;
+	}
+	
+	context_menu += '</div><div class="menu">';
+	context_menu += '<div class="item" data-value="'+Models.ARITHMETIC_TYPES.plus+'">+</div>';
+	context_menu += '<div class="item" data-value="'+Models.ARITHMETIC_TYPES.minus+'">-</div>';
+	context_menu += '<div class="item" data-value="'+Models.ARITHMETIC_TYPES.multiplication+'">*</div>';
+	context_menu += '<div class="item" data-value="'+Models.ARITHMETIC_TYPES.division+'">/</div>';
+	context_menu += '<div class="item" data-value="'+Models.ARITHMETIC_TYPES.module+'">%</div>';
+	context_menu += '<div class="item" data-value="'+Models.ARITHMETIC_TYPES.none+'" data-text="...">Nenhum</div>';
+	context_menu += '</div></div>';
+
+	context_menu = $(context_menu);
+
+	temp_op.append(context_menu);
+
+	context_menu.dropdown({
+		onChange: function(value, text, $selectedItem) {
+	     expression_element.itens[index_op] = value;
+      }
+	});
+
+}
+
+function renderMenuAddExpression (command, function_obj, el, dom_append_menu, expression_append_new_expression) {
+
+	if (el.hasClass("command_container") == false) {
+		var hier = el.parentsUntil(".commands_list_div");
+
+		for (var i = 0; i < hier.length; i++) {
+			if ($(hier[i]).hasClass("command_container")) {
+				el = $(hier[i]);
+				break;
+			}
+		}
+	}
+
+	if (dom_append_menu.hasClass("expression_elements") == false) {
+		var hier = el.parentsUntil(".commands_list_div");
+
+		for (var i = 0; i < hier.length; i++) {
+			if ($(hier[i]).hasClass("expression_elements")) {
+				dom_append_menu = $(hier[i]);
+				break;
+			}
+		}
+	}
+
+	var context_menu = '<div class="ui dropdown"><div class="text"></div><i class="ui icon arrow alternate circle right outline"></i><div class="menu">';
+	context_menu += '<div class="item" data-value="'+Models.EXPRESSION_ELEMENTS.exp_op_exp+'">EXP OP EXP</div>';
+	context_menu += '<div class="item" data-value="'+Models.EXPRESSION_ELEMENTS.op_exp+'">OP EXP</div>';
+	context_menu += '<div class="item" data-value="'+Models.EXPRESSION_ELEMENTS.par_exp_par+'">( EXP )</div>';
+	context_menu += '</div></div>';
+
+	context_menu = $(context_menu);
+
+	dom_append_menu.append(context_menu);
+
+	context_menu.dropdown({
+		onChange: function(value, text, $selectedItem) {
+	     switch (value) {
+	     	case Models.EXPRESSION_ELEMENTS.exp_op_exp:
+
+	     	var exp = new Models.ExpressionElement(Models.EXPRESSION_ELEMENTS.exp_op_exp, [new Models.VariableValueMenu(VariableValueMenuManagement.VAR_OR_VALUE_TYPES.all, null, null, null, true),
+	     		Models.ARITHMETIC_TYPES.plus, 
+				new Models.VariableValueMenu(VariableValueMenuManagement.VAR_OR_VALUE_TYPES.all, null, null, null, true)]);
+
+			expression_append_new_expression.push(exp);
+			break;
+
+		case Models.EXPRESSION_ELEMENTS.op_exp:
+			var exp = new Models.ExpressionElement(Models.EXPRESSION_ELEMENTS.op_exp, [Models.ARITHMETIC_TYPES.plus, 
+				new Models.VariableValueMenu(VariableValueMenuManagement.VAR_OR_VALUE_TYPES.all, null, null, null, true)]);
+
+			expression_append_new_expression.push(exp);
+			break;
+
+		case Models.EXPRESSION_ELEMENTS.par_exp_par:
+
+			var exp = new Models.ExpressionElement(Models.EXPRESSION_ELEMENTS.par_exp_par, [new Models.VariableValueMenu(VariableValueMenuManagement.VAR_OR_VALUE_TYPES.all, null, null, null, true)]);
+
+			expression_append_new_expression.push(exp);
+
+			break;
+		}
+		
+		renderExpressionElements(command, function_obj, el);
+      }
+	});
 
 }
 
-function renderExpression(command, function_obj, el) {
+function renderElement (command, function_obj, el, expression_element) {
+
+	switch (expression_element.type_exp) {
+		case Models.EXPRESSION_ELEMENTS.exp_op_exp:
+
+			var temp_op = $('<div class="component_element"></div>');
+			var temp_exp_1 = $('<div class="component_element"></div>');
+			var temp_exp_2 = $('<div class="component_element"></div>');
+
+			el.append(temp_exp_1);
+			el.append(temp_op);
+			el.append(temp_exp_2);
+			
+			if (expression_element.itens[0].type) {
+				VariableValueMenu.renderMenu(command, expression_element.itens[0], temp_exp_1, function_obj, 2, expression_element);
+			} else {
+				renderElement(command, function_obj, temp_exp_1, expression_element.itens[0]);
+			}
+
+			renderOperator(command, function_obj, temp_op, expression_element, 1);
+
+			if (expression_element.itens[2].type) {
+				VariableValueMenu.renderMenu(command, expression_element.itens[2], temp_exp_2, function_obj, 2, expression_element);
+			} else {
+				renderElement(command, function_obj, temp_exp_2, expression_element.itens[2]);
+			}
+
+			break;
+
+		case Models.EXPRESSION_ELEMENTS.op_exp:
+			var temp_op = $('<div class="component_element"></div>');
+			var temp_exp = $('<div class="component_element"></div>');
+
+			el.append(temp_op);
+			el.append(temp_exp);
+
+			renderOperator(command, function_obj, temp_op, expression_element, 0);
+
+			if (expression_element.itens[1].type) {
+				VariableValueMenu.renderMenu(command, expression_element.itens[1], temp_exp, function_obj, 2, expression_element);
+			} else {
+				renderElement(command, function_obj, temp_exp, expression_element.itens[1]);
+			}
+			break;
+
+		case Models.EXPRESSION_ELEMENTS.par_exp_par:
+
+			var temp_par_1 = $('<div class="component_element"> ( </div>');
+			var temp_exp = $('<div class="component_element"></div>');
+			var temp_par_2 = $('<div class="component_element"> ) </div>');
+
+			el.append(temp_par_1);
+			el.append(temp_exp);
+
+			for (var j = 0; j < expression_element.itens.length; j++) {
+				if (expression_element.itens[j].type) {
+					VariableValueMenu.renderMenu(command, expression_element.itens[j], temp_exp, function_obj, 2, expression_element);
+				} else {
+					renderElement(command, function_obj, temp_exp, expression_element.itens[j]);
+				}
+			}
+			
+
+			//renderMenuAddExpression(command, function_obj, el, el, expression_element.itens);
+
+			el.append(temp_par_2);
+
+			break;
+	}
+
+}
+
+
+function renderExpression (command, function_obj, el) {
 
 	var expression_div = el.find('.expression_elements');
 	expression_div.text('');
+
+	var menu_add_item = $('<div class="menu_add_item"></div>');
+	menu_add_item.data('index_add', 0);
+
+	expression_div.append(menu_add_item);
 	
 	for (var i = 0; i < command.expression.length; i++) {
 
@@ -101,10 +360,59 @@ function renderExpression(command, function_obj, el) {
 			expression_div.append(temp);
 
 		}
+		
+		var menu_add_item_seq = $('<div class="menu_add_item"></div>');
+		var index_temp = (i + 1);
+		menu_add_item_seq.data('index_add', index_temp);
+		expression_div.append(menu_add_item_seq);
 
 	}
+
+	addMenuItens(command, function_obj, el);
+
 }
 
+function addMenuItens (command, function_obj, expression_div) {
+	var divs_expression = expression_div.find('.menu_add_item');
+
+	for (var i = 0; i < divs_expression.length; i++) {
+
+		var temp = $(divs_expression[i]).data('index_add');
+
+		var context_menu = '<div class="ui dropdown context_menu_clear"><i class="ui icon plus square outline"></i><div class="menu">';
+		context_menu += '<div class="item" data-option="value" data-index="'+temp+'">'+LocalizedStrings.getUI('text_value')+'</div>';
+		context_menu += '<div class="item" data-option="operator" data-index="'+temp+'">'+LocalizedStrings.getUI('text_operator')+'</div>';
+		context_menu += '<div class="item" data-option="parentheses" data-index="'+temp+'">'+LocalizedStrings.getUI('text_parentheses')+'</div>';
+		context_menu += '</div></div>';
+
+		context_menu = $(context_menu);
+
+		$(divs_expression[i]).append(context_menu);
+
+		context_menu.dropdown({
+	      on: 'hover',
+	      onChange: function(value, text, $selectedItem) {
+    		switch ($selectedItem.data('option')) {
+    			case "value":
+    				command.expression.splice($selectedItem.data('index'), 0, new Models.VariableValueMenu(VariableValueMenuManagement.VAR_OR_VALUE_TYPES.all, null, null, null, true));
+    				renderExpression(command, function_obj, expression_div);
+    				break;
+    			case "operator":
+    				command.expression.splice($selectedItem.data('index'), 0, Models.ARITHMETIC_TYPES.plus);
+    				renderExpression(command, function_obj, expression_div);
+    				break;
+    			case "parentheses":
+    				command.expression.splice($selectedItem.data('index'), 0, "(");
+    				command.expression.splice($selectedItem.data('index') + 1, 0, new Models.VariableValueMenu(VariableValueMenuManagement.VAR_OR_VALUE_TYPES.all, null, null, null, true));
+    				command.expression.splice($selectedItem.data('index') + 2, 0, ")");
+    				renderExpression(command, function_obj, expression_div);
+    				break;
+    		 }
+        	}
+	    });
+
+	}
+}
 
 
 function addHandlers (command, function_obj, attribution_dom) {
@@ -116,7 +424,7 @@ function addHandlers (command, function_obj, attribution_dom) {
 	});
 
 	attribution_dom.find('.button_refresh_attribution').on('click', function() {
-		renderExpression(command, function_obj, attribution_dom);
+		renderExpressionElements(command, function_obj, attribution_dom);
 	});
 }
 

+ 7 - 33
js/visualUI/commands/comment.js

@@ -12,14 +12,20 @@ export function createFloatingCommand () {
 }
 
 export function renderCommand (command, function_obj) {
-	var el = $('<div class="ui comment command_container"> <i class="ui icon small quote left"></i> <i class="ui icon times red button_remove_command"></i> <div class="var_value_menu_div"></div> <div class="div_comment_text">'+command.comment_text.content+'</div> </div>');
+	var el = $('<div class="ui comment command_container"> <i class="ui icon small quote left"></i> <i class="ui icon times red button_remove_command"></i> <div class="var_value_menu_div"></div> <div class="div_comment_text">'+'</div> </div>');
 	el.data('command', command);
 
 	addHandlers(command, function_obj, el);
 
+	renderTextComment(command, function_obj, el);
+
 	return el;
 }
 
+function renderTextComment (command, function_obj, el) {
+	VariableValueMenu.renderMenu(command, command.comment_text, el.find('.var_value_menu_div'), function_obj, 20);
+}
+
 function addHandlers (command, function_obj, comment_dom) {
 
 	comment_dom.find('.button_remove_command').on('click', function() {
@@ -27,36 +33,4 @@ function addHandlers (command, function_obj, comment_dom) {
 			comment_dom.remove();
 		}
 	});
-
-	comment_dom.find('.div_comment_text').on('click', function() {
-		comment_dom.find('.div_comment_text').text('');
-		VariableValueMenu.renderMenu(command, command.comment_text, comment_dom.find('.var_value_menu_div'), function_obj, 20);
-		comment_dom.find('.width-dynamic').val(command.comment_text.content);
-
-		comment_dom.find('.width-dynamic').focusout(function() {
-			if ($(this).val().trim()) {
-				command.comment_text.content = $(this).val().trim();
-			}
-			comment_dom.find('.div_comment_text').text(command.comment_text.content);
-			$(this).remove();
-		});
-
-		comment_dom.find('.width-dynamic').on('keydown', function(e) {
-			var code = e.keyCode || e.which;
-			if(code == 13) {
-				if ($(this).val().trim()) {
-					command.comment_text.content = $(this).val().trim();
-				}
-				comment_dom.find('.div_comment_text').text(command.comment_text.content);
-				$(this).remove();
-			}
-			if(code == 27) {
-				comment_dom.find('.div_comment_text').text(command.comment_text.content);
-
-				$(this).remove();
-			}
-		});
-
-	});
-
 }

+ 264 - 56
js/visualUI/commands/variable_value_menu.js

@@ -10,7 +10,7 @@ import * as WritersManagement from './writer';
 export const VAR_OR_VALUE_TYPES = Object.freeze({only_variable: 1, only_value: 2, only_function: 3, variable_and_function: 4, variable_and_value_opt: 5,
 	value_and_function: 6, all: 7});
 
-export function renderMenu (command, ref_object, dom_object, function_obj, size_field = 2) {
+export function renderMenu (command, ref_object, dom_object, function_obj, size_field = 2, expression_element) {
 	var menu_var_or_value = '<div class="ui dropdown menu_var_or_value_dom"><div class="text"></div><i class="dropdown icon"></i><div class="menu">';
 
 	if (ref_object.variable_and_value == VAR_OR_VALUE_TYPES.only_function) {
@@ -48,6 +48,15 @@ export function renderMenu (command, ref_object, dom_object, function_obj, size_
 		|| (ref_object.variable_and_value == VAR_OR_VALUE_TYPES.value_and_function) || (ref_object.variable_and_value == VAR_OR_VALUE_TYPES.all)) {
 
 		menu_var_or_value += '<div class="item" data-option="'+VAR_OR_VALUE_TYPES.only_value+'">'+LocalizedStrings.getUI('text_value')+'</div>';
+
+		if (command.type == Models.COMMAND_TYPES.attribution) {
+			menu_var_or_value += '<div class="item"><i class="dropdown icon"></i>' + LocalizedStrings.getUI('text_change');
+			menu_var_or_value += '<div class="menu">';
+			menu_var_or_value += '<div class="item" data-exp="'+Models.EXPRESSION_ELEMENTS.exp_op_exp+'">EXP OP EXP</div>';
+			menu_var_or_value += '<div class="item" data-exp="'+Models.EXPRESSION_ELEMENTS.op_exp+'">OP EXP</div>';
+			menu_var_or_value += '<div class="item" data-exp="'+Models.EXPRESSION_ELEMENTS.par_exp_par+'">( EXP )</div>';
+			menu_var_or_value += '</div></div>';
+		}
 	}
 
     menu_var_or_value += '</div></div>';
@@ -56,49 +65,44 @@ export function renderMenu (command, ref_object, dom_object, function_obj, size_
 
     dom_object.append(menu_var_or_value);
 
-    addHandlers(command, ref_object, dom_object, menu_var_or_value, function_obj);
+    addHandlers(command, ref_object, dom_object, menu_var_or_value, function_obj, expression_element);
 
-    addVariablesToMenu(function_obj, menu_var_or_value, ref_object);
+    addVariablesToMenu(function_obj, menu_var_or_value, ref_object, expression_element);
 
-    addFunctionsToMenu(function_obj, menu_var_or_value, ref_object);
+    addFunctionsToMenu(function_obj, menu_var_or_value, ref_object, expression_element);
 
     if (ref_object.content || ref_object.function_called) {
-    	renderPreviousContent(function_obj, menu_var_or_value, ref_object, dom_object, command);
+    	renderPreviousContent(function_obj, menu_var_or_value, ref_object, dom_object, command, expression_element);
     }
 }
 
-function renderPreviousContent (function_obj, menu_var_or_value, ref_object, dom_object, command) {
+function renderPreviousContent (function_obj, menu_var_or_value, ref_object, dom_object, command, expression_element) {
 
 	
 	if (ref_object.function_called) {
 
-		console.log("P1 chamando para: ");
-		console.log(ref_object);
-
 		menu_var_or_value.remove();
-		variableValueMenuCode(command, ref_object, dom_object, function_obj, menu_var_or_value);
+		variableValueMenuCode(command, ref_object, dom_object, function_obj, menu_var_or_value, expression_element);
 
 	} else if (ref_object.content.type) { 
-		
-		console.log("P2 chamando para: ");
-		console.log(ref_object);
 
 		menu_var_or_value.remove();
-		variableValueMenuCode(command, ref_object, dom_object, function_obj, menu_var_or_value);
+		variableValueMenuCode(command, ref_object, dom_object, function_obj, menu_var_or_value, expression_element);
 
 	} else {
 
-		console.log("P3 chamando para: ");
-		console.log(ref_object);
-
 		menu_var_or_value.remove();
-		variableValueMenuCode(command, ref_object, dom_object, function_obj, menu_var_or_value);
+		variableValueMenuCode(command, ref_object, dom_object, function_obj, menu_var_or_value, expression_element);
 
 	}
 }
 
-function variableValueMenuCode (command, variable_obj, dom_object, function_obj, menu_var_or_value) {
+function variableValueMenuCode (command, variable_obj, dom_object, function_obj, menu_var_or_value, expression_element) {
 
+	if (variable_obj.content == null && variable_obj.function_called == null) {
+		renderMenu(command, variable_obj, dom_object, function_obj, 2, expression_element);
+		return;
+	}
 
 	var ret = '';
 	if (variable_obj.function_called) {
@@ -118,6 +122,16 @@ function variableValueMenuCode (command, variable_obj, dom_object, function_obj,
 
 			var context_menu = '<div class="ui dropdown context_menu_clear"><div class="text"></div><i class="dropdown icon"></i><div class="menu">';
 			context_menu += '<div class="item" data-clear="true">'+LocalizedStrings.getUI('btn_clear')+'</div>';
+
+			if (command.type == Models.COMMAND_TYPES.attribution) {
+				context_menu += '<div class="item"><i class="dropdown icon"></i>' + LocalizedStrings.getUI('text_change');
+				context_menu += '<div class="menu">';
+				context_menu += '<div class="item" data-exp="'+Models.EXPRESSION_ELEMENTS.exp_op_exp+'">EXP OP EXP</div>';
+				context_menu += '<div class="item" data-exp="'+Models.EXPRESSION_ELEMENTS.op_exp+'">OP EXP</div>';
+				context_menu += '<div class="item" data-exp="'+Models.EXPRESSION_ELEMENTS.par_exp_par+'">( EXP )</div>';
+				context_menu += '</div></div>';
+			}
+
 			context_menu += '</div></div>';
 
 			context_menu = $(context_menu);
@@ -127,6 +141,7 @@ function variableValueMenuCode (command, variable_obj, dom_object, function_obj,
 			context_menu.dropdown({
 				onChange: function(value, text, $selectedItem) {
 			     if ($selectedItem.data('clear')) {
+			     	console.log('PP1');
 			     	dom_object.text('');
 
 			     	variable_obj.content = null;
@@ -135,35 +150,59 @@ function variableValueMenuCode (command, variable_obj, dom_object, function_obj,
 			     	delete variable_obj.function_called;
 			     	delete variable_obj.parameters_list;
 
-			     	renderMenu(command, variable_obj, dom_object, function_obj);
+			     	renderMenu(command, variable_obj, dom_object, function_obj, 2, expression_element);
+			     }
+
+			     if ($selectedItem.data('exp')) {
+			     	AttribuitionsManagement.manageExpressionElements(command, variable_obj, dom_object, menu_var_or_value, function_obj, $selectedItem, expression_element);
 			     }
 		      }
 			});
 		} else {
 
-			console.log("sei que preciso colcoar parametros");
 			menu_var_or_value.find('.text').text(' ');
 			dom_object.find('.menu_var_or_value_dom').remove();
 
 			var parameters_menu = '<div class="parameters_function_called"> '+variable_obj.function_called.name+' <span> ( </span>';
-			
+			for (var j = 0; j < variable_obj.function_called.parameters_list.length; j++) {
+				parameters_menu += '<div class="parameter_'+j+'"></div>';
+				if ((j + 1) != variable_obj.function_called.parameters_list.length) {
+					parameters_menu += ' , ';
+				}
+			}
 			parameters_menu += '<span> ) </span></div>';
 
 			parameters_menu = $(parameters_menu);
 
 			dom_object.append(parameters_menu);
 
+			for (var j = 0; j < variable_obj.function_called.parameters_list.length; j++) {
+				renderMenu(command, variable_obj.parameters_list[j], parameters_menu.find('.parameter_'+j), function_obj, 2, expression_element);
+			}
+
+
 			var context_menu = '<div class="ui dropdown context_menu_clear"><div class="text"></div><i class="dropdown icon"></i><div class="menu">';
 			context_menu += '<div class="item" data-clear="true">'+LocalizedStrings.getUI('btn_clear')+'</div>';
+
+			if (command.type == Models.COMMAND_TYPES.attribution) {
+				context_menu += '<div class="item"><i class="dropdown icon"></i>' + LocalizedStrings.getUI('text_change');
+				context_menu += '<div class="menu">';
+				context_menu += '<div class="item" data-exp="'+Models.EXPRESSION_ELEMENTS.exp_op_exp+'">EXP OP EXP</div>';
+				context_menu += '<div class="item" data-exp="'+Models.EXPRESSION_ELEMENTS.op_exp+'">OP EXP</div>';
+				context_menu += '<div class="item" data-exp="'+Models.EXPRESSION_ELEMENTS.par_exp_par+'">( EXP )</div>';
+				context_menu += '</div></div>';
+			}
+
 			context_menu += '</div></div>';
 
 			context_menu = $(context_menu);
 
-			context_menu.insertAfter( dom_object.find('.parameters_function_called') );
+			context_menu.insertAfter( parameters_menu );
 
 			context_menu.dropdown({
 				onChange: function(value, text, $selectedItem) {
 			     if ($selectedItem.data('clear')) {
+			     	console.log('PP2');
 			     	dom_object.text('');
 
 			     	variable_obj.content = null;
@@ -172,7 +211,11 @@ function variableValueMenuCode (command, variable_obj, dom_object, function_obj,
 			     	delete variable_obj.function_called;
 			     	delete variable_obj.parameters_list;
 
-			     	renderMenu(command, variable_obj, dom_object, function_obj);
+			     	renderMenu(command, variable_obj, dom_object, function_obj, 2, expression_element);
+			     }
+
+			     if ($selectedItem.data('exp')) {
+			     	AttribuitionsManagement.manageExpressionElements(command, variable_obj, dom_object, menu_var_or_value, function_obj, $selectedItem, expression_element);
 			     }
 		      }
 			});
@@ -198,17 +241,26 @@ function variableValueMenuCode (command, variable_obj, dom_object, function_obj,
 
 			var context_menu = '<div class="ui dropdown context_menu_clear"><div class="text"></div><i class="dropdown icon"></i><div class="menu">';
 			context_menu += '<div class="item" data-clear="true">'+LocalizedStrings.getUI('btn_clear')+'</div>';
+
+			if (command.type == Models.COMMAND_TYPES.attribution) {
+				context_menu += '<div class="item"><i class="dropdown icon"></i>' + LocalizedStrings.getUI('text_change');
+				context_menu += '<div class="menu">';
+				context_menu += '<div class="item" data-exp="'+Models.EXPRESSION_ELEMENTS.exp_op_exp+'">EXP OP EXP</div>';
+				context_menu += '<div class="item" data-exp="'+Models.EXPRESSION_ELEMENTS.op_exp+'">OP EXP</div>';
+				context_menu += '<div class="item" data-exp="'+Models.EXPRESSION_ELEMENTS.par_exp_par+'">( EXP )</div>';
+				context_menu += '</div></div>';
+			}
+
 			context_menu += '</div></div>';
 
 			context_menu = $(context_menu);
 
-			//context_menu.insertAfter( dom_object.find('.variable_rendered') );
-
 			variable_render.append(context_menu);
 
 			context_menu.dropdown({
 				onChange: function(value, text, $selectedItem) {
 			     if ($selectedItem.data('clear')) {
+			     	console.log('PP3');
 			     	dom_object.text('');
 
 			     	variable_obj.content = null;
@@ -217,16 +269,73 @@ function variableValueMenuCode (command, variable_obj, dom_object, function_obj,
 			     	delete variable_obj.function_called;
 		     		delete variable_obj.parameters_list;
 
-			     	renderMenu(command, variable_obj, dom_object, function_obj);
+			     	renderMenu(command, variable_obj, dom_object, function_obj, 2, expression_element);
+			     }
+
+			     if ($selectedItem.data('exp')) {
+			     	AttribuitionsManagement.manageExpressionElements(command, variable_obj, dom_object, menu_var_or_value, function_obj, $selectedItem, expression_element);
 			     }
 		      }
 			});
 
-			variableValueMenuCode(command, variable_obj.column, $(variable_render.find('.column_container')), function_obj, menu_var_or_value);
+			variableValueMenuCode(command, variable_obj.column, $(variable_render.find('.column_container')), function_obj, menu_var_or_value, expression_element);
 
 		} else if (variable_obj.content.dimensions == 2) {
-			/*ret += ' [ ' + variableValueMenuCode(command, variable_obj.row, dom_object, function_obj) + ' ] ';
-			ret += ' [ ' + variableValueMenuCode(command, variable_obj.column, dom_object, function_obj) + ' ] ';*/
+
+			variable_render = '<div class="variable_rendered"> <span class="var_name">'+variable_obj.content.name+'</span>';
+
+			variable_render += ' <span>[ </span> <div class="row_container"></div> <span> ]</span>';
+			variable_render += ' <span>[ </span> <div class="column_container"></div> <span> ] </span>';
+			
+			variable_render += '</div>';
+
+			variable_render = $(variable_render);
+
+			dom_object.append(variable_render);
+
+
+			var context_menu = '<div class="ui dropdown context_menu_clear"><div class="text"></div><i class="dropdown icon"></i><div class="menu">';
+			context_menu += '<div class="item" data-clear="true">'+LocalizedStrings.getUI('btn_clear')+'</div>';
+
+			if (command.type == Models.COMMAND_TYPES.attribution) {
+				context_menu += '<div class="item"><i class="dropdown icon"></i>' + LocalizedStrings.getUI('text_change');
+				context_menu += '<div class="menu">';
+				context_menu += '<div class="item" data-exp="'+Models.EXPRESSION_ELEMENTS.exp_op_exp+'">EXP OP EXP</div>';
+				context_menu += '<div class="item" data-exp="'+Models.EXPRESSION_ELEMENTS.op_exp+'">OP EXP</div>';
+				context_menu += '<div class="item" data-exp="'+Models.EXPRESSION_ELEMENTS.par_exp_par+'">( EXP )</div>';
+				context_menu += '</div></div>';
+			}
+
+			context_menu += '</div></div>';
+
+			context_menu = $(context_menu);
+
+			variable_render.append(context_menu);
+
+			context_menu.dropdown({
+				onChange: function(value, text, $selectedItem) {
+			     if ($selectedItem.data('clear')) {
+			     	console.log('PP4');
+			     	dom_object.text('');
+
+			     	variable_obj.content = null;
+			     	variable_obj.row = null;
+			     	variable_obj.column = null;
+			     	delete variable_obj.function_called;
+		     		delete variable_obj.parameters_list;
+
+			     	renderMenu(command, variable_obj, dom_object, function_obj, 2, expression_element);
+			     }
+
+			     if ($selectedItem.data('exp')) {
+			     	AttribuitionsManagement.manageExpressionElements(command, variable_obj, dom_object, menu_var_or_value, function_obj, $selectedItem, expression_element);
+			     }
+		      }
+			});
+
+			variableValueMenuCode(command, variable_obj.row, $(variable_render.find('.row_container')), function_obj, menu_var_or_value, expression_element);
+			variableValueMenuCode(command, variable_obj.column, $(variable_render.find('.column_container')), function_obj, menu_var_or_value, expression_element);
+
 		} else {
 
 			variable_render = '<div class="variable_rendered"> <span class="var_name">'+variable_obj.content.name+'</span>';
@@ -240,15 +349,26 @@ function variableValueMenuCode (command, variable_obj, dom_object, function_obj,
 
 			var context_menu = '<div class="ui dropdown context_menu_clear"><div class="text"></div><i class="dropdown icon"></i><div class="menu">';
 			context_menu += '<div class="item" data-clear="true">'+LocalizedStrings.getUI('btn_clear')+'</div>';
+
+			if (command.type == Models.COMMAND_TYPES.attribution) {
+				context_menu += '<div class="item"><i class="dropdown icon"></i>' + LocalizedStrings.getUI('text_change');
+				context_menu += '<div class="menu">';
+				context_menu += '<div class="item" data-exp="'+Models.EXPRESSION_ELEMENTS.exp_op_exp+'">EXP OP EXP</div>';
+				context_menu += '<div class="item" data-exp="'+Models.EXPRESSION_ELEMENTS.op_exp+'">OP EXP</div>';
+				context_menu += '<div class="item" data-exp="'+Models.EXPRESSION_ELEMENTS.par_exp_par+'">( EXP )</div>';
+				context_menu += '</div></div>';
+			}
+
 			context_menu += '</div></div>';
 
 			context_menu = $(context_menu);
 
-			context_menu.insertAfter( variable_render );
+			variable_render.append(context_menu);
 
 			context_menu.dropdown({
 				onChange: function(value, text, $selectedItem) {
 			     if ($selectedItem.data('clear')) {
+			     	console.log('PP5');
 			     	dom_object.text('');
 
 			     	variable_obj.content = null;
@@ -258,7 +378,11 @@ function variableValueMenuCode (command, variable_obj, dom_object, function_obj,
 			     	delete variable_obj.function_called;
 		     		delete variable_obj.parameters_list;
 
-			     	renderMenu(command, variable_obj, dom_object, function_obj);
+			     	renderMenu(command, variable_obj, dom_object, function_obj, 2, expression_element);
+			     }
+
+			     if ($selectedItem.data('exp')) {
+			     	AttribuitionsManagement.manageExpressionElements(command, variable_obj, dom_object, menu_var_or_value, function_obj, $selectedItem, expression_element);
 			     }
 		      }
 			});
@@ -276,15 +400,28 @@ function variableValueMenuCode (command, variable_obj, dom_object, function_obj,
 
 		var context_menu = '<div class="ui dropdown context_menu_clear"><div class="text"></div><i class="dropdown icon"></i><div class="menu">';
 		context_menu += '<div class="item" data-clear="true">'+LocalizedStrings.getUI('btn_clear')+'</div>';
+
+		if (command.type == Models.COMMAND_TYPES.attribution) {
+			context_menu += '<div class="item"><i class="dropdown icon"></i>' + LocalizedStrings.getUI('text_change');
+			context_menu += '<div class="menu">';
+			context_menu += '<div class="item" data-exp="'+Models.EXPRESSION_ELEMENTS.exp_op_exp+'">EXP OP EXP</div>';
+			context_menu += '<div class="item" data-exp="'+Models.EXPRESSION_ELEMENTS.op_exp+'">OP EXP</div>';
+			context_menu += '<div class="item" data-exp="'+Models.EXPRESSION_ELEMENTS.par_exp_par+'">( EXP )</div>';
+			context_menu += '</div></div>';
+		}
+
 		context_menu += '</div></div>';
 
 		context_menu = $(context_menu);
 
-		context_menu.insertAfter( variable_render );
+		if (variable_obj.variable_and_value != VAR_OR_VALUE_TYPES.only_value) {
+			context_menu.insertAfter( variable_render );
+		}
 
 		context_menu.dropdown({
 			onChange: function(value, text, $selectedItem) {
 		     if ($selectedItem.data('clear')) {
+		     	console.log('PP6');
 		     	dom_object.text('');
 
    				variable_obj.content = null;
@@ -298,7 +435,11 @@ function variableValueMenuCode (command, variable_obj, dom_object, function_obj,
 				dom_object.find('.context_menu_clear').remove();
 				dom_object.find('.width-dynamic-minus').remove();
 
-		     	renderMenu(command, variable_obj, dom_object, function_obj);
+		     	renderMenu(command, variable_obj, dom_object, function_obj, 2, expression_element);
+		     }
+
+		     if ($selectedItem.data('exp')) {
+		     	AttribuitionsManagement.manageExpressionElements(command, variable_obj, dom_object, menu_var_or_value, function_obj, $selectedItem, expression_element);
 		     }
 	      }
 		});
@@ -310,7 +451,7 @@ function variableValueMenuCode (command, variable_obj, dom_object, function_obj,
 			dom_object.empty();
 			dom_object.append('<span class="menu_var_or_value_dom"> </span>');
 			
-			openInputToValue(command, variable_obj, dom_object, menu_var_or_value, function_obj);
+			openInputToValue(command, variable_obj, dom_object, menu_var_or_value, function_obj, expression_element);
 		});
 	}
 
@@ -318,7 +459,7 @@ function variableValueMenuCode (command, variable_obj, dom_object, function_obj,
 
 }
 
-function addFunctionsToMenu (function_obj, menu_var_or_value, ref_object) {
+function addFunctionsToMenu (function_obj, menu_var_or_value, ref_object, expression_element) {
 	var sub_menu = menu_var_or_value.find('.menu_only_functions');
 	sub_menu.text('');
 
@@ -329,7 +470,7 @@ function addFunctionsToMenu (function_obj, menu_var_or_value, ref_object) {
 	}
 }
 
-function addVariablesToMenu (function_obj, menu_var_or_value, ref_object) {
+function addVariablesToMenu (function_obj, menu_var_or_value, ref_object, expression_element) {
 
 	var sub_menu = menu_var_or_value.find('.menu_only_vars');
 	sub_menu.text('');
@@ -371,7 +512,7 @@ function addVariablesToMenu (function_obj, menu_var_or_value, ref_object) {
 
 }
 
-function addHandlers (command, ref_object, dom_object, menu_var_or_value, function_obj) {
+function addHandlers (command, ref_object, dom_object, menu_var_or_value, function_obj, expression_element) {
 
 	if (ref_object.variable_and_value != VAR_OR_VALUE_TYPES.only_value) {
 		menu_var_or_value.dropdown({
@@ -380,17 +521,21 @@ function addHandlers (command, ref_object, dom_object, menu_var_or_value, functi
 
 		     switch ($selectedItem.data('option')) {
 		     	case VAR_OR_VALUE_TYPES.only_function:
-		     		openInputToFunction(command, ref_object, dom_object, menu_var_or_value, function_obj, $($selectedItem).data('function_reference'));
+		     		openInputToFunction(command, ref_object, dom_object, menu_var_or_value, function_obj, $($selectedItem).data('function_reference'), expression_element);
 		     		break;
 
 		     	case VAR_OR_VALUE_TYPES.only_value:
-		     		openInputToValue(command, ref_object, dom_object, menu_var_or_value, function_obj);
+		     		openInputToValue(command, ref_object, dom_object, menu_var_or_value, function_obj, expression_element);
 		     		break;
 
 		     	case VAR_OR_VALUE_TYPES.only_variable:
-		     		openInputToVariable(command, ref_object, dom_object, menu_var_or_value, function_obj, $($selectedItem).data('variable_reference'));
+		     		openInputToVariable(command, ref_object, dom_object, menu_var_or_value, function_obj, $($selectedItem).data('variable_reference'), expression_element);
 		     		break;
 		     }
+
+		     if ($selectedItem.data('exp')) {
+		     	AttribuitionsManagement.manageExpressionElements(command, ref_object, dom_object, menu_var_or_value, function_obj, $selectedItem, expression_element);
+		     }
 	      }
 	    });
 	}
@@ -410,7 +555,7 @@ function addHandlers (command, ref_object, dom_object, menu_var_or_value, functi
 	
 }
 
-function openInputToFunction (command, ref_object, dom_object, menu_var_or_value, function_obj, function_selected) {
+function openInputToFunction (command, ref_object, dom_object, menu_var_or_value, function_obj, function_selected, expression_element) {
 	
 	ref_object.function_called = function_selected;
 	ref_object.parameters_list = [];
@@ -437,12 +582,22 @@ function openInputToFunction (command, ref_object, dom_object, menu_var_or_value
 		for (var j = 0; j < function_selected.parameters_list.length; j++) {
 			var temp = new Models.VariableValueMenu(VAR_OR_VALUE_TYPES.all, null, null, null, true);
 			ref_object.parameters_list.push(temp);
-			renderMenu(command, temp, parameters_menu.find('.parameter_'+j), function_obj);
+			renderMenu(command, temp, parameters_menu.find('.parameter_'+j), function_obj, 2, expression_element);
 		}
 
 
 		var context_menu = '<div class="ui dropdown context_menu_clear"><div class="text"></div><i class="dropdown icon"></i><div class="menu">';
 		context_menu += '<div class="item" data-clear="true">'+LocalizedStrings.getUI('btn_clear')+'</div>';
+
+		if (command.type == Models.COMMAND_TYPES.attribution) {
+			context_menu += '<div class="item"><i class="dropdown icon"></i>' + LocalizedStrings.getUI('text_change');
+			context_menu += '<div class="menu">';
+			context_menu += '<div class="item" data-exp="'+Models.EXPRESSION_ELEMENTS.exp_op_exp+'">EXP OP EXP</div>';
+			context_menu += '<div class="item" data-exp="'+Models.EXPRESSION_ELEMENTS.op_exp+'">OP EXP</div>';
+			context_menu += '<div class="item" data-exp="'+Models.EXPRESSION_ELEMENTS.par_exp_par+'">( EXP )</div>';
+			context_menu += '</div></div>';
+		}
+
 		context_menu += '</div></div>';
 
 		context_menu = $(context_menu);
@@ -452,6 +607,7 @@ function openInputToFunction (command, ref_object, dom_object, menu_var_or_value
 		context_menu.dropdown({
 			onChange: function(value, text, $selectedItem) {
 		     if ($selectedItem.data('clear')) {
+		     	console.log('PP7');
 		     	dom_object.text('');
 
 		     	ref_object.content = null;
@@ -460,7 +616,11 @@ function openInputToFunction (command, ref_object, dom_object, menu_var_or_value
 		     	delete ref_object.function_called;
 		     	delete ref_object.parameters_list;
 
-		     	renderMenu(command, ref_object, dom_object, function_obj);
+		     	renderMenu(command, ref_object, dom_object, function_obj, 2, expression_element);
+		     }
+
+		     if ($selectedItem.data('exp')) {
+		     	AttribuitionsManagement.manageExpressionElements(command, ref_object, dom_object, menu_var_or_value, function_obj, $selectedItem, expression_element);
 		     }
 	      }
 		});
@@ -479,6 +639,16 @@ function openInputToFunction (command, ref_object, dom_object, menu_var_or_value
 
 		var context_menu = '<div class="ui dropdown context_menu_clear"><div class="text"></div><i class="dropdown icon"></i><div class="menu">';
 		context_menu += '<div class="item" data-clear="true">'+LocalizedStrings.getUI('btn_clear')+'</div>';
+
+		if (command.type == Models.COMMAND_TYPES.attribution) {
+			context_menu += '<div class="item"><i class="dropdown icon"></i>' + LocalizedStrings.getUI('text_change');
+			context_menu += '<div class="menu">';
+			context_menu += '<div class="item" data-exp="'+Models.EXPRESSION_ELEMENTS.exp_op_exp+'">EXP OP EXP</div>';
+			context_menu += '<div class="item" data-exp="'+Models.EXPRESSION_ELEMENTS.op_exp+'">OP EXP</div>';
+			context_menu += '<div class="item" data-exp="'+Models.EXPRESSION_ELEMENTS.par_exp_par+'">( EXP )</div>';
+			context_menu += '</div></div>';
+		}
+
 		context_menu += '</div></div>';
 
 		context_menu = $(context_menu);
@@ -488,6 +658,7 @@ function openInputToFunction (command, ref_object, dom_object, menu_var_or_value
 		context_menu.dropdown({
 			onChange: function(value, text, $selectedItem) {
 		     if ($selectedItem.data('clear')) {
+		     	console.log('PP8');
 		     	dom_object.text('');
 
 		     	ref_object.content = null;
@@ -496,7 +667,11 @@ function openInputToFunction (command, ref_object, dom_object, menu_var_or_value
 		     	delete ref_object.function_called;
 		     	delete ref_object.parameters_list;
 
-		     	renderMenu(command, ref_object, dom_object, function_obj);
+		     	renderMenu(command, ref_object, dom_object, function_obj, 2, expression_element);
+		     }
+
+		     if ($selectedItem.data('exp')) {
+		     	AttribuitionsManagement.manageExpressionElements(command, ref_object, dom_object, menu_var_or_value, function_obj, $selectedItem, expression_element);
 		     }
 	      }
 		});
@@ -511,7 +686,7 @@ function openInputToFunction (command, ref_object, dom_object, menu_var_or_value
 	}
 }
 
-function openInputToVariable (command, ref_object, dom_object, menu_var_or_value, function_obj, variable_selected) {
+function openInputToVariable (command, ref_object, dom_object, menu_var_or_value, function_obj, variable_selected, expression_element) {
 	
 	ref_object.content = variable_selected;
 
@@ -537,18 +712,28 @@ function openInputToVariable (command, ref_object, dom_object, menu_var_or_value
 
 	if (variable_selected.dimensions == 1) {
 		ref_object.column = new Models.VariableValueMenu(VAR_OR_VALUE_TYPES.all, null, null, null, true);
-		renderMenu(command, ref_object.column, variable_render.find('.column_container'), function_obj);
+		renderMenu(command, ref_object.column, variable_render.find('.column_container'), function_obj, 2, expression_element);
 	}
 	if (variable_selected.dimensions == 2) {
 		ref_object.row = new Models.VariableValueMenu(VAR_OR_VALUE_TYPES.all, null, null, null, true);
-		renderMenu(command, ref_object.row, variable_render.find('.row_container'), function_obj);
+		renderMenu(command, ref_object.row, variable_render.find('.row_container'), function_obj, 2, expression_element);
 
 		ref_object.column = new Models.VariableValueMenu(VAR_OR_VALUE_TYPES.all, null, null, null, true);
-		renderMenu(command, ref_object.column, variable_render.find('.column_container'), function_obj);
+		renderMenu(command, ref_object.column, variable_render.find('.column_container'), function_obj, 2, expression_element);
 	}
 
 	var context_menu = '<div class="ui dropdown context_menu_clear"><div class="text"></div><i class="dropdown icon"></i><div class="menu">';
 	context_menu += '<div class="item" data-clear="true">'+LocalizedStrings.getUI('btn_clear')+'</div>';
+
+	if (command.type == Models.COMMAND_TYPES.attribution) {
+		context_menu += '<div class="item"><i class="dropdown icon"></i>' + LocalizedStrings.getUI('text_change');
+		context_menu += '<div class="menu">';
+		context_menu += '<div class="item" data-exp="'+Models.EXPRESSION_ELEMENTS.exp_op_exp+'">EXP OP EXP</div>';
+		context_menu += '<div class="item" data-exp="'+Models.EXPRESSION_ELEMENTS.op_exp+'">OP EXP</div>';
+		context_menu += '<div class="item" data-exp="'+Models.EXPRESSION_ELEMENTS.par_exp_par+'">( EXP )</div>';
+		context_menu += '</div></div>';
+	}
+
 	context_menu += '</div></div>';
 
 	context_menu = $(context_menu);
@@ -558,6 +743,7 @@ function openInputToVariable (command, ref_object, dom_object, menu_var_or_value
 	context_menu.dropdown({
 		onChange: function(value, text, $selectedItem) {
 	     if ($selectedItem.data('clear')) {
+	     	console.log('PP9');
 	     	dom_object.text('');
 
 	     	ref_object.content = null;
@@ -567,7 +753,11 @@ function openInputToVariable (command, ref_object, dom_object, menu_var_or_value
 	     	delete ref_object.function_called;
 		    delete ref_object.parameters_list;
 
-	     	renderMenu(command, ref_object, dom_object, function_obj);
+	     	renderMenu(command, ref_object, dom_object, function_obj, 2, expression_element);
+	     }
+
+	     if ($selectedItem.data('exp')) {
+	     	AttribuitionsManagement.manageExpressionElements(command, ref_object, dom_object, menu_var_or_value, function_obj, $selectedItem, expression_element);
 	     }
       }
 	});
@@ -584,7 +774,7 @@ function openInputToVariable (command, ref_object, dom_object, menu_var_or_value
 }
 
 
-function openInputToValue (command, ref_object, dom_object, menu_var_or_value, function_obj) {
+function openInputToValue (command, ref_object, dom_object, menu_var_or_value, function_obj, expression_element) {
 
 	if (ref_object.content == null) {
 		ref_object.content = "";
@@ -599,19 +789,32 @@ function openInputToValue (command, ref_object, dom_object, menu_var_or_value, f
 	field.focus();
 	field.val(ref_object.content);
 
-	dom_object.find('.menu_var_or_value_dom').remove();
-
 	var context_menu = '<div class="ui dropdown context_menu_clear"><div class="text"></div><i class="dropdown icon"></i><div class="menu">';
 	context_menu += '<div class="item" data-clear="true">'+LocalizedStrings.getUI('btn_clear')+'</div>';
+
+	if (command.type == Models.COMMAND_TYPES.attribution) {
+		context_menu += '<div class="item"><i class="dropdown icon"></i>' + LocalizedStrings.getUI('text_change');
+		context_menu += '<div class="menu">';
+		context_menu += '<div class="item" data-exp="'+Models.EXPRESSION_ELEMENTS.exp_op_exp+'">EXP OP EXP</div>';
+		context_menu += '<div class="item" data-exp="'+Models.EXPRESSION_ELEMENTS.op_exp+'">OP EXP</div>';
+		context_menu += '<div class="item" data-exp="'+Models.EXPRESSION_ELEMENTS.par_exp_par+'">( EXP )</div>';
+		context_menu += '</div></div>';
+	}
+
 	context_menu += '</div></div>';
 
 	context_menu = $(context_menu);
 
-	context_menu.insertAfter( field );
+	dom_object.find('.menu_var_or_value_dom').remove();
+
+	if (ref_object.variable_and_value != VAR_OR_VALUE_TYPES.only_value) {
+		context_menu.insertAfter( field );
+	}
 
 	context_menu.dropdown({
 		onChange: function(value, text, $selectedItem) {
 	     if ($selectedItem.data('clear')) {
+	     	console.log('PP10');
 	     	dom_object.text('');
 
 	     	dom_object.find('.value_rendered').remove();
@@ -625,7 +828,11 @@ function openInputToValue (command, ref_object, dom_object, menu_var_or_value, f
 			delete ref_object.function_called;
 		    delete ref_object.parameters_list;
 
-	     	renderMenu(command, ref_object, dom_object, function_obj);
+	     	renderMenu(command, ref_object, dom_object, function_obj, 2, expression_element);
+	     }
+
+	     if ($selectedItem.data('exp')) {
+	     	AttribuitionsManagement.manageExpressionElements(command, ref_object, dom_object, menu_var_or_value, function_obj, $selectedItem, expression_element);
 	     }
       }
 	});
@@ -658,13 +865,14 @@ function openInputToValue (command, ref_object, dom_object, menu_var_or_value, f
 	});
 
 	rendered.on('click', function(e) {
+		console.log("TTT2");
 		rendered.remove();
 		rendered.empty();
 		rendered.remove();
 		dom_object.empty();
 		dom_object.append('<span class="menu_var_or_value_dom"> </span>');
 		
-		openInputToValue(command, ref_object, dom_object, menu_var_or_value, function_obj)
+		openInputToValue(command, ref_object, dom_object, menu_var_or_value, function_obj, expression_element)
 	});
 
 	if (command.type == Models.COMMAND_TYPES.attribution) {

+ 1 - 1
js/visualUI/commands/writer.js

@@ -17,7 +17,7 @@ export function renderCommand (command, function_obj) {
 	ret += '<div class="ui writer command_container"> <i class="ui icon small upload command_drag"></i> <i class="ui icon times red button_remove_command"></i> <span>'+LocalizedStrings.getUI('text_command_write')+' ( </span><div class="var_value_menu_div"></div> <span class="close_parentheses">)</span> </div>';
 
 	var el = $(ret);
-	$(el).data('command', command);
+	el.data('command', command);
 
 	VariableValueMenu.renderMenu(command, command.content[0], $(el).find('.var_value_menu_div'), function_obj);
 

+ 3 - 0
js/visualUI/functions.js

@@ -299,6 +299,9 @@ $( document ).ready(function() {
 
 function runCode () {
   const strCode = CodeManagement.generate();
+  if (strCode == null) {
+    return;
+  }
   domConsole = new DOMConsole("#ivprog-term");
   $("#ivprog-term").slideDown(500);
   const lexer = LanguageService.getCurrentLexer();

+ 14 - 11
js/visualUI/ivprog_elements.js

@@ -4,7 +4,9 @@ import WatchJS from 'melanke-watchjs';
 export const COMMAND_TYPES = Object.freeze({function:"function", comment:"comment", reader:"reader", writer:"writer", attribution:"attribution", iftrue:"iftrue",
  repeatNtimes:"repeatNtimes", whiletrue:"whiletrue", dowhiletrue:"dowhiletrue", switch:"switch", functioncall:"functioncall"});
 
-export const ARITHMETIC_TYPES = Object.freeze({plus:"plus", minus:"minus", multiplication:"multiplication", division:"division", module:"module"});
+export const ARITHMETIC_TYPES = Object.freeze({plus:"plus", minus:"minus", multiplication:"multiplication", division:"division", module:"module", none:"none"});
+
+export const EXPRESSION_ELEMENTS = Object.freeze({exp_op_exp:"exp_op_exp", op_exp:"op_exp", par_exp_par:"par_exp_par", start_point:"start_point"});
 
 export class Variable {
 
@@ -68,6 +70,16 @@ export class Attribution {
   }
 }
 
+export class ExpressionElement {
+
+  constructor (type_exp, itens = []) {
+    this.type_exp = type_exp;
+    this.itens = itens;
+  }
+}
+
+/*
+
 export class Expression {
 
   constructor (operand1, operand2, operator) {
@@ -76,16 +88,7 @@ export class Expression {
     this.operator = operator;
   }
 }
-/*
-export class ExpressionNode {
-
-  constructor (content, left_node, right_node) {
-    this.content = content;
-    this.left_node = left_node;
-    this.right_node = right_node;
-    
-  }
-}*/
+*/
 
 export class IfTrue {