Refactor designer moving methods to a designer model.
This commit is contained in:
@@ -21,12 +21,12 @@ mindplot.commands.AddIconToTopicCommand = new Class({
|
||||
initialize: function(topicId, iconType) {
|
||||
$assert(topicId, 'topicId can not be null');
|
||||
$assert(iconType, 'iconType can not be null');
|
||||
this._selectedObjectsIds = topicId;
|
||||
this._objectsIds = topicId;
|
||||
this._iconType = iconType;
|
||||
},
|
||||
|
||||
execute: function(commandContext) {
|
||||
var topic = commandContext.findTopics(this._selectedObjectsIds)[0];
|
||||
var topic = commandContext.findTopics(this._objectsIds)[0];
|
||||
var updated = function() {
|
||||
var iconImg = topic.addIcon(this._iconType, commandContext._designer);
|
||||
this._iconModel = iconImg.getModel();
|
||||
@@ -36,7 +36,7 @@ mindplot.commands.AddIconToTopicCommand = new Class({
|
||||
},
|
||||
|
||||
undoExecute: function(commandContext) {
|
||||
var topic = commandContext.findTopics(this._selectedObjectsIds)[0];
|
||||
var topic = commandContext.findTopics(this._objectsIds)[0];
|
||||
var updated = function() {
|
||||
topic.removeIcon(this._iconModel);
|
||||
topic.updateNode();
|
||||
|
@@ -20,12 +20,12 @@ mindplot.commands.AddLinkToTopicCommand = new Class({
|
||||
Extends:mindplot.Command,
|
||||
initialize: function(topicId, url) {
|
||||
$assert(topicId, 'topicId can not be null');
|
||||
this._selectedObjectsIds = topicId;
|
||||
this._objectsIds = topicId;
|
||||
this._url = url;
|
||||
this._id = mindplot.Command._nextUUID();
|
||||
},
|
||||
execute: function(commandContext) {
|
||||
var topic = commandContext.findTopics(this._selectedObjectsIds)[0];
|
||||
var topic = commandContext.findTopics(this._objectsIds)[0];
|
||||
var updated = function() {
|
||||
topic.addLink(this._url, commandContext._designer);
|
||||
topic.updateNode();
|
||||
@@ -33,7 +33,7 @@ mindplot.commands.AddLinkToTopicCommand = new Class({
|
||||
updated.delay(0);
|
||||
},
|
||||
undoExecute: function(commandContext) {
|
||||
var topic = commandContext.findTopics(this._selectedObjectsIds)[0];
|
||||
var topic = commandContext.findTopics(this._objectsIds)[0];
|
||||
var updated = function() {
|
||||
topic.removeLink();
|
||||
}.bind(this);
|
||||
|
@@ -20,12 +20,12 @@ mindplot.commands.AddNoteToTopicCommand = new Class({
|
||||
Extends:mindplot.Command,
|
||||
initialize: function(topicId, text) {
|
||||
$assert(topicId, 'topicId can not be null');
|
||||
this._selectedObjectsIds = topicId;
|
||||
this._objectsIds = topicId;
|
||||
this._text = text;
|
||||
this._id = mindplot.Command._nextUUID();
|
||||
},
|
||||
execute: function(commandContext) {
|
||||
var topic = commandContext.findTopics(this._selectedObjectsIds)[0];
|
||||
var topic = commandContext.findTopics(this._objectsIds)[0];
|
||||
var updated = function() {
|
||||
topic.addNote(this._text, commandContext._designer);
|
||||
topic.updateNode();
|
||||
@@ -33,7 +33,7 @@ mindplot.commands.AddNoteToTopicCommand = new Class({
|
||||
updated.delay(0);
|
||||
},
|
||||
undoExecute: function(commandContext) {
|
||||
var topic = commandContext.findTopics(this._selectedObjectsIds)[0];
|
||||
var topic = commandContext.findTopics(this._objectsIds)[0];
|
||||
var updated = function() {
|
||||
topic.removeNote();
|
||||
}.bind(this);
|
||||
|
@@ -16,18 +16,19 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
mindplot.commands.DeleteTopicCommand = new Class({
|
||||
mindplot.commands.DeleteCommand = new Class({
|
||||
Extends:mindplot.Command,
|
||||
initialize: function(topicsIds) {
|
||||
$assert(topicsIds, "topicsIds must be defined");
|
||||
this._selectedObjectsIds = topicsIds;
|
||||
initialize: function(objectIds) {
|
||||
$assert(objectIds, "objectIds must be defined");
|
||||
this._objectsIds = objectIds;
|
||||
this._deletedTopicModels = [];
|
||||
this._parentTopicIds = [];
|
||||
this._deletedRelationships = [];
|
||||
this._id = mindplot.Command._nextUUID();
|
||||
},
|
||||
|
||||
execute: function(commandContext) {
|
||||
var topics = commandContext.findTopics(this._selectedObjectsIds.nodes);
|
||||
var topics = commandContext.findTopics(this._objectsIds.nodes);
|
||||
if (topics.length > 0) {
|
||||
topics.forEach(
|
||||
function(topic, index) {
|
||||
@@ -57,7 +58,7 @@ mindplot.commands.DeleteTopicCommand = new Class({
|
||||
}.bind(this)
|
||||
);
|
||||
}
|
||||
var lines = commandContext.findRelationships(this._selectedObjectsIds.relationshipLines);
|
||||
var lines = commandContext.findRelationships(this._objectsIds.relationship);
|
||||
if (lines.length > 0) {
|
||||
lines.forEach(function(line, index) {
|
||||
if (line.isInWorkspace()) {
|
||||
@@ -69,7 +70,7 @@ mindplot.commands.DeleteTopicCommand = new Class({
|
||||
},
|
||||
undoExecute: function(commandContext) {
|
||||
|
||||
var topics = commandContext.findTopics(this._selectedObjectsIds);
|
||||
var topics = commandContext.findTopics(this._objectsIds);
|
||||
var parent = commandContext.findTopics(this._parentTopicIds);
|
||||
|
||||
this._deletedTopicModels.forEach(
|
@@ -21,7 +21,7 @@ mindplot.commands.DragTopicCommand = new Class({
|
||||
initialize: function(topicIds, position, order, parentTopic) {
|
||||
$assert(topicIds, "topicIds must be defined");
|
||||
|
||||
this._selectedObjectsIds = topicIds;
|
||||
this._objectsIds = topicIds;
|
||||
if ($defined(parentTopic))
|
||||
this._parentId = parentTopic.getId();
|
||||
|
||||
@@ -31,7 +31,7 @@ mindplot.commands.DragTopicCommand = new Class({
|
||||
},
|
||||
execute: function(commandContext) {
|
||||
|
||||
var topic = commandContext.findTopics([this._selectedObjectsIds])[0];
|
||||
var topic = commandContext.findTopics([this._objectsIds])[0];
|
||||
|
||||
// Save old position ...
|
||||
var origParentTopic = topic.getOutgoingConnectedTopic();
|
||||
@@ -80,7 +80,7 @@ mindplot.commands.DragTopicCommand = new Class({
|
||||
},
|
||||
undoExecute: function(commandContext) {
|
||||
this.execute(commandContext);
|
||||
var selectedRelationships = commandContext.getSelectedRelationshipLines();
|
||||
var selectedRelationships = commandContext.filterSelectedRelations();
|
||||
selectedRelationships.forEach(function(relationshipLine) {
|
||||
relationshipLine.redraw();
|
||||
});
|
||||
|
@@ -23,14 +23,14 @@ mindplot.commands.GenericFunctionCommand = new Class({
|
||||
$assert(topicsIds, "topicsIds must be defined");
|
||||
|
||||
this._value = value;
|
||||
this._selectedObjectsIds = topicsIds;
|
||||
this._objectsIds = topicsIds;
|
||||
this._commandFunc = commandFunc;
|
||||
this._oldValues = [];
|
||||
this._id = mindplot.Command._nextUUID();
|
||||
},
|
||||
execute: function(commandContext) {
|
||||
if (!this.applied) {
|
||||
var topics = commandContext.findTopics(this._selectedObjectsIds);
|
||||
var topics = commandContext.findTopics(this._objectsIds);
|
||||
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._selectedObjectsIds);
|
||||
var topics = commandContext.findTopics(this._objectsIds);
|
||||
topics.forEach(function(topic, index) {
|
||||
this._commandFunc(topic, this._oldValues[index]);
|
||||
|
||||
|
@@ -22,12 +22,12 @@ mindplot.commands.RemoveIconFromTopicCommand = new Class({
|
||||
{
|
||||
$assert(topicId, 'topicId can not be null');
|
||||
$assert(iconModel, 'iconId can not be null');
|
||||
this._selectedObjectsIds = topicId;
|
||||
this._objectsIds = topicId;
|
||||
this._iconModel = iconModel;
|
||||
},
|
||||
execute: function(commandContext)
|
||||
{
|
||||
var topic = commandContext.findTopics(this._selectedObjectsIds)[0];
|
||||
var topic = commandContext.findTopics(this._objectsIds)[0];
|
||||
var updated = function() {
|
||||
topic.removeIcon(this._iconModel);
|
||||
topic.updateNode();
|
||||
@@ -36,7 +36,7 @@ mindplot.commands.RemoveIconFromTopicCommand = new Class({
|
||||
},
|
||||
undoExecute: function(commandContext)
|
||||
{
|
||||
var topic = commandContext.findTopics(this._selectedObjectsIds)[0];
|
||||
var topic = commandContext.findTopics(this._objectsIds)[0];
|
||||
var updated = function() {
|
||||
var iconType = this._iconModel.getIconType();
|
||||
var iconImg = topic.addIcon(iconType, commandContext._designer);
|
||||
|
@@ -20,10 +20,10 @@ mindplot.commands.RemoveLinkFromTopicCommand = new Class({
|
||||
Extends:mindplot.Command,
|
||||
initialize: function(topicId) {
|
||||
$assert(topicId, 'topicId can not be null');
|
||||
this._selectedObjectsIds = topicId;
|
||||
this._objectsIds = topicId;
|
||||
},
|
||||
execute: function(commandContext) {
|
||||
var topic = commandContext.findTopics(this._selectedObjectsIds)[0];
|
||||
var topic = commandContext.findTopics(this._objectsIds)[0];
|
||||
this._url = topic._link.getUrl();
|
||||
var updated = function() {
|
||||
topic.removeLink();
|
||||
@@ -31,7 +31,7 @@ mindplot.commands.RemoveLinkFromTopicCommand = new Class({
|
||||
updated.delay(0);
|
||||
},
|
||||
undoExecute: function(commandContext) {
|
||||
var topic = commandContext.findTopics(this._selectedObjectsIds)[0];
|
||||
var topic = commandContext.findTopics(this._objectsIds)[0];
|
||||
var updated = function() {
|
||||
topic.addLink(this._url, commandContext._designer);
|
||||
topic.updateNode();
|
||||
|
@@ -21,11 +21,11 @@ mindplot.commands.RemoveNoteFromTopicCommand = new Class({
|
||||
initialize: function(topicId)
|
||||
{
|
||||
$assert(topicId, 'topicId can not be null');
|
||||
this._selectedObjectsIds = topicId;
|
||||
this._objectsIds = topicId;
|
||||
},
|
||||
execute: function(commandContext)
|
||||
{
|
||||
var topic = commandContext.findTopics(this._selectedObjectsIds)[0];
|
||||
var topic = commandContext.findTopics(this._objectsIds)[0];
|
||||
this._text = topic._note.getText();
|
||||
var updated = function() {
|
||||
topic.removeNote();
|
||||
@@ -34,7 +34,7 @@ mindplot.commands.RemoveNoteFromTopicCommand = new Class({
|
||||
},
|
||||
undoExecute: function(commandContext)
|
||||
{
|
||||
var topic = commandContext.findTopics(this._selectedObjectsIds)[0];
|
||||
var topic = commandContext.findTopics(this._objectsIds)[0];
|
||||
var updated = function() {
|
||||
topic.addNote(this._text,commandContext._designer);
|
||||
topic.updateNode();
|
||||
|
Reference in New Issue
Block a user