Relationship lines can now be selected and deleted

This commit is contained in:
Pablo Luna
2010-12-22 19:34:24 -03:00
parent 67c4968aca
commit ae64037f3a
20 changed files with 400 additions and 207 deletions

View File

@@ -23,12 +23,12 @@ mindplot.commands.AddIconToTopicCommand = mindplot.Command.extend(
{
core.assert(topicId, 'topicId can not be null');
core.assert(iconType, 'iconType can not be null');
this._topicId = topicId;
this._selectedObjectsIds = topicId;
this._iconType = iconType;
},
execute: function(commandContext)
{
var topic = commandContext.findTopics(this._topicId)[0];
var topic = commandContext.findTopics(this._selectedObjectsIds)[0];
var updated = function() {
var iconImg = topic.addIcon(this._iconType, commandContext._designer);
this._iconModel = iconImg.getModel();
@@ -38,7 +38,7 @@ mindplot.commands.AddIconToTopicCommand = mindplot.Command.extend(
},
undoExecute: function(commandContext)
{
var topic = commandContext.findTopics(this._topicId)[0];
var topic = commandContext.findTopics(this._selectedObjectsIds)[0];
var updated = function() {
topic.removeIcon(this._iconModel);
topic.updateNode();

View File

@@ -22,13 +22,13 @@ mindplot.commands.AddLinkToTopicCommand = mindplot.Command.extend(
initialize: function(topicId,url)
{
core.assert(topicId, 'topicId can not be null');
this._topicId = topicId;
this._selectedObjectsIds = topicId;
this._url = url;
this._id = mindplot.Command._nextUUID();
},
execute: function(commandContext)
{
var topic = commandContext.findTopics(this._topicId)[0];
var topic = commandContext.findTopics(this._selectedObjectsIds)[0];
var updated = function() {
topic.addLink(this._url,commandContext._designer);
topic.updateNode();
@@ -37,7 +37,7 @@ mindplot.commands.AddLinkToTopicCommand = mindplot.Command.extend(
},
undoExecute: function(commandContext)
{
var topic = commandContext.findTopics(this._topicId)[0];
var topic = commandContext.findTopics(this._selectedObjectsIds)[0];
var updated = function() {
topic.removeLink();
}.bind(this);

View File

@@ -22,13 +22,13 @@ mindplot.commands.AddNoteToTopicCommand = mindplot.Command.extend(
initialize: function(topicId,text)
{
core.assert(topicId, 'topicId can not be null');
this._topicId = topicId;
this._selectedObjectsIds = topicId;
this._text = text;
this._id = mindplot.Command._nextUUID();
},
execute: function(commandContext)
{
var topic = commandContext.findTopics(this._topicId)[0];
var topic = commandContext.findTopics(this._selectedObjectsIds)[0];
var updated = function() {
topic.addNote(this._text,commandContext._designer);
topic.updateNode();
@@ -37,7 +37,7 @@ mindplot.commands.AddNoteToTopicCommand = mindplot.Command.extend(
},
undoExecute: function(commandContext)
{
var topic = commandContext.findTopics(this._topicId)[0];
var topic = commandContext.findTopics(this._selectedObjectsIds)[0];
var updated = function() {
topic.removeNote();
}.bind(this);

View File

@@ -24,13 +24,13 @@ mindplot.commands.ChangeIconFromTopicCommand = mindplot.Command.extend(
core.assert(topicId, 'topicId can not be null');
core.assert(iconId, 'iconId can not be null');
core.assert(iconType, 'iconType can not be null');
this._topicId = topicId;
this._selectedObjectsIds = topicId;
this._iconModel = iconId;
this._iconType = iconType;
},
execute: function(commandContext)
{
var topic = commandContext.findTopics(this._topicId)[0];
var topic = commandContext.findTopics(this._selectedObjectsIds)[0];
var updated = function() {
topic.removeIcon(this._iconModel);
topic.updateNode();
@@ -39,7 +39,7 @@ mindplot.commands.ChangeIconFromTopicCommand = mindplot.Command.extend(
},
undoExecute: function(commandContext)
{
var topic = commandContext.findTopics(this._topicId)[0];
var topic = commandContext.findTopics(this._selectedObjectsIds)[0];
var updated = function() {
topic.addIcon(this._iconModel, commandContext._designer);
topic.updateNode();

View File

@@ -22,7 +22,7 @@ mindplot.commands.DeleteTopicCommand = mindplot.Command.extend(
initialize: function(topicsIds)
{
core.assert(topicsIds, "topicsIds must be defined");
this._topicId = topicsIds;
this._selectedObjectsIds = topicsIds;
this._deletedTopicModels = [];
this._parentTopicIds = [];
this._deletedRelationships = [];
@@ -30,7 +30,8 @@ mindplot.commands.DeleteTopicCommand = mindplot.Command.extend(
},
execute: function(commandContext)
{
var topics = commandContext.findTopics(this._topicId);
var topics = commandContext.findTopics(this._selectedObjectsIds.nodes);
if(topics.length>0){
topics.forEach(
function(topic, index)
{
@@ -59,12 +60,21 @@ mindplot.commands.DeleteTopicCommand = mindplot.Command.extend(
commandContext.deleteTopic(topic);
}.bind(this)
);
); }
var lines = commandContext.findRelationships(this._selectedObjectsIds.relationshipLines);
if(lines.length>0){
lines.forEach(function(line,index){
if(line.isInWorkspace()){
this._deletedRelationships.push(line.getModel().clone());
commandContext.removeRelationship(line.getModel());
}
}.bind(this));
}
},
undoExecute: function(commandContext)
{
var topics = commandContext.findTopics(this._topicId);
var topics = commandContext.findTopics(this._selectedObjectsIds);
var parent = commandContext.findTopics(this._parentTopicIds);
this._deletedTopicModels.forEach(

View File

@@ -22,7 +22,7 @@ mindplot.commands.DragTopicCommand = mindplot.Command.extend(
initialize: function(topicId)
{
core.assert(topicId, "topicId must be defined");
this._topicId = topicId;
this._selectedObjectsIds = topicId;
this._parentTopic = null;
this._position = null;
this._order = null;
@@ -31,7 +31,7 @@ mindplot.commands.DragTopicCommand = mindplot.Command.extend(
execute: function(commandContext)
{
var topic = commandContext.findTopics([this._topicId])[0];
var topic = commandContext.findTopics([this._selectedObjectsIds])[0];
// Save old position ...
var origParentTopic = topic.getOutgoingConnectedTopic();

View File

@@ -24,7 +24,7 @@ mindplot.commands.GenericFunctionCommand = mindplot.Command.extend(
core.assert(commandFunc, "commandFunc must be defined");
core.assert(topicsIds, "topicsIds must be defined");
this._value = value;
this._topicId = topicsIds;
this._selectedObjectsIds = topicsIds;
this._commandFunc = commandFunc;
this._oldValues = [];
this._id = mindplot.Command._nextUUID();
@@ -33,7 +33,7 @@ mindplot.commands.GenericFunctionCommand = mindplot.Command.extend(
{
if (!this.applied)
{
var topics = commandContext.findTopics(this._topicId);
var topics = commandContext.findTopics(this._selectedObjectsIds);
topics.forEach(function(topic)
{
var oldValue = this._commandFunc(topic, this._value);
@@ -50,7 +50,7 @@ mindplot.commands.GenericFunctionCommand = mindplot.Command.extend(
{
if (this.applied)
{
var topics = commandContext.findTopics(this._topicId);
var topics = commandContext.findTopics(this._selectedObjectsIds);
topics.forEach(function(topic,index)
{
this._commandFunc(topic, this._oldValues[index]);

View File

@@ -1,59 +1,77 @@
mindplot.commands.MoveControlPointCommand = mindplot.Command.extend(
{
initialize: function(ctrlPointControler, point)
initialize: function(ctrlPointController, point)
{
core.assert(ctrlPointControler, 'line can not be null');
this._ctrlPointControler = ctrlPointControler;
core.assert(ctrlPointController, 'line can not be null');
this._ctrlPointControler = ctrlPointController;
this._line = ctrlPointController._line;
var model = this._line.getModel();
this._controlPoint = this._ctrlPointControler.getControlPoint(point).clone();
this._oldControlPoint= this._ctrlPointControler.getOriginalCtrlPoint(point).clone();
this._originalEndPoint = this._ctrlPointControler.getOriginalEndPoint(point).clone();
switch (point){
case 0:
this._wasCustom = this._line.getLine().isSrcControlPointCustom();
this._endPoint = this._line.getLine().getFrom().clone();
break;
case 1:
this._wasCustom = this._line.getLine().isDestControlPointCustom();
this._endPoint = this._line.getLine().getTo().clone();
break;
}
this._id = mindplot.Command._nextUUID();
this._wasCustom=false;
this._point = point;
this._controlPoint = null;
},
execute: function(commandContext)
{
var line = this._ctrlPointControler._line;
var ctrlPoints = line.getLine().getControlPoints();
var model = line.getModel();
var point = null;
var model = this._line.getModel();
switch (this._point){
case 0:
if(core.Utils.isDefined(model.getSrcCtrlPoint())){
this._controlPoint= model.getSrcCtrlPoint().clone();
}
model.setSrcCtrlPoint(ctrlPoints[0].clone());
this._wasCustom = line.getLine().isSrcControlPointCustom();
line.getLine().setIsSrcControlPointCustom(true);
model.setSrcCtrlPoint(this._controlPoint.clone());
this._line.getLine().setFrom(this._endPoint.x, this._endPoint.y);
this._line.getLine().setIsSrcControlPointCustom(true);
this._line.getLine().setSrcControlPoint(this._controlPoint.clone());
break;
case 1:
if(core.Utils.isDefined(model.getDestCtrlPoint())){
this._controlPoint = model.getDestCtrlPoint().clone();
}
model.setDestCtrlPoint(ctrlPoints[1].clone());
this._wasCustom = line.getLine().isDestControlPointCustom();
line.getLine().setIsDestControlPointCustom(true);
model.setDestCtrlPoint(this._controlPoint.clone());
this._wasCustom = this._line.getLine().isDestControlPointCustom();
this._line.getLine().setTo(this._endPoint.x, this._endPoint.y);
this._line.getLine().setIsDestControlPointCustom(true);
this._line.getLine().setDestControlPoint(this._controlPoint.clone());
break;
}
if(this._line.isOnFocus()){
this._line._refreshSelectedShape();
this._ctrlPointControler.setLine(this._line);
}
this._line.getLine().updateLine(this._point);
},
undoExecute: function(commandContext)
{
var line = this._ctrlPointControler._line;
var line = this._line;
var model = line.getModel();
switch (this._point){
case 0:
if(core.Utils.isDefined(this._controlPoint)){
model.setSrcCtrlPoint(this._controlPoint.clone());
line.getLine().setSrcControlPoint(this._controlPoint.clone());
if(core.Utils.isDefined(this._oldControlPoint)){
line.getLine().setFrom(this._originalEndPoint.x, this._originalEndPoint.y);
model.setSrcCtrlPoint(this._oldControlPoint.clone());
line.getLine().setSrcControlPoint(this._oldControlPoint.clone());
line.getLine().setIsSrcControlPointCustom(this._wasCustom);
}
break;
case 1:
if(core.Utils.isDefined(this._controlPoint)){
model.setDestCtrlPoint(this._controlPoint.clone());
line.getLine().setDestControlPoint(this._controlPoint.clone());
if(core.Utils.isDefined(this._oldControlPoint)){
line.getLine().setTo(this._originalEndPoint.x, this._originalEndPoint.y);
model.setDestCtrlPoint(this._oldControlPoint.clone());
line.getLine().setDestControlPoint(this._oldControlPoint.clone());
line.getLine().setIsDestControlPointCustom(this._wasCustom);
}
break;
}
this._ctrlPointControler.setLine(line);
this._line.getLine().updateLine(this._point);
if(this._line.isOnFocus()){
this._ctrlPointControler.setLine(line);
line._refreshSelectedShape();
}
}
});

View File

@@ -23,12 +23,12 @@ mindplot.commands.RemoveIconFromTopicCommand = mindplot.Command.extend(
{
core.assert(topicId, 'topicId can not be null');
core.assert(iconModel, 'iconId can not be null');
this._topicId = topicId;
this._selectedObjectsIds = topicId;
this._iconModel = iconModel;
},
execute: function(commandContext)
{
var topic = commandContext.findTopics(this._topicId)[0];
var topic = commandContext.findTopics(this._selectedObjectsIds)[0];
var updated = function() {
topic.removeIcon(this._iconModel);
topic.updateNode();
@@ -37,7 +37,7 @@ mindplot.commands.RemoveIconFromTopicCommand = mindplot.Command.extend(
},
undoExecute: function(commandContext)
{
var topic = commandContext.findTopics(this._topicId)[0];
var topic = commandContext.findTopics(this._selectedObjectsIds)[0];
var updated = function() {
var iconType = this._iconModel.getIconType();
var iconImg = topic.addIcon(iconType, commandContext._designer);

View File

@@ -22,11 +22,11 @@ mindplot.commands.RemoveLinkFromTopicCommand = mindplot.Command.extend(
initialize: function(topicId)
{
core.assert(topicId, 'topicId can not be null');
this._topicId = topicId;
this._selectedObjectsIds = topicId;
},
execute: function(commandContext)
{
var topic = commandContext.findTopics(this._topicId)[0];
var topic = commandContext.findTopics(this._selectedObjectsIds)[0];
this._url = topic._link.getUrl();
var updated = function() {
topic.removeLink();
@@ -35,7 +35,7 @@ mindplot.commands.RemoveLinkFromTopicCommand = mindplot.Command.extend(
},
undoExecute: function(commandContext)
{
var topic = commandContext.findTopics(this._topicId)[0];
var topic = commandContext.findTopics(this._selectedObjectsIds)[0];
var updated = function() {
topic.addLink(this._url,commandContext._designer);
topic.updateNode();

View File

@@ -22,11 +22,11 @@ mindplot.commands.RemoveNoteFromTopicCommand = mindplot.Command.extend(
initialize: function(topicId)
{
core.assert(topicId, 'topicId can not be null');
this._topicId = topicId;
this._selectedObjectsIds = topicId;
},
execute: function(commandContext)
{
var topic = commandContext.findTopics(this._topicId)[0];
var topic = commandContext.findTopics(this._selectedObjectsIds)[0];
this._text = topic._note.getText();
var updated = function() {
topic.removeNote();
@@ -35,7 +35,7 @@ mindplot.commands.RemoveNoteFromTopicCommand = mindplot.Command.extend(
},
undoExecute: function(commandContext)
{
var topic = commandContext.findTopics(this._topicId)[0];
var topic = commandContext.findTopics(this._selectedObjectsIds)[0];
var updated = function() {
topic.addNote(this._text,commandContext._designer);
topic.updateNode();