2011-03-17 16:51:40 +01:00
|
|
|
mindplot.layoutManagers.BaseLayoutManager = new Class({
|
|
|
|
|
|
|
|
options: {
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
initialize: function(designer, options) {
|
|
|
|
this.setOptions(options);
|
2011-04-08 16:31:40 +02:00
|
|
|
this._createBoard();
|
2011-03-17 16:51:40 +01:00
|
|
|
this._designer = designer;
|
2011-03-24 19:00:51 +01:00
|
|
|
mindplot.EventBus.instance.addEvent(mindplot.EventBus.events.NodeResizeEvent,this._nodeResizeEvent.bind(this));
|
|
|
|
mindplot.EventBus.instance.addEvent(mindplot.EventBus.events.NodeMoveEvent,this._nodeMoveEvent.bind(this));
|
|
|
|
mindplot.EventBus.instance.addEvent(mindplot.EventBus.events.NodeDisconnectEvent,this._nodeDisconnectEvent.bind(this));
|
|
|
|
mindplot.EventBus.instance.addEvent(mindplot.EventBus.events.NodeConnectEvent,this._nodeConnectEvent.bind(this));
|
2011-04-12 14:59:03 +02:00
|
|
|
mindplot.EventBus.instance.addEvent(mindplot.EventBus.events.NodeRepositionateEvent,this._nodeRepositionateEvent.bind(this));
|
|
|
|
mindplot.EventBus.instance.addEvent(mindplot.EventBus.events.NodeShrinkEvent,this._nodeShrinkEvent.bind(this));
|
2011-03-17 16:51:40 +01:00
|
|
|
},
|
2011-03-24 19:00:51 +01:00
|
|
|
_nodeResizeEvent:function(node){
|
|
|
|
},
|
|
|
|
_nodeMoveEvent:function(node){
|
2011-04-08 16:31:40 +02:00
|
|
|
var modifiedTopics = [];
|
|
|
|
this.getTopicBoardForTopic(node).updateChildrenPosition(node, modifiedTopics);
|
2011-03-24 19:00:51 +01:00
|
|
|
},
|
|
|
|
_nodeDisconnectEvent:function(targetNode, node){
|
2011-04-08 16:31:40 +02:00
|
|
|
var modifiedTopics = [];
|
|
|
|
this.getTopicBoardForTopic(targetNode).removeTopicFromBoard(node,modifiedTopics);
|
2011-03-24 19:00:51 +01:00
|
|
|
},
|
|
|
|
_nodeConnectEvent:function(targetNode, node){
|
2011-04-08 16:31:40 +02:00
|
|
|
var modifiedTopics = [];
|
|
|
|
this.getTopicBoardForTopic(targetNode).addBranch(node,modifiedTopics);
|
2011-03-24 19:00:51 +01:00
|
|
|
},
|
2011-04-12 14:59:03 +02:00
|
|
|
_nodeRepositionateEvent:function(node){
|
|
|
|
},
|
2011-04-15 12:42:05 +02:00
|
|
|
_nodeShrinkEvent:function(node){
|
2011-03-24 19:00:51 +01:00
|
|
|
},
|
2011-04-08 16:31:40 +02:00
|
|
|
_createBoard:function(){
|
|
|
|
this._boards = new Hash();
|
|
|
|
},
|
2011-03-24 19:00:51 +01:00
|
|
|
getTopicBoardForTopic:function(node){
|
2011-04-08 16:31:40 +02:00
|
|
|
var id = node.getId();
|
2011-03-24 19:00:51 +01:00
|
|
|
var result = this._boards[id];
|
|
|
|
if(!result){
|
2011-04-08 16:31:40 +02:00
|
|
|
result = this._addNode(node);
|
2011-03-24 19:00:51 +01:00
|
|
|
}
|
|
|
|
return result;
|
|
|
|
},
|
2011-04-08 16:31:40 +02:00
|
|
|
_addNode:function(node){
|
2011-03-24 19:00:51 +01:00
|
|
|
var board = null;
|
|
|
|
if (this._isCentralTopic(node))
|
|
|
|
board = this._createCentralTopicBoard(node);
|
|
|
|
else
|
|
|
|
board = this._createMainTopicBoard(node);
|
|
|
|
var id = node.getId();
|
|
|
|
this._boards[id]=board;
|
|
|
|
return board;
|
|
|
|
},
|
|
|
|
_createMainTopicBoard:function(node){
|
|
|
|
return new mindplot.layoutManagers.boards.Board(node, this);
|
|
|
|
},
|
|
|
|
_createCentralTopicBoard:function(node){
|
|
|
|
return new mindplot.layoutManagers.boards.Board(node, this);
|
2011-03-17 16:51:40 +01:00
|
|
|
},
|
2011-04-15 13:59:21 +02:00
|
|
|
prepareNode:function(node, children){
|
2011-04-12 14:59:03 +02:00
|
|
|
|
|
|
|
},
|
|
|
|
addHelpers:function(node){
|
|
|
|
|
|
|
|
},
|
|
|
|
needsPrepositioning:function(){
|
|
|
|
return true;
|
|
|
|
},
|
2011-03-17 16:51:40 +01:00
|
|
|
getDesigner:function(){
|
|
|
|
return this._designer;
|
2011-03-17 17:28:19 +01:00
|
|
|
},
|
2011-03-24 19:00:51 +01:00
|
|
|
_isCentralTopic:function(node){
|
|
|
|
var type = node.getModel().getType();
|
|
|
|
return type == mindplot.NodeModel.CENTRAL_TOPIC_TYPE;
|
|
|
|
},
|
|
|
|
getClassName:function(){
|
2011-03-17 17:28:19 +01:00
|
|
|
return mindplot.layoutManagers.BaseLayoutManager.NAME;
|
2011-03-17 16:51:40 +01:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2011-03-17 17:28:19 +01:00
|
|
|
mindplot.layoutManagers.BaseLayoutManager.NAME ="BaseLayoutManager";
|
|
|
|
|
2011-03-17 16:51:40 +01:00
|
|
|
mindplot.layoutManagers.BaseLayoutManager.implement(new Events);
|
|
|
|
mindplot.layoutManagers.BaseLayoutManager.implement(new Options);
|