- Fix errors on actions over central topic.

This commit is contained in:
Paulo Veiga 2011-11-30 00:56:21 -03:00
parent e520d9baba
commit dfc3bbdbe6
9 changed files with 28 additions and 26 deletions

View File

@ -21,18 +21,18 @@ mindplot.commands.AddIconToTopicCommand = new Class({
initialize: function(topicId, iconType) {
$assert($defined(topicId), 'topicId can not be null');
$assert(iconType, 'iconType can not be null');
this._objectsIds = topicId;
this._topicsIds = topicId;
this._iconType = iconType;
},
execute: function(commandContext) {
var topic = commandContext.findTopics(this._objectsIds)[0];
var topic = commandContext.findTopics(this._topicsIds)[0];
var iconImg = topic.addIcon(this._iconType, commandContext._designer);
this._iconModel = iconImg.getModel();
},
undoExecute: function(commandContext) {
var topic = commandContext.findTopics(this._objectsIds)[0];
var topic = commandContext.findTopics(this._topicsIds)[0];
topic.removeIcon(this._iconModel);
}
});

View File

@ -20,13 +20,13 @@ mindplot.commands.ChangeLinkToTopicCommand = new Class({
Extends:mindplot.Command,
initialize: function(topicId, url) {
$assert(topicId, 'topicId can not be null');
this._objectsIds = topicId;
this._topicsIds = topicId;
this._url = url;
this._id = mindplot.Command._nextUUID();
},
execute: function(commandContext) {
var topic = commandContext.findTopics(this._objectsIds)[0];
var topic = commandContext.findTopics(this._topicsIds)[0];
if (topic.hasLink()) {
var model = topic.getModel();
var link = model.getLinks()[0];
@ -37,7 +37,7 @@ mindplot.commands.ChangeLinkToTopicCommand = new Class({
},
undoExecute: function(commandContext) {
var topic = commandContext.findTopics(this._objectsIds)[0];
var topic = commandContext.findTopics(this._topicsIds)[0];
if (this._oldtext) {
topic.removeLink();
topic.addLink(this._oldUrl);

View File

@ -20,14 +20,14 @@ mindplot.commands.ChangeNoteToTopicCommand = new Class({
Extends:mindplot.Command,
initialize: function(topicId, text) {
$assert(topicId, 'topicId can not be null');
this._objectsIds = topicId;
this._topicsIds = topicId;
this._text = text;
this._oldtext = null;
this._id = mindplot.Command._nextUUID();
},
execute: function(commandContext) {
var topic = commandContext.findTopics(this._objectsIds)[0];
var topic = commandContext.findTopics(this._topicsIds)[0];
if (topic.hasNote()) {
var model = topic.getModel();
var notes = model.getNotes()[0];
@ -38,7 +38,7 @@ mindplot.commands.ChangeNoteToTopicCommand = new Class({
},
undoExecute: function(commandContext) {
var topic = commandContext.findTopics(this._objectsIds)[0];
var topic = commandContext.findTopics(this._topicsIds)[0];
if (this._oldtext) {
topic.removeNote();
topic.addNote(this._oldtext);

View File

@ -19,6 +19,8 @@
mindplot.commands.DeleteCommand = new Class({
Extends:mindplot.Command,
initialize: function(topicIds, relIds) {
$assert($defined(topicIds), 'topicIds can not be null');
this._relIds = relIds;
this._topicIds = topicIds;
this._deletedTopicModels = [];

View File

@ -21,7 +21,7 @@ mindplot.commands.DragTopicCommand = new Class({
initialize: function(topicIds, position, order, parentTopic) {
$assert(topicIds, "topicIds must be defined");
this._objectsIds = topicIds;
this._topicsIds = topicIds;
if ($defined(parentTopic))
this._parentId = parentTopic.getId();
@ -32,7 +32,7 @@ mindplot.commands.DragTopicCommand = new Class({
execute: function(commandContext) {
var topic = commandContext.findTopics([this._objectsIds])[0];
var topic = commandContext.findTopics([this._topicsIds])[0];
// Save old position ...
var origParentTopic = topic.getOutgoingConnectedTopic();

View File

@ -23,14 +23,14 @@ mindplot.commands.GenericFunctionCommand = new Class({
$assert(topicsIds, "topicsIds must be defined");
this._value = value;
this._objectsIds = topicsIds;
this._topicsIds = topicsIds;
this._commandFunc = commandFunc;
this._oldValues = [];
this._id = mindplot.Command._nextUUID();
},
execute: function(commandContext) {
if (!this.applied) {
var topics = commandContext.findTopics(this._objectsIds);
var topics = commandContext.findTopics(this._topicsIds);
topics.forEach(function(topic) {
var oldValue = this._commandFunc(topic, this._value);
this._oldValues.push(oldValue);
@ -43,7 +43,7 @@ mindplot.commands.GenericFunctionCommand = new Class({
},
undoExecute: function(commandContext) {
if (this.applied) {
var topics = commandContext.findTopics(this._objectsIds);
var topics = commandContext.findTopics(this._topicsIds);
topics.forEach(function(topic, index) {
this._commandFunc(topic, this._oldValues[index]);

View File

@ -19,19 +19,19 @@
mindplot.commands.RemoveIconFromTopicCommand = new Class({
Extends:mindplot.Command,
initialize: function(topicIds, iconModel) {
$assert(topicIds, 'topicIds can not be null');
$assert($defined(topicIds), 'topicIds can not be null');
$assert(iconModel, 'iconModel can not be null');
this._objectsIds = topicIds;
this._topicsIds = topicIds;
this._iconModel = iconModel;
},
execute: function(commandContext) {
var topic = commandContext.findTopics(this._objectsIds)[0];
var topic = commandContext.findTopics(this._topicsIds)[0];
topic.removeIcon(this._iconModel);
},
undoExecute: function(commandContext) {
var topic = commandContext.findTopics(this._objectsIds)[0];
var topic = commandContext.findTopics(this._topicsIds)[0];
var iconType = this._iconModel.getIconType();
var iconImg = topic.addIcon(iconType, commandContext._designer);
this._iconModel = iconImg.getModel();

View File

@ -19,12 +19,12 @@
mindplot.commands.RemoveLinkFromTopicCommand = new Class({
Extends:mindplot.Command,
initialize: function(topicId) {
$assert(topicId, 'topicId can not be null');
this._objectsIds = topicId;
$assert($defined(topicId), 'topicId can not be null');
this._topicsIds = topicId;
},
execute: function(commandContext) {
var topic = commandContext.findTopics(this._objectsIds)[0];
var topic = commandContext.findTopics(this._topicsIds)[0];
var model = topic.getModel();
var links = model.getLinks()[0];
this._text = links.getUrl();
@ -32,7 +32,7 @@ mindplot.commands.RemoveLinkFromTopicCommand = new Class({
},
undoExecute: function(commandContext) {
var topic = commandContext.findTopics(this._objectsIds)[0];
var topic = commandContext.findTopics(this._topicsIds)[0];
topic.addLink(this._url, commandContext._designer);
}
});

View File

@ -19,18 +19,18 @@
mindplot.commands.RemoveNoteFromTopicCommand = new Class({
Extends:mindplot.Command,
initialize: function(topicId) {
$assert(topicId, 'topicId can not be null');
this._objectsIds = topicId;
$assert($defined(topicId), 'topicId can not be null');
this._topicsIds = topicId;
},
execute: function(commandContext) {
var topic = commandContext.findTopics(this._objectsIds)[0];
var topic = commandContext.findTopics(this._topicsIds)[0];
var model = topic.getModel();
var notes = model.getNotes()[0];
this._text = notes.getText();
topic.removeNote();
},
undoExecute: function(commandContext) {
var topic = commandContext.findTopics(this._objectsIds)[0];
var topic = commandContext.findTopics(this._topicsIds)[0];
topic.addNote(this._text, commandContext._designer);
}
});