Add support for custom dialogs and extend drag support.
This commit is contained in:
@@ -61,7 +61,7 @@ mindplot.Designer = new Class({
|
||||
// Set editor working area ...
|
||||
this.setViewPort(options.viewPort);
|
||||
|
||||
mindplot.TopicEditor.configure();
|
||||
mindplot.TopicEditor.configure(this.isReadOnly());
|
||||
},
|
||||
|
||||
_registerEvents : function() {
|
||||
@@ -72,6 +72,15 @@ mindplot.Designer = new Class({
|
||||
mindplot.DesignerKeyboard.register(this);
|
||||
},
|
||||
|
||||
addEvent: function(type, listener) {
|
||||
if (type == "editnode") {
|
||||
var editor = mindplot.TopicEditor.getInstance();
|
||||
editor.addEvent(type, listener);
|
||||
} else {
|
||||
this.parent(type, listener);
|
||||
}
|
||||
},
|
||||
|
||||
_registerMouseEvents : function() {
|
||||
var workspace = this._workspace;
|
||||
var screenManager = workspace.getScreenManager();
|
||||
@@ -329,7 +338,7 @@ mindplot.Designer = new Class({
|
||||
// Create a new node ...
|
||||
var model = topic.getModel();
|
||||
var mindmap = model.getMindmap();
|
||||
var childModel = mindmap.createNode(mindplot.model.INodeModel.MAIN_TOPIC_TYPE);
|
||||
var childModel = mindmap.createNode();
|
||||
|
||||
// Create a new node ...
|
||||
var layoutManager = this._eventBussDispatcher.getLayoutManager();
|
||||
@@ -342,19 +351,9 @@ mindplot.Designer = new Class({
|
||||
return childModel;
|
||||
},
|
||||
|
||||
addDraggedNode: function(event, options) {
|
||||
addDraggedNode: function(event, model) {
|
||||
$assert(event, "event can not be null");
|
||||
$assert(options, "option can not be null");
|
||||
|
||||
// Create a new node ...
|
||||
var mindmap = this.getMindmap();
|
||||
var model = mindmap.createNode(mindplot.model.INodeModel.MAIN_TOPIC_TYPE);
|
||||
model.setShapeType(mindplot.model.TopicShape.IMAGE);
|
||||
|
||||
// Set node specified options ...
|
||||
model.setImageUrl(options.imageUrl);
|
||||
model.setImageSize(options.imageWidth, options.imageHeight);
|
||||
model.setMetadata(options.metadata);
|
||||
$assert(model, "model can not be null");
|
||||
|
||||
// Position far from the visual area ...
|
||||
model.setPosition(1000, 1000);
|
||||
@@ -402,7 +401,7 @@ mindplot.Designer = new Class({
|
||||
// Create a new node ...
|
||||
var model = topic.getModel();
|
||||
var mindmap = model.getMindmap();
|
||||
result = mindmap.createNode(mindplot.model.INodeModel.MAIN_TOPIC_TYPE);
|
||||
result = mindmap.createNode();
|
||||
|
||||
// Create a new node ...
|
||||
var order = topic.getOrder() + 1;
|
||||
@@ -449,42 +448,42 @@ mindplot.Designer = new Class({
|
||||
this._mindmap = mindmapModel;
|
||||
|
||||
// try {
|
||||
// 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);
|
||||
// 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 ...
|
||||
var branches = mindmapModel.getBranches();
|
||||
for (var i = 0; i < branches.length; i++) {
|
||||
// NodeModel -> NodeGraph ...
|
||||
var nodeModel = branches[i];
|
||||
var nodeGraph = this._nodeModelToNodeGraph(nodeModel, false);
|
||||
// Building node graph ...
|
||||
var branches = mindmapModel.getBranches();
|
||||
for (var i = 0; i < branches.length; i++) {
|
||||
// NodeModel -> NodeGraph ...
|
||||
var nodeModel = branches[i];
|
||||
var nodeGraph = this._nodeModelToNodeGraph(nodeModel, false);
|
||||
|
||||
// Update shrink render state...
|
||||
nodeGraph.setBranchVisibility(true);
|
||||
}
|
||||
// Update shrink render state...
|
||||
nodeGraph.setBranchVisibility(true);
|
||||
}
|
||||
|
||||
var relationships = mindmapModel.getRelationships();
|
||||
for (var j = 0; j < relationships.length; j++) {
|
||||
this._relationshipModelToRelationship(relationships[j]);
|
||||
}
|
||||
var relationships = mindmapModel.getRelationships();
|
||||
for (var j = 0; j < relationships.length; j++) {
|
||||
this._relationshipModelToRelationship(relationships[j]);
|
||||
}
|
||||
|
||||
// Place the focus on the Central Topic
|
||||
var centralTopic = this.getModel().getCentralTopic();
|
||||
this.goToNode(centralTopic);
|
||||
// Place the focus on the Central Topic
|
||||
var centralTopic = this.getModel().getCentralTopic();
|
||||
this.goToNode(centralTopic);
|
||||
|
||||
// Finally, sort the map ...
|
||||
mindplot.EventBus.instance.fireEvent(mindplot.EventBus.events.DoLayout);
|
||||
// Finally, sort the map ...
|
||||
mindplot.EventBus.instance.fireEvent(mindplot.EventBus.events.DoLayout);
|
||||
|
||||
this.fireEvent('loadSuccess');
|
||||
this.fireEvent('loadSuccess');
|
||||
// } catch(e) {
|
||||
// this.fireEvent('loadError', e);
|
||||
// }
|
||||
|
Reference in New Issue
Block a user