Commit a5efc617 authored by Evan W. Patton's avatar Evan W. Patton Committed by Susan Rati Lane

Make empty component setter sockets errors, not warnings

Change-Id: I59456500e2e89b0ce43f0f80f5d447dae8b8a2ea
parent ab7650f1
......@@ -591,6 +591,9 @@ Blockly.Blocks.component_method = {
var mode = this.typeName === "Form" ? "Screen" : this.typeName;
return Blockly.ComponentBlock.METHODS_HELPURLS[mode];
},
init: function() {
this.genericComponentInput = Blockly.Msg.LANG_COMPONENT_BLOCK_GENERIC_METHOD_TITLE_FOR_COMPONENT;
},
mutationToDom : function() {
......@@ -745,7 +748,8 @@ Blockly.Blocks.component_method = {
this.setNextStatement(true);
}
this.errors = [{name:"checkIfUndefinedBlock"},{name:"checkIsInDefinition"},{name:"checkComponentNotExistsError"}];
this.errors = [{name:"checkIfUndefinedBlock"}, {name:"checkIsInDefinition"},
{name:"checkComponentNotExistsError"}, {name: "checkGenericComponentSocket"}];
// mark the block bad if the method isn't defined or is marked deprecated
var method = this.getMethodTypeObject();
......@@ -939,6 +943,7 @@ Blockly.Blocks.component_set_get = {
init: function() {
this.componentDropDown = Blockly.ComponentBlock.createComponentDropDown(this);
this.genericComponentInput = Blockly.Msg.LANG_COMPONENT_BLOCK_GENERIC_SETTER_TITLE_OF_COMPONENT;
},
mutationToDom : function() {
......@@ -1085,7 +1090,9 @@ Blockly.Blocks.component_set_get = {
this.setTooltip(tooltipDescription);
this.errors = [{name:"checkIfUndefinedBlock"},{name:"checkIsInDefinition"},{name:"checkComponentNotExistsError"}];
this.errors = [{name:"checkIfUndefinedBlock"}, {name:"checkIsInDefinition"},
{name:"checkComponentNotExistsError"}, {name: 'checkGenericComponentSocket'},
{name: 'checkEmptySetterSocket'}];
if (thisBlock.propertyObject && this.propertyObject.deprecated === "true" && this.workspace === Blockly.mainWorkspace) {
// [lyn, 2015/12/27] mark deprecated properties as bad
......
......@@ -1397,6 +1397,8 @@ Blockly.Msg.en.switch_language_to_english = {
Blockly.Msg.HIDE_WARNINGS = "Hide Warnings";
Blockly.Msg.MISSING_SOCKETS_WARNINGS = "You should fill all of the sockets with blocks";
Blockly.Msg.WRONG_TYPE_BLOCK_WARINGS = "This block should be connected to an event block or a procedure definition";
Blockly.Msg.ERROR_PROPERTY_SETTER_NEEDS_VALUE = 'This block needs a value block connected to its socket.';
Blockly.Msg.ERROR_GENERIC_NEEDS_COMPONENT = 'You need to provide a valid component to this block\'s "%1" socket.';
// Messages from replmgr.js
Blockly.Msg.REPL_ERROR_FROM_COMPANION = "Error from Companion";
......
......@@ -604,6 +604,29 @@ Blockly.WarningHandler.prototype.checkDisposedBlock = function(block){
}
};
Blockly.WarningHandler.prototype['checkEmptySetterSocket'] = function(block) {
if (block.setOrGet === 'set') {
var value = block.getInputTargetBlock('VALUE');
if (!value) {
block.setErrorIconText(Blockly.Msg.ERROR_PROPERTY_SETTER_NEEDS_VALUE);
return true;
}
}
return false;
};
Blockly.WarningHandler.prototype['checkGenericComponentSocket'] = function(block) {
if (block.isGeneric) {
var value = block.getInputTargetBlock('COMPONENT');
if (!value) {
block.setErrorIconText(Blockly.Msg.ERROR_GENERIC_NEEDS_COMPONENT
.replace(/%1/, block.genericComponentInput));
return true;
}
}
return false;
};
//Warnings
//Warnings indicate that there is a problem with the project, but it will not run
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment