From 1b3ad1b42d580214907b1147faab96ec712474e0 Mon Sep 17 00:00:00 2001 From: Paulo Veiga <paulo.veiga@oracle.com> Date: Sat, 14 Jan 2012 10:45:39 -0300 Subject: [PATCH] Add new Tango serializer. Pending to comple migration. --- mindplot/pom.xml | 2 + mindplot/src/main/javascript/Designer.js | 6 +- mindplot/src/main/javascript/ModelCodeName.js | 3 +- .../src/main/javascript/Pela2TangoMigrator.js | 37 +++++++++++ .../javascript/StandaloneActionDispatcher.js | 1 - mindplot/src/main/javascript/Topic.js | 62 ++++--------------- .../javascript/XMLMindmapSerializerFactory.js | 7 ++- .../javascript/XMLMindmapSerializer_Beta.js | 1 + .../javascript/XMLMindmapSerializer_Tango.js | 21 +++++++ .../javascript/commands/DragTopicCommand.js | 7 --- mindplot/src/main/javascript/model/Mindmap.js | 2 +- wise-doc/src/main/webapp/maps/pepe.xml | 26 ++++++++ 12 files changed, 110 insertions(+), 65 deletions(-) create mode 100644 mindplot/src/main/javascript/Pela2TangoMigrator.js create mode 100644 mindplot/src/main/javascript/XMLMindmapSerializer_Tango.js create mode 100644 wise-doc/src/main/webapp/maps/pepe.xml diff --git a/mindplot/pom.xml b/mindplot/pom.xml index 95403a38..c8c9a490 100644 --- a/mindplot/pom.xml +++ b/mindplot/pom.xml @@ -107,6 +107,8 @@ <filelist dir="${basedir}/src/main/javascript/" files="ModelCodeName.js"/> <filelist dir="${basedir}/src/main/javascript/" files="XMLMindmapSerializer_Pela.js"/> + <filelist dir="${basedir}/src/main/javascript/" + files="XMLMindmapSerializer_Tango.js"/> <filelist dir="${basedir}/src/main/javascript/" files="XMLMindmapSerializer_Beta.js"/> <filelist dir="${basedir}/src/main/javascript/" files="Beta2PelaMigrator.js"/> diff --git a/mindplot/src/main/javascript/Designer.js b/mindplot/src/main/javascript/Designer.js index 6d9455f1..61611999 100644 --- a/mindplot/src/main/javascript/Designer.js +++ b/mindplot/src/main/javascript/Designer.js @@ -443,9 +443,6 @@ mindplot.Designer = new Class({ var nodeModel = branches[i]; var nodeGraph = this._nodeModelToNodeGraph(nodeModel, false); - // Now, refresh UI changes ... - nodeGraph.enableUICache(false); - // Update shrink render state... nodeGraph.setBranchVisibility(true); } @@ -480,6 +477,9 @@ mindplot.Designer = new Class({ _nodeModelToNodeGraph : function(nodeModel, isVisible) { $assert(nodeModel, "Node model can not be null"); var children = nodeModel.getChildren().slice(); + children = children.sort(function(a, b) { + return a.getOrder() - b.getOrder() + }); var nodeGraph = this._buildNodeGraph(nodeModel); diff --git a/mindplot/src/main/javascript/ModelCodeName.js b/mindplot/src/main/javascript/ModelCodeName.js index edc66ea9..4b201a75 100644 --- a/mindplot/src/main/javascript/ModelCodeName.js +++ b/mindplot/src/main/javascript/ModelCodeName.js @@ -17,5 +17,6 @@ */ mindplot.ModelCodeName = { BETA : "beta", - PELA : "pela" + PELA : "pela", + TANGO : "tango" }; \ No newline at end of file diff --git a/mindplot/src/main/javascript/Pela2TangoMigrator.js b/mindplot/src/main/javascript/Pela2TangoMigrator.js new file mode 100644 index 00000000..fe7fc04a --- /dev/null +++ b/mindplot/src/main/javascript/Pela2TangoMigrator.js @@ -0,0 +1,37 @@ +/* + * Copyright [2011] [wisemapping] + * + * Licensed under WiseMapping Public License, Version 1.0 (the "License"). + * It is basically the Apache License, Version 2.0 (the "License") plus the + * "powered by wisemapping" text requirement on every single page; + * you may not use this file except in compliance with the License. + * You may obtain a copy of the license at + * + * http://www.wisemapping.org/license + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +mindplot.Pela2TangoMigrator = new Class({ + initialize : function(pelaSerializer) { + this._pelaSerializer = pelaSerializer; + this._tangoSerializer = new mindplot.XMLMindmapSerializer_Tango(); + }, + + toXML : function(mindmap) { + return this._tangoSerializer.toXML(mindmap); + }, + + loadFromDom : function(dom, mapId) { + $assert($defined(mapId), "mapId can not be null"); + var mindmap = this._pelaSerializer.loadFromDom(dom, mapId); + mindmap.setVersion(mindplot.ModelCodeName.TANGO); + + // @todo: Cocinar los ordenes .... + + return mindmap; + } +}); diff --git a/mindplot/src/main/javascript/StandaloneActionDispatcher.js b/mindplot/src/main/javascript/StandaloneActionDispatcher.js index a70318ef..4efcc00f 100644 --- a/mindplot/src/main/javascript/StandaloneActionDispatcher.js +++ b/mindplot/src/main/javascript/StandaloneActionDispatcher.js @@ -260,7 +260,6 @@ mindplot.CommandContext = new Class({ createTopic:function(model, isVisible) { $assert(model, "model can not be null"); var result = this._designer._nodeModelToNodeGraph(model, isVisible); - result.enableUICache(false); return result; }, diff --git a/mindplot/src/main/javascript/Topic.js b/mindplot/src/main/javascript/Topic.js index 93718ac1..8862a487 100644 --- a/mindplot/src/main/javascript/Topic.js +++ b/mindplot/src/main/javascript/Topic.js @@ -41,38 +41,9 @@ mindplot.Topic = new Class({ this._registerEvents(); } - - this._cacheUIEnabled = true; - this._iuCache = {}; }, - isUICacheEnabled : function() { - return this._cacheUIEnabled; - }, - - enableUICache : function(value) { - this._cacheUIEnabled = value; - if (!value) { - this._flushUIUpdate(); - } - - // Propagate the change to the children nodes ... - var children = this._getChildren(); - for (var i = 0; i < children.length; i++) { - var node = children[i]; - node.enableUICache(value); - } - }, - - _flushUIUpdate: function() { - var position = this._iuCache['position']; - if (position) { - this.setPosition(position); - } - this._iuCache = {}; - }, - _registerEvents : function() { this.setMouseEventsEnabled(true); @@ -829,32 +800,21 @@ mindplot.Topic = new Class({ var currentPos = model.getPosition(); model.setPosition(point.x, point.y); - if (!this.isUICacheEnabled()) { - // Elements are positioned in the center. - // All topic element must be positioned based on the innerShape. - var size = this.getSize(); + // Elements are positioned in the center. + // All topic element must be positioned based on the innerShape. + var size = this.getSize(); - var cx = Math.round(point.x - (size.width / 2)); - var cy = Math.round(point.y - (size.height / 2)); + var cx = Math.round(point.x - (size.width / 2)); + var cy = Math.round(point.y - (size.height / 2)); - // Update visual position. - this._elem2d.setPosition(cx, cy); + // Update visual position. + this._elem2d.setPosition(cx, cy); - // Update connection lines ... - this._updateConnectionLines(); + // Update connection lines ... + this._updateConnectionLines(); - // Check object state. - this.invariant(); - - } else { - this._iuCache['position'] = point; - } - - if (!$defined(currentPos) || parseInt(currentPos.x) != parseInt(point.x) || parseInt(currentPos.y) != parseInt(point.y)) { - - // Fire Listener events ... - mindplot.EventBus.instance.fireEvent(mindplot.EventBus.events.NodeMoveEvent, [this]); - } + // Check object state. + this.invariant(); }, getOutgoingLine : function() { diff --git a/mindplot/src/main/javascript/XMLMindmapSerializerFactory.js b/mindplot/src/main/javascript/XMLMindmapSerializerFactory.js index 6a891ce1..7fa666f5 100644 --- a/mindplot/src/main/javascript/XMLMindmapSerializerFactory.js +++ b/mindplot/src/main/javascript/XMLMindmapSerializerFactory.js @@ -53,12 +53,17 @@ mindplot.XMLMindmapSerializerFactory._codeNames = { codeName:mindplot.ModelCodeName.BETA, serializer: mindplot.XMLMindmapSerializer_Beta, - migrator:function() {//todo:error + migrator:function() { } }, { codeName:mindplot.ModelCodeName.PELA, serializer:mindplot.XMLMindmapSerializer_Pela, migrator:mindplot.Beta2PelaMigrator + }, + { + codeName:mindplot.ModelCodeName.TANGO, + serializer:mindplot.XMLMindmapSerializer_Tango, + migrator:mindplot.Pela2TangoMigrator } ]; \ No newline at end of file diff --git a/mindplot/src/main/javascript/XMLMindmapSerializer_Beta.js b/mindplot/src/main/javascript/XMLMindmapSerializer_Beta.js index 117dd746..c0e27aca 100644 --- a/mindplot/src/main/javascript/XMLMindmapSerializer_Beta.js +++ b/mindplot/src/main/javascript/XMLMindmapSerializer_Beta.js @@ -168,6 +168,7 @@ mindplot.XMLMindmapSerializer_Beta = new Class({ // Start the loading process ... var version = rootElem.getAttribute("version"); + version = !$defined(version) ? mindplot.ModelCodeName.BETA : version; var mindmap = new mindplot.model.Mindmap(mapId, version); var children = rootElem.childNodes; diff --git a/mindplot/src/main/javascript/XMLMindmapSerializer_Tango.js b/mindplot/src/main/javascript/XMLMindmapSerializer_Tango.js new file mode 100644 index 00000000..64d73f99 --- /dev/null +++ b/mindplot/src/main/javascript/XMLMindmapSerializer_Tango.js @@ -0,0 +1,21 @@ +/* + * Copyright [2011] [wisemapping] + * + * Licensed under WiseMapping Public License, Version 1.0 (the "License"). + * It is basically the Apache License, Version 2.0 (the "License") plus the + * "powered by wisemapping" text requirement on every single page; + * you may not use this file except in compliance with the License. + * You may obtain a copy of the license at + * + * http://www.wisemapping.org/license + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +mindplot.XMLMindmapSerializer_Tango = new Class({ + Extends: mindplot.XMLMindmapSerializer_Pela +}); diff --git a/mindplot/src/main/javascript/commands/DragTopicCommand.js b/mindplot/src/main/javascript/commands/DragTopicCommand.js index 95fde129..e6d73c7c 100644 --- a/mindplot/src/main/javascript/commands/DragTopicCommand.js +++ b/mindplot/src/main/javascript/commands/DragTopicCommand.js @@ -41,9 +41,6 @@ mindplot.commands.DragTopicCommand = new Class({ // Cache nodes position ... var topics = designer.getModel().getTopics(); - topics.forEach(function(topic) { - topic.enableUICache(true); - }); // In this case, topics are positioned using order ... origOrder = topic.getOrder(); @@ -83,10 +80,6 @@ mindplot.commands.DragTopicCommand = new Class({ this._order = origOrder; this._position = origPosition; - topics.forEach(function(topic) { - topic.enableUICache(false); - }); - }, undoExecute: function(commandContext) { diff --git a/mindplot/src/main/javascript/model/Mindmap.js b/mindplot/src/main/javascript/model/Mindmap.js index 60f200d1..02c6ca86 100644 --- a/mindplot/src/main/javascript/model/Mindmap.js +++ b/mindplot/src/main/javascript/model/Mindmap.js @@ -22,7 +22,7 @@ mindplot.model.Mindmap = new Class({ this._branches = []; this._description = null; this._relationships = []; - this._version = $defined(version) ? version : 'pela'; + this._version = $defined(version) ? version : mindplot.ModelCodeName.TANGO; this._id = id; }, diff --git a/wise-doc/src/main/webapp/maps/pepe.xml b/wise-doc/src/main/webapp/maps/pepe.xml new file mode 100644 index 00000000..1e7680b4 --- /dev/null +++ b/wise-doc/src/main/webapp/maps/pepe.xml @@ -0,0 +1,26 @@ +<map name="mapId" version="pela"> + <topic central="true" id="0"> + <topic position="127,-163" order="0" id="1"/> + <topic position="-127,-33" order="1" id="2"/> + <topic position="127,-130" order="2" id="3"/> + <topic position="-127,0" order="3" id="4"/> + <topic position="127,94" order="6" id="5"> + <topic position="251,94" order="0" text="ddddddddddddddddddddd" id="8"> + <topic position="364,55" order="0" id="9"/> + <topic position="364,81" order="1" id="10"/> + <topic position="364,107" order="2" id="11"/> + <topic position="364,133" order="3" id="12"/> + </topic> + </topic> + <topic position="-127,33" order="5" id="6"/> + <topic position="127,163" order="8" id="7"/> + <topic position="127,-35" order="4" id="13"> + <topic position="216,-100" order="0" id="14"/> + <topic position="216,-74" order="1" id="15"/> + <topic position="216,3" order="4" id="16"/> + <topic position="216,-48" order="2" id="17"/> + <topic position="216,29" order="5" id="18"/> + <topic position="216,-22" order="3" id="19"/> + </topic> + </topic> +</map> \ No newline at end of file