Fix add links.

This commit is contained in:
Paulo Veiga
2011-10-08 20:36:47 -03:00
parent 52587c0eaa
commit 5d1ab3cb6e
19 changed files with 333 additions and 306 deletions

View File

@@ -16,7 +16,7 @@
* limitations under the License.
*/
mindplot.commands.AddLinkToTopicCommand = new Class({
mindplot.commands.ChangeLinkToTopicCommand = new Class({
Extends:mindplot.Command,
initialize: function(topicId, url) {
$assert(topicId, 'topicId can not be null');
@@ -24,12 +24,25 @@ mindplot.commands.AddLinkToTopicCommand = new Class({
this._url = url;
this._id = mindplot.Command._nextUUID();
},
execute: function(commandContext) {
var topic = commandContext.findTopics(this._objectsIds)[0];
topic.addLink(this._url, commandContext._designer);
if (topic.hasLink()) {
var model = topic.getModel();
var link = model.getLinks()[0];
this._oldUrl = link.getUrl();
topic.removeLink();
}
topic.addLink(this._url);
},
undoExecute: function(commandContext) {
var topic = commandContext.findTopics(this._objectsIds)[0];
topic.removeLink();
if (this._oldtext) {
topic.removeLink();
topic.addLink(this._oldUrl);
} else {
topic.removeLink();
}
}
});

View File

@@ -25,7 +25,8 @@ mindplot.commands.ChangeNoteToTopicCommand = new Class({
this._oldtext = null;
this._id = mindplot.Command._nextUUID();
},
execute: function(commandContext) {
execute: function(commandContext) {
var topic = commandContext.findTopics(this._objectsIds)[0];
if (topic.hasNote()) {
var model = topic.getModel();
@@ -35,6 +36,7 @@ mindplot.commands.ChangeNoteToTopicCommand = new Class({
}
topic.addNote(this._text);
},
undoExecute: function(commandContext) {
var topic = commandContext.findTopics(this._objectsIds)[0];
if (this._oldtext) {

View File

@@ -22,11 +22,15 @@ mindplot.commands.RemoveLinkFromTopicCommand = new Class({
$assert(topicId, 'topicId can not be null');
this._objectsIds = topicId;
},
execute: function(commandContext) {
var topic = commandContext.findTopics(this._objectsIds)[0];
this._url = topic._link.getUrl();
var model = topic.getModel();
var links = model.getLinks()[0];
this._text = links.getUrl();
topic.removeLink();
},
undoExecute: function(commandContext) {
var topic = commandContext.findTopics(this._objectsIds)[0];
topic.addLink(this._url, commandContext._designer);