Unverified Commit baef0cdc authored by Evan W. Patton's avatar Evan W. Patton Committed by Jeffrey I. Schiller

Implement per-component tooltips on collison

Change-Id: I5778d0ddad1a34c1019645478fb6061d88acea10
parent 468b72a6
......@@ -569,7 +569,7 @@
<pathelement location="${gwt.sdk}/validation-api-1.0.0.GA-sources.jar" />
</classpath>
<jvmarg value="-Xss2M"/> <!-- increase if you see a StackOverflowError -->
<jvmarg value="-Xmx1G"/>
<jvmarg value="-Xmx2G"/>
<jvmarg line="${XstartOnFirstThread}"/>
<jvmarg value="-Dfile.encoding=UTF-8" />
<arg line="-war"/>
......
......@@ -283,10 +283,11 @@ Blockly.Blocks.component_event = {
this.setParameterOrientation(horizParams);
var tooltipDescription;
if (eventType) {
tooltipDescription = componentDb.getInternationalizedEventDescription(eventType.name, eventType.description);
tooltipDescription = componentDb.getInternationalizedEventDescription(this.getTypeName(), eventType.name,
eventType.description);
}
else {
tooltipDescription = componentDb.getInternationalizedEventDescription(this.eventName);
tooltipDescription = componentDb.getInternationalizedEventDescription(this.getTypeName(), this.eventName);
}
this.setTooltip(tooltipDescription);
this.setPreviousStatement(false, null);
......@@ -309,6 +310,10 @@ Blockly.Blocks.component_event = {
this.rendered = oldRendered;
},
getTypeName: function() {
return this.typeName === 'Form' ? 'Screen' : this.typeName;
},
// [lyn, 10/24/13] Allow switching between horizontal and vertical display of arguments
// Also must create flydown params and DO input if they don't exist.
......@@ -418,11 +423,10 @@ Blockly.Blocks.component_event = {
}
},
helpUrl : function() {
var mode = this.typeName === "Form" ? "Screen" : this.typeName;
var url = Blockly.ComponentBlock.EVENTS_HELPURLS[mode];
var url = Blockly.ComponentBlock.EVENTS_HELPURLS[this.getTypeName()];
if (url && url[0] == '/') {
var parts = url.split('#');
parts[1] = this.typeName + '.' + this.eventName;
parts[1] = this.getTypeName() + '.' + this.eventName;
url = parts.join('#');
}
return url;
......@@ -599,18 +603,14 @@ Blockly.Blocks.component_event = {
Blockly.Blocks.component_method = {
category : 'Component',
helpUrl : function() {
var mode = this.typeName === "Form" ? "Screen" : this.typeName;
var url = Blockly.ComponentBlock.METHODS_HELPURLS[mode];
var url = Blockly.ComponentBlock.METHODS_HELPURLS[this.getTypeName()];
if (url && url[0] == '/') {
var parts = url.split('#');
parts[1] = this.typeName + '.' + this.methodName;
parts[1] = this.getTypeName() + '.' + this.methodName;
url = parts.join('#');
}
return url;
},
init: function() {
this.genericComponentInput = Blockly.Msg.LANG_COMPONENT_BLOCK_GENERIC_METHOD_TITLE_FOR_COMPONENT;
},
mutationToDom : function() {
......@@ -728,9 +728,10 @@ Blockly.Blocks.component_method = {
var tooltipDescription;
if (methodTypeObject) {
tooltipDescription = componentDb.getInternationalizedMethodDescription(methodTypeObject.name, methodTypeObject.description);
tooltipDescription = componentDb.getInternationalizedMethodDescription(this.getTypeName(), methodTypeObject.name,
methodTypeObject.description);
} else {
tooltipDescription = componentDb.getInternationalizedMethodDescription(this.typeName);
tooltipDescription = componentDb.getInternationalizedMethodDescription(this.getTypeName(), this.methodName);
}
this.setTooltip(tooltipDescription);
......@@ -780,6 +781,10 @@ Blockly.Blocks.component_method = {
this.rendered = oldRendered;
},
getTypeName: function() {
return this.typeName === 'Form' ? 'Screen' : this.typeName;
},
// Rename the block's instanceName, type, and reset its title
rename : function(oldname, newname) {
if (this.instanceName == oldname) {
......@@ -957,11 +962,10 @@ Blockly.Blocks.component_set_get = {
category : 'Component',
//this.blockType = 'getter',
helpUrl : function() {
var mode = this.typeName === "Form" ? "Screen" : this.typeName;
var url = Blockly.ComponentBlock.PROPERTIES_HELPURLS[mode];
var url = Blockly.ComponentBlock.PROPERTIES_HELPURLS[this.getTypeName()];
if (url && url[0] == '/') {
var parts = url.split('#');
parts[1] = this.typeName + '.' + this.propertyName;
parts[1] = this.getTypeName() + '.' + this.propertyName;
url = parts.join('#');
}
return url;
......@@ -1026,7 +1030,8 @@ Blockly.Blocks.component_set_get = {
}
var tooltipDescription;
if (this.propertyName) {
tooltipDescription = componentDb.getInternationalizedPropertyDescription(this.propertyName, this.propertyObject.description);
tooltipDescription = componentDb.getInternationalizedPropertyDescription(this.getTypeName(), this.propertyName,
this.propertyObject.description);
} else {
tooltipDescription = Blockly.Msg.UNDEFINED_BLOCK_TOOLTIP;
}
......@@ -1042,7 +1047,8 @@ Blockly.Blocks.component_set_get = {
thisBlock.propertyObject = thisBlock.getPropertyObject(selection);
thisBlock.setTypeCheck();
if (thisBlock.propertyName) {
thisBlock.setTooltip(componentDb.getInternationalizedPropertyDescription(thisBlock.propertyName, thisBlock.propertyObject.description));
thisBlock.setTooltip(componentDb.getInternationalizedPropertyDescription(thisBlock.getTabCatcherElement(),
thisBlock.propertyName, thisBlock.propertyObject.description));
} else {
thisBlock.setTooltip(Blockly.Msg.UNDEFINED_BLOCK_TOOLTIP);
}
......@@ -1135,6 +1141,10 @@ Blockly.Blocks.component_set_get = {
this.rendered = oldRendered;
},
getTypeName: function() {
return this.typeName === 'Form' ? 'Screen' : this.typeName;
},
setTypeCheck : function() {
var inputOrOutput = Blockly.Blocks.Utilities.OUTPUT;
......@@ -1304,8 +1314,7 @@ Blockly.Blocks.component_component_block = {
category : 'Component',
helpUrl : function() {
var mode = this.typeName === "Form" ? "Screen" : this.typeName;
return Blockly.ComponentBlock.HELPURLS[mode];
return Blockly.ComponentBlock.HELPURLS[this.getTypeName()];
}, // TODO: fix
mutationToDom : function() {
......@@ -1329,6 +1338,11 @@ Blockly.Blocks.component_component_block = {
this.setOutput(true, [this.typeName,"COMPONENT"]);
this.errors = [{name:"checkIfUndefinedBlock"},{name:"checkComponentNotExistsError"}];
},
getTypeName: function() {
return this.typeName === 'Form' ? 'Screen' : this.typeName;
},
// Renames the block's instanceName, type, and reset its title
rename : function(oldname, newname) {
if (this.instanceName == oldname) {
......
......@@ -360,30 +360,38 @@ Blockly.ComponentDatabase.prototype.populateTypes = function(componentInfos) {
}
};
Blockly.ComponentDatabase.PROPDESC = /PropertyDescriptions$/;
Blockly.ComponentDatabase.METHODDESC = /MethodDescrptions$/;
Blockly.ComponentDatabase.EVENTDESC = /EventDescriptions$/;
/**
* Populate the tranlsations for components.
* @param translations
*/
Blockly.ComponentDatabase.prototype.populateTranslations = function(translations) {
var newkey;
for (var key in translations) {
if (translations.hasOwnProperty(key)) {
var parts = key.split('-', 2);
if (parts[0] == 'COMPONENT') {
if (parts[0] === 'COMPONENT') {
this.i18nComponentTypes_[parts[1]] = translations[key];
} else if (parts[0] == 'PROPERTY') {
} else if (parts[0] === 'PROPERTY') {
this.i18nPropertyNames_[parts[1]] = translations[key];
} else if (parts[0] == 'EVENT') {
} else if (parts[0] === 'EVENT') {
this.i18nEventNames_[parts[1]] = translations[key];
} else if (parts[0] == 'METHOD') {
} else if (parts[0] === 'METHOD') {
this.i18nMethodNames_[parts[1]] = translations[key];
} else if (parts[0] == 'PARAM') {
} else if (parts[0] === 'PARAM') {
this.i18nParamNames_[parts[1]] = translations[key];
} else if (parts[0] == 'EVENTDESC') {
} else if (parts[0] === 'EVENTDESC') {
newkey = parts[1].replace(Blockly.ComponentDatabase.EVENTDESC, '');
this.i18nEventDescriptions_[parts[1]] = translations[key];
} else if (parts[0] == 'METHDESC') {
this.i18nMethodDescriptions_[parts[1]] = translations[key];
} else if (parts[0] == 'PROPDESC') {
this.i18nPropertyDescriptions_[parts[1]] = translations[key];
} else if (parts[0] === 'METHODDESC') {
newkey = parts[1].replace(Blockly.ComponentDatabase.METHODDESC, '');
this.i18nMethodDescriptions_[newkey] = translations[key];
} else if (parts[0] === 'PROPDESC') {
newkey = parts[1].replace(Blockly.ComponentDatabase.PROPDESC, '');
this.i18nPropertyDescriptions_[newkey] = translations[key];
}
}
}
......@@ -521,8 +529,8 @@ Blockly.ComponentDatabase.prototype.getInternationalizedEventName = function(nam
* @param {?string=name} opt_default Optional default value (default: name parameter)
* @returns {string} The localized string if available, otherwise the unlocalized name.
*/
Blockly.ComponentDatabase.prototype.getInternationalizedEventDescription = function(name, opt_default) {
return this.i18nEventDescriptions_[name] || opt_default || name;
Blockly.ComponentDatabase.prototype.getInternationalizedEventDescription = function(component, name, opt_default) {
return this.i18nEventDescriptions_[component + '.' + name] || this.i18nEventDescriptions_[name] || opt_default || name;
};
/**
......@@ -541,8 +549,8 @@ Blockly.ComponentDatabase.prototype.getInternationalizedMethodName = function(na
* @param {?string=name} opt_default Optional default value (default: name parameter)
* @returns {string} The localized string if available, otherwise the unlocalized name.
*/
Blockly.ComponentDatabase.prototype.getInternationalizedMethodDescription = function(name, opt_default) {
return this.i18nMethodDescriptions_[name] || opt_default || name;
Blockly.ComponentDatabase.prototype.getInternationalizedMethodDescription = function(component, name, opt_default) {
return this.i18nMethodDescriptions_[component + '.' + name] || this.i18nMethodDescriptions_[name] || opt_default || name;
};
/**
......@@ -571,6 +579,6 @@ Blockly.ComponentDatabase.prototype.getInternationalizedPropertyName = function(
* @param {?string=name} opt_default Optional default value (default: name parameter)
* @returns {string} The localized string if available, otherwise the unlocalized name.
*/
Blockly.ComponentDatabase.prototype.getInternationalizedPropertyDescription = function(name, opt_default) {
return this.i18nPropertyDescriptions_[name] || opt_default || name;
Blockly.ComponentDatabase.prototype.getInternationalizedPropertyDescription = function(component, name, opt_default) {
return this.i18nPropertyDescriptions_[component + '.' + name] || this.i18nPropertyDescriptions_[name] || opt_default || name;
};
......@@ -61,7 +61,7 @@ page.open('src/demos/yail/yail_testing_index.html', function(status) {
'METHOD-TranslatedMethod': 'SuccessfulMethod',
'PROPERTY-TranslatedProperty': 'SuccessfulProperty',
'EVENTDESC-TranslatedEvent': 'Successfully translated event test.',
'METHDESC-TranslatedMethod': 'Successfully translated method test.',
'METHODDESC-TranslatedMethod': 'Successfully translated method test.',
'PROPDESC-TranslatedProperty': 'Successfully translated property test.'
});
......
......@@ -841,6 +841,14 @@ public abstract class ComponentProcessor extends AbstractProcessor {
return "Form".equals(componentTypeName) ? "Screen" : componentTypeName;
}
protected String getName() {
if (name.equals("Form")) {
return "Screen";
} else {
return name;
}
}
}
/**
......
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