Add debug information. REMOVE COMMIT

This commit is contained in:
Paulo Gustavo Veiga 2012-10-01 23:26:28 -03:00
parent 4f1bb45fc2
commit 7fa766c2d0
2 changed files with 32 additions and 6 deletions

View File

@ -54,6 +54,7 @@ mindplot.StandaloneActionDispatcher = new Class({
};
var command = new mindplot.commands.GenericFunctionCommand(commandFunc, topicId, position);
command.desc = "move topic";
this.execute(command);
},
@ -71,6 +72,7 @@ mindplot.StandaloneActionDispatcher = new Class({
return result;
};
var command = new mindplot.commands.GenericFunctionCommand(commandFunc, topicsIds);
command.desc = "changeFontStyleToTopic";
this.execute(command);
},
@ -85,6 +87,7 @@ mindplot.StandaloneActionDispatcher = new Class({
};
var command = new mindplot.commands.GenericFunctionCommand(commandFunc, topicsIds, text);
command.desc = "changeTextToTopic";
this.execute(command);
},
@ -102,6 +105,8 @@ mindplot.StandaloneActionDispatcher = new Class({
};
var command = new mindplot.commands.GenericFunctionCommand(commandFunc, topicIds, fontFamily);
command.desc = "changeFontFamilyToTopic";
this.execute(command);
},
@ -117,6 +122,7 @@ mindplot.StandaloneActionDispatcher = new Class({
var command = new mindplot.commands.GenericFunctionCommand(commandFunc, topicsIds, color);
command.discardDuplicated = "fontColorCommandId";
command.desc = "changeFontColorToTopic";
this.execute(command);
},
@ -132,6 +138,8 @@ mindplot.StandaloneActionDispatcher = new Class({
var command = new mindplot.commands.GenericFunctionCommand(commandFunc, topicsIds, color);
command.discardDuplicated = "backColor";
command.desc = "changeBackgroundColorToTopic";
this.execute(command);
},
@ -147,6 +155,8 @@ mindplot.StandaloneActionDispatcher = new Class({
var command = new mindplot.commands.GenericFunctionCommand(commandFunc, topicsIds, color);
command.discardDuplicated = "borderColorCommandId";
command.desc = "changeBorderColorToTopic";
this.execute(command);
},
@ -163,6 +173,8 @@ mindplot.StandaloneActionDispatcher = new Class({
};
var command = new mindplot.commands.GenericFunctionCommand(commandFunc, topicsIds, size);
command.desc = "changeFontSizeToTopic";
this.execute(command);
},
@ -177,6 +189,8 @@ mindplot.StandaloneActionDispatcher = new Class({
};
var command = new mindplot.commands.GenericFunctionCommand(commandFunc, topicsIds, shapeType);
command.desc = "changeShapeTypeToTopic";
this.execute(command);
},
@ -193,6 +207,8 @@ mindplot.StandaloneActionDispatcher = new Class({
};
var command = new mindplot.commands.GenericFunctionCommand(commandFunc, topicsIds);
command.desc = "changeFontWeightToTopic";
this.execute(command);
},
@ -205,6 +221,8 @@ mindplot.StandaloneActionDispatcher = new Class({
};
var command = new mindplot.commands.GenericFunctionCommand(commandFunc, topicsIds, collapse);
command.desc = "shrinkBranch";
this.execute(command, false);
},

View File

@ -18,7 +18,7 @@
mindplot.commands.GenericFunctionCommand = new Class({
Extends:mindplot.Command,
initialize: function(commandFunc, topicsIds,value) {
initialize:function (commandFunc, topicsIds, value) {
$assert(commandFunc, "commandFunc must be defined");
$assert($defined(topicsIds), "topicsIds must be defined");
@ -29,10 +29,18 @@ mindplot.commands.GenericFunctionCommand = new Class({
this._oldValues = [];
},
execute: function(commandContext) {
execute:function (commandContext) {
if (!this.applied) {
var topics = commandContext.findTopics(this._topicsId);
topics.each(function(topic) {
// @Todo: Debug hack. Remove
var topics;
try {
topics = commandContext.findTopics(this._topicsId);
} catch (e) {
throw new Error(e + "," + this._commandFunc + "," + this._commandFunc.desc);
}
topics.each(function (topic) {
var oldValue = this._commandFunc(topic, this._value);
this._oldValues.push(oldValue);
}.bind(this));
@ -43,10 +51,10 @@ mindplot.commands.GenericFunctionCommand = new Class({
},
undoExecute: function(commandContext) {
undoExecute:function (commandContext) {
if (this.applied) {
var topics = commandContext.findTopics(this._topicsId);
topics.each(function(topic, index) {
topics.each(function (topic, index) {
this._commandFunc(topic, this._oldValues[index]);
}.bind(this));