From dfc3bbdbe6d4d6e9ba5dc6b2f8cbac4c3918d841 Mon Sep 17 00:00:00 2001 From: Paulo Veiga Date: Wed, 30 Nov 2011 00:56:21 -0300 Subject: [PATCH 1/3] - Fix errors on actions over central topic. --- .../src/main/javascript/commands/AddIconToTopicCommand.js | 6 +++--- .../main/javascript/commands/ChangeLinkToTopicCommand.js | 6 +++--- .../main/javascript/commands/ChangeNoteToTopicCommand.js | 6 +++--- mindplot/src/main/javascript/commands/DeleteCommand.js | 2 ++ mindplot/src/main/javascript/commands/DragTopicCommand.js | 4 ++-- .../main/javascript/commands/GenericFunctionCommand.js | 6 +++--- .../javascript/commands/RemoveIconFromTopicCommand.js | 8 ++++---- .../javascript/commands/RemoveLinkFromTopicCommand.js | 8 ++++---- .../javascript/commands/RemoveNoteFromTopicCommand.js | 8 ++++---- 9 files changed, 28 insertions(+), 26 deletions(-) diff --git a/mindplot/src/main/javascript/commands/AddIconToTopicCommand.js b/mindplot/src/main/javascript/commands/AddIconToTopicCommand.js index 2b3a556d..e764cee4 100644 --- a/mindplot/src/main/javascript/commands/AddIconToTopicCommand.js +++ b/mindplot/src/main/javascript/commands/AddIconToTopicCommand.js @@ -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); } }); \ No newline at end of file diff --git a/mindplot/src/main/javascript/commands/ChangeLinkToTopicCommand.js b/mindplot/src/main/javascript/commands/ChangeLinkToTopicCommand.js index 1d1314f4..ef259057 100644 --- a/mindplot/src/main/javascript/commands/ChangeLinkToTopicCommand.js +++ b/mindplot/src/main/javascript/commands/ChangeLinkToTopicCommand.js @@ -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); diff --git a/mindplot/src/main/javascript/commands/ChangeNoteToTopicCommand.js b/mindplot/src/main/javascript/commands/ChangeNoteToTopicCommand.js index d556a529..6c3ad86c 100644 --- a/mindplot/src/main/javascript/commands/ChangeNoteToTopicCommand.js +++ b/mindplot/src/main/javascript/commands/ChangeNoteToTopicCommand.js @@ -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); diff --git a/mindplot/src/main/javascript/commands/DeleteCommand.js b/mindplot/src/main/javascript/commands/DeleteCommand.js index f6af98ec..650168f6 100644 --- a/mindplot/src/main/javascript/commands/DeleteCommand.js +++ b/mindplot/src/main/javascript/commands/DeleteCommand.js @@ -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 = []; diff --git a/mindplot/src/main/javascript/commands/DragTopicCommand.js b/mindplot/src/main/javascript/commands/DragTopicCommand.js index e8aee711..95fde129 100644 --- a/mindplot/src/main/javascript/commands/DragTopicCommand.js +++ b/mindplot/src/main/javascript/commands/DragTopicCommand.js @@ -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(); diff --git a/mindplot/src/main/javascript/commands/GenericFunctionCommand.js b/mindplot/src/main/javascript/commands/GenericFunctionCommand.js index 0dc6f896..b2552103 100644 --- a/mindplot/src/main/javascript/commands/GenericFunctionCommand.js +++ b/mindplot/src/main/javascript/commands/GenericFunctionCommand.js @@ -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]); diff --git a/mindplot/src/main/javascript/commands/RemoveIconFromTopicCommand.js b/mindplot/src/main/javascript/commands/RemoveIconFromTopicCommand.js index 03cd05e5..32717760 100644 --- a/mindplot/src/main/javascript/commands/RemoveIconFromTopicCommand.js +++ b/mindplot/src/main/javascript/commands/RemoveIconFromTopicCommand.js @@ -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(); diff --git a/mindplot/src/main/javascript/commands/RemoveLinkFromTopicCommand.js b/mindplot/src/main/javascript/commands/RemoveLinkFromTopicCommand.js index bb759485..3800c91b 100644 --- a/mindplot/src/main/javascript/commands/RemoveLinkFromTopicCommand.js +++ b/mindplot/src/main/javascript/commands/RemoveLinkFromTopicCommand.js @@ -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); } }); \ No newline at end of file diff --git a/mindplot/src/main/javascript/commands/RemoveNoteFromTopicCommand.js b/mindplot/src/main/javascript/commands/RemoveNoteFromTopicCommand.js index 7c042845..230e191d 100644 --- a/mindplot/src/main/javascript/commands/RemoveNoteFromTopicCommand.js +++ b/mindplot/src/main/javascript/commands/RemoveNoteFromTopicCommand.js @@ -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); } }); \ No newline at end of file From 4d3baac09d9c465823f32fc1235c144373af1c6c Mon Sep 17 00:00:00 2001 From: Paulo Veiga Date: Wed, 30 Nov 2011 00:59:36 -0300 Subject: [PATCH 2/3] - Fix actions over the central topic. --- .../src/main/javascript/commands/ChangeLinkToTopicCommand.js | 2 +- .../src/main/javascript/commands/ChangeNoteToTopicCommand.js | 4 ++-- .../src/main/javascript/commands/GenericFunctionCommand.js | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/mindplot/src/main/javascript/commands/ChangeLinkToTopicCommand.js b/mindplot/src/main/javascript/commands/ChangeLinkToTopicCommand.js index ef259057..3578b12d 100644 --- a/mindplot/src/main/javascript/commands/ChangeLinkToTopicCommand.js +++ b/mindplot/src/main/javascript/commands/ChangeLinkToTopicCommand.js @@ -19,7 +19,7 @@ mindplot.commands.ChangeLinkToTopicCommand = new Class({ Extends:mindplot.Command, initialize: function(topicId, url) { - $assert(topicId, 'topicId can not be null'); + $assert($defined(topicId), 'topicId can not be null'); this._topicsIds = topicId; this._url = url; this._id = mindplot.Command._nextUUID(); diff --git a/mindplot/src/main/javascript/commands/ChangeNoteToTopicCommand.js b/mindplot/src/main/javascript/commands/ChangeNoteToTopicCommand.js index 6c3ad86c..117d97c7 100644 --- a/mindplot/src/main/javascript/commands/ChangeNoteToTopicCommand.js +++ b/mindplot/src/main/javascript/commands/ChangeNoteToTopicCommand.js @@ -19,14 +19,14 @@ mindplot.commands.ChangeNoteToTopicCommand = new Class({ Extends:mindplot.Command, initialize: function(topicId, text) { - $assert(topicId, 'topicId can not be null'); + $assert($defined(topicId), 'topicId can not be null'); this._topicsIds = topicId; this._text = text; this._oldtext = null; this._id = mindplot.Command._nextUUID(); }, - execute: function(commandContext) { + execute: function(commandContext) { var topic = commandContext.findTopics(this._topicsIds)[0]; if (topic.hasNote()) { var model = topic.getModel(); diff --git a/mindplot/src/main/javascript/commands/GenericFunctionCommand.js b/mindplot/src/main/javascript/commands/GenericFunctionCommand.js index b2552103..00d9f576 100644 --- a/mindplot/src/main/javascript/commands/GenericFunctionCommand.js +++ b/mindplot/src/main/javascript/commands/GenericFunctionCommand.js @@ -20,7 +20,7 @@ mindplot.commands.GenericFunctionCommand = new Class({ Extends:mindplot.Command, initialize: function(commandFunc, topicsIds,value) { $assert(commandFunc, "commandFunc must be defined"); - $assert(topicsIds, "topicsIds must be defined"); + $assert($defined(topicsIds), "topicsIds must be defined"); this._value = value; this._topicsIds = topicsIds; From d62d4af76691c791125568914c24a7f5e43367c7 Mon Sep 17 00:00:00 2001 From: Paulo Veiga Date: Thu, 1 Dec 2011 18:07:19 -0300 Subject: [PATCH 3/3] Move layout files in order to reflethe final layout structure. --- mindplot/pom.xml | 32 ++++++++++++------- mindplot/src/main/javascript/MainTopic.js | 4 ++- mindplot/src/main/javascript/Topic.js | 3 ++ mindplot/src/main/javascript/header.js | 2 ++ .../javascript/layout/BaseLayoutManager.js | 18 +++++++++++ .../layout/FreeMindLayoutManager.js | 18 +++++++++++ .../javascript/layout/LayoutManagerFactory.js | 18 +++++++++++ .../layout/OriginalLayoutManager.js | 4 +-- .../main/javascript/layout/boards/Board.js | 2 -- .../{ => layout/boards/original}/Board.js | 6 ++-- .../boards/original}/BoardEntry.js | 2 +- .../boards/original}/CentralTopicBoard.js | 8 ++--- .../boards/original}/FixedDistanceBoard.js | 26 ++++++++------- .../boards/original}/MainTopicBoard.js | 10 +++--- .../boards/original}/VariableDistanceBoard.js | 6 ++-- 15 files changed, 113 insertions(+), 46 deletions(-) rename mindplot/src/main/javascript/{ => layout/boards/original}/Board.js (91%) rename mindplot/src/main/javascript/{ => layout/boards/original}/BoardEntry.js (95%) rename mindplot/src/main/javascript/{ => layout/boards/original}/CentralTopicBoard.js (89%) rename mindplot/src/main/javascript/{ => layout/boards/original}/FixedDistanceBoard.js (91%) rename mindplot/src/main/javascript/{ => layout/boards/original}/MainTopicBoard.js (91%) rename mindplot/src/main/javascript/{ => layout/boards/original}/VariableDistanceBoard.js (94%) diff --git a/mindplot/pom.xml b/mindplot/pom.xml index f976cda6..7a992c0e 100644 --- a/mindplot/pom.xml +++ b/mindplot/pom.xml @@ -84,9 +84,18 @@ - - - + + + + + + + @@ -94,10 +103,9 @@ - - - + @@ -152,21 +160,21 @@ - + - + - + - + - + - + = 0) { // It's at right. - result = topicPosition.x + halfTargetWidth + mindplot.FixedDistanceBoard.MAIN_TOPIC_TO_MAIN_TOPIC_DISTANCE; + result = topicPosition.x + halfTargetWidth + mindplot.layout.boards.original.FixedDistanceBoard.MAIN_TOPIC_TO_MAIN_TOPIC_DISTANCE; } else { - result = topicPosition.x - (halfTargetWidth + mindplot.FixedDistanceBoard.MAIN_TOPIC_TO_MAIN_TOPIC_DISTANCE); + result = topicPosition.x - (halfTargetWidth + mindplot.layout.boards.original.FixedDistanceBoard.MAIN_TOPIC_TO_MAIN_TOPIC_DISTANCE); } return result; }, @@ -140,13 +140,13 @@ mindplot.FixedDistanceBoard = new Class({ var topicBoardHeight = topicBoard.getHeight(); - height += topicBoardHeight + mindplot.FixedDistanceBoard.INTER_TOPIC_DISTANCE; + height += topicBoardHeight + mindplot.layout.boards.original.FixedDistanceBoard.INTER_TOPIC_DISTANCE; } } } else { var topic = this._topic; - height = topic.getSize().height + mindplot.FixedDistanceBoard.INTER_TOPIC_DISTANCE; + height = topic.getSize().height + mindplot.layout.boards.original.FixedDistanceBoard.INTER_TOPIC_DISTANCE; } var oldHeight = this._height; @@ -193,7 +193,7 @@ mindplot.FixedDistanceBoard = new Class({ var topicBoard = this._layoutManager.getTopicBoardForTopic(currentTopic); var topicBoardHeight = topicBoard.getHeight(); - upperLimit = lowerLimit + topicBoardHeight + mindplot.FixedDistanceBoard.INTER_TOPIC_DISTANCE; + upperLimit = lowerLimit + topicBoardHeight + mindplot.layout.boards.original.FixedDistanceBoard.INTER_TOPIC_DISTANCE; e.setUpperLimit(upperLimit); lowerLimit = upperLimit; @@ -277,8 +277,10 @@ mindplot.FixedDistanceBoard = new Class({ return result; } -}) - ; -mindplot.FixedDistanceBoard.INTER_TOPIC_DISTANCE = 6; -mindplot.FixedDistanceBoard.MAIN_TOPIC_TO_MAIN_TOPIC_DISTANCE = 60; +}); + +mindplot.layout.boards.original.FixedDistanceBoard.MAIN_TOPIC_TO_MAIN_TOPIC_DISTANCE = 60; +mindplot.layout.boards.original.FixedDistanceBoard.INTER_TOPIC_DISTANCE = 6; + + diff --git a/mindplot/src/main/javascript/MainTopicBoard.js b/mindplot/src/main/javascript/layout/boards/original/MainTopicBoard.js similarity index 91% rename from mindplot/src/main/javascript/MainTopicBoard.js rename to mindplot/src/main/javascript/layout/boards/original/MainTopicBoard.js index 368cafc8..0a529ce0 100644 --- a/mindplot/src/main/javascript/MainTopicBoard.js +++ b/mindplot/src/main/javascript/layout/boards/original/MainTopicBoard.js @@ -16,8 +16,8 @@ * limitations under the License. */ -mindplot.MainTopicBoard = new Class({ - Extends:mindplot.Board, +mindplot.layout.boards.original.MainTopicBoard = new Class({ + Extends:mindplot.layout.boards.original.Board, initialize:function(topic, layoutManager) { this._layoutManager = layoutManager; this._topic = topic; @@ -29,7 +29,7 @@ mindplot.MainTopicBoard = new Class({ _getBoard: function() { if (!$defined(this._board)) { var topic = this._topic; - this._board = new mindplot.FixedDistanceBoard(mindplot.MainTopicBoard.DEFAULT_MAIN_TOPIC_HEIGHT, topic, this._layoutManager); + this._board = new mindplot.layout.boards.original.FixedDistanceBoard(mindplot.MainTopic.DEFAULT_MAIN_TOPIC_HEIGHT, topic, this._layoutManager); } return this._board; }, @@ -124,6 +124,4 @@ mindplot.MainTopicBoard = new Class({ mindplot.EventBus.instance.fireEvent(mindplot.EventBus.events.NodeRepositionateEvent, [connectedTopic]); } } -}); - -mindplot.MainTopicBoard.DEFAULT_MAIN_TOPIC_HEIGHT = 18; +}); \ No newline at end of file diff --git a/mindplot/src/main/javascript/VariableDistanceBoard.js b/mindplot/src/main/javascript/layout/boards/original/VariableDistanceBoard.js similarity index 94% rename from mindplot/src/main/javascript/VariableDistanceBoard.js rename to mindplot/src/main/javascript/layout/boards/original/VariableDistanceBoard.js index b3b5b099..418e1de2 100644 --- a/mindplot/src/main/javascript/VariableDistanceBoard.js +++ b/mindplot/src/main/javascript/layout/boards/original/VariableDistanceBoard.js @@ -16,8 +16,8 @@ * limitations under the License. */ -mindplot.VariableDistanceBoard = new Class({ - Extends: mindplot.Board, +mindplot.layout.boards.original.VariableDistanceBoard = new Class({ + Extends: mindplot.layout.boards.original.Board, initialize: function(defaultHeight, referencePoint) { this.parent(defaultHeight, referencePoint); var zeroEntryCoordinate = referencePoint.y; @@ -66,7 +66,7 @@ mindplot.VariableDistanceBoard = new Class({ }, createBoardEntry:function(lowerLimit, upperLimit, order) { - return new mindplot.BoardEntry(lowerLimit, upperLimit, order); + return new mindplot.layout.boards.original.BoardEntry(lowerLimit, upperLimit, order); }, updateReferencePoint:function(position) {