Several fixes added.
This commit is contained in:
@@ -18,8 +18,9 @@
|
||||
|
||||
//noinspection JSUnusedLocalSymbols
|
||||
mindplot.ActionDispatcher = new Class({
|
||||
|
||||
initialize: function() {
|
||||
Implements:[Events],
|
||||
initialize: function(commandContext) {
|
||||
$assert(commandContext, "commandContext can not be null");
|
||||
},
|
||||
|
||||
addIconToTopic: function(topicId, iconType) {
|
||||
@@ -92,7 +93,9 @@ mindplot.ActionDispatcher = new Class({
|
||||
|
||||
changeFontWeightToTopic : function(topicsIds) {
|
||||
throw "method must be implemented.";
|
||||
|
||||
},
|
||||
changeTextOnTopic : function(topicsIds, text) {
|
||||
throw "method must be implemented.";
|
||||
}
|
||||
|
||||
});
|
||||
|
@@ -18,9 +18,8 @@
|
||||
|
||||
mindplot.BrixActionDispatcher = new Class({
|
||||
Extends: mindplot.ActionDispatcher,
|
||||
initialize: function(designer) {
|
||||
$assert(designer, "designer can not be null");
|
||||
|
||||
initialize: function(commandContext, fireOnChange) {
|
||||
this.parent(commandContext, fireOnChange);
|
||||
}
|
||||
});
|
||||
|
||||
|
@@ -16,43 +16,36 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
// @Todo: Why the whole desginer ?. Must decouple this...
|
||||
mindplot.DesignerActionRunner = new Class({
|
||||
initialize: function(designer) {
|
||||
$assert(designer, "designer can not be null");
|
||||
this._designer = designer;
|
||||
initialize: function(commandContext, notifier) {
|
||||
$assert(commandContext, "commandContext can not be null");
|
||||
$assert(event, "event can not be null");
|
||||
|
||||
this._undoManager = new mindplot.DesignerUndoManager();
|
||||
this._context = new mindplot.CommandContext(this._designer);
|
||||
this._context = commandContext;
|
||||
this._notifier = notifier;
|
||||
},
|
||||
|
||||
execute:function(command) {
|
||||
$assert(command, "command can not be null");
|
||||
// Execute action ...
|
||||
command.execute(this._context);
|
||||
|
||||
// Enqueue it ...
|
||||
this._undoManager.enqueue(command);
|
||||
|
||||
// Fire event
|
||||
var event = this._undoManager._buildEvent();
|
||||
this._designer._fireEvent("change", event);
|
||||
this.fireChangeEvent();
|
||||
},
|
||||
|
||||
undo: function() {
|
||||
this._undoManager.execUndo(this._context);
|
||||
|
||||
// Fire event
|
||||
var event = this._undoManager._buildEvent();
|
||||
this._designer._fireEvent("change", event);
|
||||
this.fireChangeEvent();
|
||||
},
|
||||
|
||||
redo: function() {
|
||||
this._undoManager.execRedo(this._context);
|
||||
this.fireChangeEvent();
|
||||
},
|
||||
|
||||
// Fire event
|
||||
var event = this._undoManager._buildEvent();
|
||||
this._designer._fireEvent("change", event);
|
||||
|
||||
fireChangeEvent : function () {
|
||||
var event = this._undoManager.buildEvent();
|
||||
this._notifier.fireEvent("modelUpdate", event);
|
||||
},
|
||||
|
||||
markAsChangeBase: function() {
|
||||
@@ -61,68 +54,4 @@ mindplot.DesignerActionRunner = new Class({
|
||||
hasBeenChanged: function() {
|
||||
return this._undoManager.hasBeenChanged();
|
||||
}
|
||||
});
|
||||
|
||||
mindplot.CommandContext = new Class({
|
||||
initialize: function(designer) {
|
||||
this._designer = designer;
|
||||
},
|
||||
findTopics:function(topicsIds) {
|
||||
var designerTopics = this._designer._topics;
|
||||
if (!(topicsIds instanceof Array)) {
|
||||
topicsIds = [topicsIds];
|
||||
}
|
||||
|
||||
var result = designerTopics.filter(function(topic) {
|
||||
var found = false;
|
||||
if (topic != null) {
|
||||
var topicId = topic.getId();
|
||||
found = topicsIds.contains(topicId);
|
||||
}
|
||||
return found;
|
||||
|
||||
});
|
||||
return result;
|
||||
},
|
||||
deleteTopic:function(topic) {
|
||||
this._designer._removeNode(topic);
|
||||
},
|
||||
createTopic:function(model, isVisible) {
|
||||
$assert(model, "model can not be null");
|
||||
var topic = this._designer._nodeModelToNodeGraph(model, isVisible);
|
||||
|
||||
return topic;
|
||||
},
|
||||
createModel:function() {
|
||||
var mindmap = this._designer.getMindmap();
|
||||
var model = mindmap.createNode(mindplot.NodeModel.MAIN_TOPIC_TYPE);
|
||||
return model;
|
||||
},
|
||||
connect:function(childTopic, parentTopic, isVisible) {
|
||||
childTopic.connectTo(parentTopic, this._designer._workspace, isVisible);
|
||||
} ,
|
||||
disconnect:function(topic) {
|
||||
topic.disconnect(this._designer._workspace);
|
||||
},
|
||||
createRelationship:function(model) {
|
||||
$assert(model, "model cannot be null");
|
||||
var relationship = this._designer.createRelationship(model);
|
||||
return relationship;
|
||||
},
|
||||
removeRelationship:function(model) {
|
||||
this._designer.removeRelationship(model);
|
||||
},
|
||||
findRelationships:function(lineIds) {
|
||||
var result = [];
|
||||
lineIds.forEach(function(lineId, index) {
|
||||
var line = this._designer._relationships[lineId];
|
||||
if ($defined(line)) {
|
||||
result.push(line);
|
||||
}
|
||||
}.bind(this));
|
||||
return result;
|
||||
},
|
||||
getSelectedRelationshipLines:function() {
|
||||
return this._designer.getSelectedRelationshipLines();
|
||||
}
|
||||
});
|
||||
});
|
@@ -17,10 +17,12 @@
|
||||
*/
|
||||
|
||||
mindplot.DesignerUndoManager = new Class({
|
||||
initialize: function() {
|
||||
initialize: function(fireChange) {
|
||||
this._undoQueue = [];
|
||||
this._redoQueue = [];
|
||||
this._baseId = 0;
|
||||
this._fireChange = fireChange;
|
||||
|
||||
},
|
||||
|
||||
enqueue:function(command) {
|
||||
@@ -55,7 +57,7 @@ mindplot.DesignerUndoManager = new Class({
|
||||
}
|
||||
},
|
||||
|
||||
_buildEvent: function() {
|
||||
buildEvent: function() {
|
||||
return {undoSteps: this._undoQueue.length, redoSteps:this._redoQueue.length};
|
||||
},
|
||||
|
||||
|
@@ -18,9 +18,9 @@
|
||||
|
||||
mindplot.LocalActionDispatcher = new Class({
|
||||
Extends: mindplot.ActionDispatcher,
|
||||
initialize: function(designer) {
|
||||
$assert(designer, "designer can not be null");
|
||||
this._actionRunner = new mindplot.DesignerActionRunner(designer);
|
||||
initialize: function(commandContext) {
|
||||
this.parent(commandContext);
|
||||
this._actionRunner = new mindplot.DesignerActionRunner(commandContext,this);
|
||||
},
|
||||
|
||||
addIconToTopic: function(topicId, iconType) {
|
||||
@@ -89,6 +89,20 @@ mindplot.LocalActionDispatcher = new Class({
|
||||
|
||||
},
|
||||
|
||||
changeTextOnTopic : function(topicsIds, text) {
|
||||
$assert(topicsIds, "topicsIds can not be null");
|
||||
|
||||
var commandFunc = function(topic, value) {
|
||||
|
||||
var result = topic.getText();
|
||||
topic.setText(value);
|
||||
return result;
|
||||
};
|
||||
|
||||
var command = new mindplot.commands.GenericFunctionCommand(commandFunc, topicsIds, text);
|
||||
this._actionRunner.execute(command);
|
||||
},
|
||||
|
||||
changeFontFamilyToTopic: function(topicIds, fontFamily) {
|
||||
$assert(topicIds, "topicIds can not be null");
|
||||
$assert(fontFamily, "fontFamily can not be null");
|
||||
@@ -207,3 +221,73 @@ mindplot.LocalActionDispatcher = new Class({
|
||||
|
||||
});
|
||||
|
||||
mindplot.CommandContext = new Class({
|
||||
initialize: function(designer) {
|
||||
$assert(designer, "designer can not be null");
|
||||
this._designer = designer;
|
||||
},
|
||||
findTopics:function(topicsIds) {
|
||||
var designerTopics = this._designer._topics;
|
||||
if (!(topicsIds instanceof Array)) {
|
||||
topicsIds = [topicsIds];
|
||||
}
|
||||
|
||||
var result = designerTopics.filter(function(topic) {
|
||||
var found = false;
|
||||
if (topic != null) {
|
||||
var topicId = topic.getId();
|
||||
found = topicsIds.contains(topicId);
|
||||
}
|
||||
return found;
|
||||
|
||||
});
|
||||
return result;
|
||||
},
|
||||
|
||||
deleteTopic:function(topic) {
|
||||
this._designer._removeNode(topic);
|
||||
},
|
||||
|
||||
createTopic:function(model, isVisible) {
|
||||
$assert(model, "model can not be null");
|
||||
return this._designer._nodeModelToNodeGraph(model, isVisible);
|
||||
},
|
||||
|
||||
createModel:function() {
|
||||
var mindmap = this._designer.getMindmap();
|
||||
return mindmap.createNode(mindplot.NodeModel.MAIN_TOPIC_TYPE);
|
||||
},
|
||||
|
||||
connect:function(childTopic, parentTopic, isVisible) {
|
||||
childTopic.connectTo(parentTopic, this._designer._workspace, isVisible);
|
||||
} ,
|
||||
|
||||
disconnect:function(topic) {
|
||||
topic.disconnect(this._designer._workspace);
|
||||
},
|
||||
|
||||
createRelationship:function(model) {
|
||||
$assert(model, "model cannot be null");
|
||||
return this._designer.createRelationship(model);
|
||||
},
|
||||
removeRelationship:function(model) {
|
||||
this._designer.removeRelationship(model);
|
||||
},
|
||||
|
||||
findRelationships:function(lineIds) {
|
||||
var result = [];
|
||||
lineIds.forEach(function(lineId, index) {
|
||||
var line = this._designer._relationships[lineId];
|
||||
if ($defined(line)) {
|
||||
result.push(line);
|
||||
}
|
||||
}.bind(this));
|
||||
return result;
|
||||
},
|
||||
|
||||
getSelectedRelationshipLines:function() {
|
||||
return this._designer.getSelectedRelationshipLines();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
@@ -23,10 +23,13 @@ mindplot.MindmapDesigner = new Class({
|
||||
$assert(divElement, "divElement must be defined");
|
||||
|
||||
// Dispatcher manager ...
|
||||
// @Todo: Remove this static. Sucks...
|
||||
this._actionDispatcher = new mindplot.LocalActionDispatcher(this);
|
||||
mindplot.ActionDispatcher.setInstance(this._actionDispatcher);
|
||||
var commandContext = new mindplot.CommandContext(this);
|
||||
this._actionDispatcher = new mindplot.LocalActionDispatcher(commandContext);
|
||||
this._actionDispatcher.addEvent("modelUpdate", function(event) {
|
||||
this._fireEvent("modelUpdate", event);
|
||||
}.bind(this));
|
||||
|
||||
mindplot.ActionDispatcher.setInstance(this._actionDispatcher);
|
||||
|
||||
// Initial Zoom
|
||||
this._zoom = profile.zoom;
|
||||
@@ -60,7 +63,6 @@ mindplot.MindmapDesigner = new Class({
|
||||
return topics[0];
|
||||
},
|
||||
|
||||
|
||||
addEventListener : function(eventType, listener) {
|
||||
|
||||
this._events[eventType] = listener;
|
||||
@@ -156,7 +158,7 @@ mindplot.MindmapDesigner = new Class({
|
||||
this.getEditor().lostFocus();
|
||||
var selectableObjects = this.getSelectedObjects();
|
||||
// Disable all nodes on focus but not the current if Ctrl key isn't being pressed
|
||||
if (!$defined(event) || event.ctrlKey == false) {
|
||||
if (!$defined(event) || event.ctrlKey) {
|
||||
for (var i = 0; i < selectableObjects.length; i++) {
|
||||
var selectableObject = selectableObjects[i];
|
||||
if (selectableObject.isOnFocus() && selectableObject != currentObject) {
|
||||
@@ -788,27 +790,6 @@ mindplot.MindmapDesigner = new Class({
|
||||
}
|
||||
},
|
||||
|
||||
removeLastImageFromSelectedNode : function() {
|
||||
var nodes = this._getSelectedNodes();
|
||||
if (nodes.length == 0) {
|
||||
core.Monitor.getInstance().logMessage('A topic must be selected in order to execute this operation.');
|
||||
} else {
|
||||
var elem = nodes[0];
|
||||
elem.removeLastIcon(this);
|
||||
core.Executor.instance.delay(elem.updateNode, 0, elem);
|
||||
/*var executor = function(editor)
|
||||
{
|
||||
return function()
|
||||
{
|
||||
elem.updateNode();
|
||||
};
|
||||
};
|
||||
|
||||
setTimeout(executor(this), 0);*/
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
_getSelectedNodes : function() {
|
||||
var result = new Array();
|
||||
for (var i = 0; i < this._topics.length; i++) {
|
||||
@@ -858,6 +839,7 @@ mindplot.MindmapDesigner = new Class({
|
||||
evt.returnValue = false;
|
||||
}
|
||||
else {
|
||||
// @ToDo: I think that some of the keys has been removed ... Check this...
|
||||
evt = new Event(event);
|
||||
var key = evt.key;
|
||||
if (!this._editor.isVisible()) {
|
||||
@@ -1077,17 +1059,6 @@ mindplot.MindmapDesigner = new Class({
|
||||
|
||||
getWorkSpace : function() {
|
||||
return this._workspace;
|
||||
},
|
||||
|
||||
findRelationShipsByTopicId : function(topicId) {
|
||||
var result = [];
|
||||
for (var relationshipId in this._relationships) {
|
||||
var relationship = this._relationships[relationshipId];
|
||||
if (relationship.getModel().getFromNode() == topicId || relationship.getModel().getToNode() == topicId) {
|
||||
result.push(relationship);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
);
|
||||
|
@@ -131,13 +131,8 @@ mindplot.TextEditor = new Class({
|
||||
var text = this.getText();
|
||||
var topicId = this._currentNode.getId();
|
||||
|
||||
var commandFunc = function(topic, value) {
|
||||
var result = topic.getText();
|
||||
topic.setText(value);
|
||||
return result;
|
||||
};
|
||||
var command = new mindplot.commands.GenericFunctionCommand(commandFunc, text, [topicId]);
|
||||
this._actionRunner.execute(command);
|
||||
var actionDispatcher = mindplot.ActionDispatcher.getInstance();
|
||||
actionDispatcher.changeTextOnTopic([topicId], text);
|
||||
}
|
||||
},
|
||||
|
||||
|
@@ -906,7 +906,6 @@ mindplot.Topic = new Class({
|
||||
},
|
||||
|
||||
_setRelationshipLinesVisibility : function(value) {
|
||||
//var relationships = designer.findRelationShipsByTopicId(this.getId());
|
||||
this._relationships.forEach(function(relationship, index) {
|
||||
relationship.setVisibility(value);
|
||||
});
|
||||
|
@@ -1,7 +1,7 @@
|
||||
mindplot.layout.boards = {};
|
||||
|
||||
mindplot.layout.boards.Board = new Class({
|
||||
|
||||
Implements: [Events,Options],
|
||||
options: {
|
||||
|
||||
},
|
||||
@@ -31,6 +31,3 @@ mindplot.layout.boards.Board = new Class({
|
||||
});
|
||||
|
||||
mindplot.layout.boards.Board.NAME = "Board";
|
||||
|
||||
mindplot.layout.boards.Board.implement(new Events);
|
||||
mindplot.layout.boards.Board.implement(new Options);
|
Reference in New Issue
Block a user