Add migrator for Pela to Tango

This commit is contained in:
Paulo Veiga 2012-01-21 18:02:38 -03:00
parent 7ec7c18524
commit 0e07e28b4c
9 changed files with 66 additions and 55 deletions

View File

@ -95,6 +95,8 @@
files="XMLMindmapSerializer_Pela.js"/> files="XMLMindmapSerializer_Pela.js"/>
<filelist dir="${basedir}/src/main/javascript/" <filelist dir="${basedir}/src/main/javascript/"
files="XMLMindmapSerializer_Tango.js"/> files="XMLMindmapSerializer_Tango.js"/>
<filelist dir="${basedir}/src/main/javascript/"
files="Pela2TangoMigrator.js"/>
<filelist dir="${basedir}/src/main/javascript/" <filelist dir="${basedir}/src/main/javascript/"
files="XMLMindmapSerializer_Beta.js"/> files="XMLMindmapSerializer_Beta.js"/>
<filelist dir="${basedir}/src/main/javascript/" files="Beta2PelaMigrator.js"/> <filelist dir="${basedir}/src/main/javascript/" files="Beta2PelaMigrator.js"/>

View File

@ -330,7 +330,6 @@ mindplot.Designer = new Class({
var layoutManager = this._eventBussDispatcher.getLayoutManager(); var layoutManager = this._eventBussDispatcher.getLayoutManager();
var result = layoutManager.predict(topic.getId(), mousePos); var result = layoutManager.predict(topic.getId(), mousePos);
childModel.setOrder(result.order); childModel.setOrder(result.order);
console.log(result.order);
var position = result.position; var position = result.position;
childModel.setPosition(position.x, position.y); childModel.setPosition(position.x, position.y);
@ -420,6 +419,18 @@ mindplot.Designer = new Class({
$assert(mindmapModel, "mindmapModel can not be null"); $assert(mindmapModel, "mindmapModel can not be null");
this._mindmap = mindmapModel; this._mindmap = mindmapModel;
// Init layout manager ...
var size = {width:25,height:25};
var layoutManager = new mindplot.layout.LayoutManager(mindmapModel.getCentralTopic().getId(), size);
layoutManager.addEvent('change', function(event) {
var id = event.getId();
var topic = this.getModel().findTopicById(id);
topic.setPosition(event.getPosition());
topic.setOrder(event.getOrder());
}.bind(this));
this._eventBussDispatcher.setLayoutManager(layoutManager);
// Building node graph ... // Building node graph ...
var branches = mindmapModel.getBranches(); var branches = mindmapModel.getBranches();
for (var i = 0; i < branches.length; i++) { for (var i = 0; i < branches.length; i++) {

View File

@ -29,9 +29,38 @@ mindplot.Pela2TangoMigrator = new Class({
$assert($defined(mapId), "mapId can not be null"); $assert($defined(mapId), "mapId can not be null");
var mindmap = this._pelaSerializer.loadFromDom(dom, mapId); var mindmap = this._pelaSerializer.loadFromDom(dom, mapId);
mindmap.setVersion(mindplot.ModelCodeName.TANGO); mindmap.setVersion(mindplot.ModelCodeName.TANGO);
this._fixOrder(mindmap);
// @todo: Cocinar los ordenes ....
return mindmap; return mindmap;
},
_fixOrder : function(mindmap) {
// First level node policies has been changed.
var centralNode = mindmap.getBranches()[0];
var children = centralNode.getChildren();
var leftNodes = [];
var rightNodes = [];
for (var i = 0; i < children.length; i++) {
var child = children[i];
var position = child.getPosition();
if (position.x < 0) {
leftNodes.push(child);
} else {
rightNodes.push(child);
}
}
rightNodes.sort(function(a, b) {
return a.getOrder() > b.getOrder()
});
leftNodes.sort(function(a, b) {
return a.getOrder() > b.getOrder();
});
for (i = 0; i < rightNodes.length; i++) {
rightNodes[i].setOrder(i*2);
}
for (i = 0; i < leftNodes.length; i++) {
leftNodes[i].setOrder(i*2+1);
}
} }
}); });

View File

@ -194,11 +194,11 @@ mindplot.Topic = new Class({
}; };
var setStrokeFunction = result.setStroke; var setStrokeFunction = result.setStroke;
result.setFill = function(color) { result.setFill = function() {
}; };
result.setStroke = function(color) { result.setStroke = function() {
}; };
} }
@ -1091,7 +1091,7 @@ mindplot.Topic = new Class({
var size = this.getFontSize(); var size = this.getFontSize();
this.setFontSize(size, false); this.setFontSize(size, false);
} }
var textShape = this.getTextShape(); this.getTextShape();
// Display connection node... // Display connection node...
var connector = targetTopic.getShrinkConnector(); var connector = targetTopic.getShrinkConnector();
@ -1141,7 +1141,9 @@ mindplot.Topic = new Class({
var elem = this.get2DElement(); var elem = this.get2DElement();
workspace.appendChild(elem); workspace.appendChild(elem);
if (!this.isInWorkspace()) { if (!this.isInWorkspace()) {
if (this.getType() != mindplot.model.INodeModel.CENTRAL_TOPIC_TYPE) {
mindplot.EventBus.instance.fireEvent(mindplot.EventBus.events.NodeAdded, this.getModel()); mindplot.EventBus.instance.fireEvent(mindplot.EventBus.events.NodeAdded, this.getModel());
}
if (this.getModel().isConnected()) if (this.getModel().isConnected())
mindplot.EventBus.instance.fireEvent(mindplot.EventBus.events.NodeConnectEvent, {parentNode:this.getOutgoingConnectedTopic().getModel(), childNode: this.getModel()}); mindplot.EventBus.instance.fireEvent(mindplot.EventBus.events.NodeConnectEvent, {parentNode:this.getOutgoingConnectedTopic().getModel(), childNode: this.getModel()});

View File

@ -17,19 +17,12 @@
*/ */
mindplot.layout.EventBusDispatcher = new Class({ mindplot.layout.EventBusDispatcher = new Class({
initialize:function(designerModel) { initialize:function() {
$assert(designerModel, "designerModel cannot be null");
this.registerBusEvents(); this.registerBusEvents();
},
var size = {width:25,height:25}; setLayoutManager : function(layoutManager) {
this._layoutManager = new mindplot.layout.LayoutManager(0, size); this._layoutManager = layoutManager;
this._layoutManager.addEvent('change', function(event) {
var id = event.getId();
var topic = designerModel.findTopicById(id);
topic.setPosition(event.getPosition());
topic.setOrder(event.getOrder());
});
}, },
registerBusEvents:function () { registerBusEvents:function () {

View File

@ -25,7 +25,7 @@
$(document).fireEvent('loadcomplete', 'brix'); $(document).fireEvent('loadcomplete', 'brix');
}; };
var mapId = 'mapId'; // @todo: Must be changed ... var mapId = 'welcome'; // @todo: Must be changed ...
var brixReady = false; var brixReady = false;
var mindReady = false; var mindReady = false;
var collab = 'standalone'; var collab = 'standalone';
@ -59,12 +59,12 @@
// Load map from XML ... // Load map from XML ...
var persitence = mindplot.PersitenceManager.getInstance(); var persitence = mindplot.PersitenceManager.getInstance();
var mindmap; var mindmap;
try { // try {
mindmap = persitence.load(mapId); mindmap = persitence.load(mapId);
} catch(e) { // } catch(e) {
// If the map could not be loaded, create a new empty map... // // If the map could not be loaded, create a new empty map...
mindmap = mindplot.model.Mindmap.buildEmpty(mapId); // mindmap = mindplot.model.Mindmap.buildEmpty(mapId);
} // }
designer.loadMap(mindmap); designer.loadMap(mindmap);

View File

@ -1,26 +0,0 @@
<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>

View File

@ -33,7 +33,7 @@
<topic position="266,0" order="0" text="Try it Now!" id="11" fontStyle=";;#ffffff;;;" bgColor="#250be3" <topic position="266,0" order="0" text="Try it Now!" id="11" fontStyle=";;#ffffff;;;" bgColor="#250be3"
brColor="#080559"> brColor="#080559">
<topic position="358,-33" order="0" text="Double Click" id="12" fontStyle=";;#001be6;;italic;"/> <topic position="358,-33" order="0" text="Double Click" id="12" fontStyle=";;#001be6;;italic;"/>
<topic position="362,-9" order="1" text="" INS" to insert" id="13" fontStyle=";;#001be6;;italic;"/> <topic position="362,-9" order="1" text=" INS to insert" id="13" fontStyle=";;#001be6;;italic;"/>
<topic position="371,15" order="2" text="Drag map to move" id="14" fontStyle=";;#001be6;;italic;"/> <topic position="371,15" order="2" text="Drag map to move" id="14" fontStyle=";;#001be6;;italic;"/>
</topic> </topic>
<topic position="299,-100" order="3" text="Mind Mapping" id="6" fontStyle=";;#602378;;;" bgColor="#edabff"> <topic position="299,-100" order="3" text="Mind Mapping" id="6" fontStyle=";;#602378;;;" bgColor="#edabff">