mirror of
https://bitbucket.org/wisemapping/wisemapping-open-source.git
synced 2024-11-22 14:17:57 +01:00
Refactor designer moving methods to a designer model.
This commit is contained in:
parent
f01a01b72d
commit
046789bb6a
@ -297,7 +297,7 @@ core.Utils.animatePosition = function (elems, doneFn, designer) {
|
|||||||
for (var j = 0; j < keys.length; j++) {
|
for (var j = 0; j < keys.length; j++) {
|
||||||
var id = keys[j];
|
var id = keys[j];
|
||||||
var mod = elems.get(id);
|
var mod = elems.get(id);
|
||||||
var allTopics = designer._getTopics();
|
var allTopics = designer.getModel().getTopics();
|
||||||
var currentTopic = allTopics.filter(function(node) {
|
var currentTopic = allTopics.filter(function(node) {
|
||||||
return node.getId() == id;
|
return node.getId() == id;
|
||||||
})[0];
|
})[0];
|
||||||
@ -314,7 +314,7 @@ core.Utils.animatePosition = function (elems, doneFn, designer) {
|
|||||||
for (var j = 0; j < keys.length; j++) {
|
for (var j = 0; j < keys.length; j++) {
|
||||||
var id = keys[j];
|
var id = keys[j];
|
||||||
var mod = elems.get(id);
|
var mod = elems.get(id);
|
||||||
var allTopics = designer._getTopics();
|
var allTopics = designer.getModel().getTopics();
|
||||||
var currentTopic = allTopics.filter(function(node) {
|
var currentTopic = allTopics.filter(function(node) {
|
||||||
return node.getId() == id;
|
return node.getId() == id;
|
||||||
})[0];
|
})[0];
|
||||||
|
@ -58,6 +58,7 @@
|
|||||||
<filelist dir="${basedir}/src/main/javascript/" files="ActionDispatcher.js"/>
|
<filelist dir="${basedir}/src/main/javascript/" files="ActionDispatcher.js"/>
|
||||||
<filelist dir="${basedir}/src/main/javascript/" files="BrixActionDispatcher.js"/>
|
<filelist dir="${basedir}/src/main/javascript/" files="BrixActionDispatcher.js"/>
|
||||||
<filelist dir="${basedir}/src/main/javascript/" files="LocalActionDispatcher.js"/>
|
<filelist dir="${basedir}/src/main/javascript/" files="LocalActionDispatcher.js"/>
|
||||||
|
<filelist dir="${basedir}/src/main/javascript/" files="DesignerModel.js"/>
|
||||||
<filelist dir="${basedir}/src/main/javascript/" files="MindmapDesigner.js"/>
|
<filelist dir="${basedir}/src/main/javascript/" files="MindmapDesigner.js"/>
|
||||||
<filelist dir="${basedir}/src/main/javascript/" files="ScreenManager.js"/>
|
<filelist dir="${basedir}/src/main/javascript/" files="ScreenManager.js"/>
|
||||||
<filelist dir="${basedir}/src/main/javascript/" files="Workspace.js"/>
|
<filelist dir="${basedir}/src/main/javascript/" files="Workspace.js"/>
|
||||||
@ -113,7 +114,7 @@
|
|||||||
<filelist dir="${basedir}/src/main/javascript/"
|
<filelist dir="${basedir}/src/main/javascript/"
|
||||||
files="commands/GenericFunctionCommand.js"/>
|
files="commands/GenericFunctionCommand.js"/>
|
||||||
<filelist dir="${basedir}/src/main/javascript/"
|
<filelist dir="${basedir}/src/main/javascript/"
|
||||||
files="commands/DeleteTopicCommand.js"/>
|
files="commands/DeleteCommand.js"/>
|
||||||
<filelist dir="${basedir}/src/main/javascript/"
|
<filelist dir="${basedir}/src/main/javascript/"
|
||||||
files="commands/DragTopicCommand.js"/>
|
files="commands/DragTopicCommand.js"/>
|
||||||
<filelist dir="${basedir}/src/main/javascript/"
|
<filelist dir="${basedir}/src/main/javascript/"
|
||||||
|
@ -221,7 +221,7 @@ mindplot.DesignerKeyboard = new Class({
|
|||||||
|
|
||||||
// If it's not registered, let's
|
// If it's not registered, let's
|
||||||
if (!isRegistered && !excludes.contains(key) && !modifiers.contains(key) && !key.contains('meta') && !key.contains('ctrl') && !key.contains('control')) {
|
if (!isRegistered && !excludes.contains(key) && !modifiers.contains(key) && !key.contains('meta') && !key.contains('ctrl') && !key.contains('control')) {
|
||||||
var nodes = designer.getSelectedNodes();
|
var nodes = designer.getModel().filterSelectedTopics();
|
||||||
if (nodes.length > 0) {
|
if (nodes.length > 0) {
|
||||||
nodes[0].showTextEditor(event.key);
|
nodes[0].showTextEditor(event.key);
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
@ -324,7 +324,7 @@ mindplot.DesignerKeyboard = new Class({
|
|||||||
},
|
},
|
||||||
|
|
||||||
_getSelectedNode : function(designer) {
|
_getSelectedNode : function(designer) {
|
||||||
var nodes = designer.getSelectedNodes();
|
var nodes = designer.filterSelectedTopics();
|
||||||
return (nodes.length > 0) ? nodes[0] : null;
|
return (nodes.length > 0) ? nodes[0] : null;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
136
mindplot/src/main/javascript/DesignerModel.js
Normal file
136
mindplot/src/main/javascript/DesignerModel.js
Normal file
@ -0,0 +1,136 @@
|
|||||||
|
/*
|
||||||
|
* 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.DesignerModel = new Class({
|
||||||
|
initialize : function(options) {
|
||||||
|
this._zoom = options.zoom;
|
||||||
|
this._topics = [];
|
||||||
|
this._relationships = {};
|
||||||
|
},
|
||||||
|
|
||||||
|
getZoom : function() {
|
||||||
|
return this._zoom;
|
||||||
|
},
|
||||||
|
|
||||||
|
setZoom : function(zoom) {
|
||||||
|
this._zoom = zoom;
|
||||||
|
},
|
||||||
|
|
||||||
|
getTopics : function() {
|
||||||
|
return this._topics;
|
||||||
|
},
|
||||||
|
|
||||||
|
getCentralTopic : function() {
|
||||||
|
var topics = this.getTopics();
|
||||||
|
return topics[0];
|
||||||
|
},
|
||||||
|
|
||||||
|
filterSelectedTopics : function() {
|
||||||
|
var result = [];
|
||||||
|
for (var i = 0; i < this._topics.length; i++) {
|
||||||
|
if (this._topics[i].isOnFocus()) {
|
||||||
|
result.push(this._topics[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
},
|
||||||
|
|
||||||
|
filterSelectedRelations : function() {
|
||||||
|
var result = [];
|
||||||
|
for (var id in this._relationships) {
|
||||||
|
var relationship = this._relationships[id];
|
||||||
|
if (relationship.isOnFocus()) {
|
||||||
|
result.push(relationship);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
},
|
||||||
|
|
||||||
|
getObjects : function() {
|
||||||
|
var result = [].append(this._topics);
|
||||||
|
for (var id in this._relationships) {
|
||||||
|
result.push(this._relationships[id]);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
},
|
||||||
|
|
||||||
|
removeTopic : function(topic) {
|
||||||
|
$assert(topic, "topic can not be null");
|
||||||
|
this._topics.erase(topic);
|
||||||
|
},
|
||||||
|
|
||||||
|
addTopic : function(topic) {
|
||||||
|
$assert(topic, "topic can not be null");
|
||||||
|
this._topics.push(topic);
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
filterTopicsIds : function(validate, errorMsg) {
|
||||||
|
var result = [];
|
||||||
|
var topics = this.filterSelectedTopics();
|
||||||
|
|
||||||
|
if (topics.length==0) {
|
||||||
|
core.Monitor.getInstance().logMessage('At least one element must be selected to execute this operation.');
|
||||||
|
} else {
|
||||||
|
var isValid = true;
|
||||||
|
for (var i = 0; i < topics.length; i++) {
|
||||||
|
var selectedNode = topics[i];
|
||||||
|
if ($defined(validate)) {
|
||||||
|
isValid = validate(selectedNode);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add node only if it's valid.
|
||||||
|
if (isValid) {
|
||||||
|
result.push(selectedNode.getId());
|
||||||
|
} else {
|
||||||
|
core.Monitor.getInstance().logMessage(errorMsg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
},
|
||||||
|
|
||||||
|
filterRelationIds : function(validate, errorMsg) {
|
||||||
|
var result = [];
|
||||||
|
var relationships = this.filterSelectedRelations();
|
||||||
|
if (relationships.length == 0) {
|
||||||
|
core.Monitor.getInstance().logMessage('At least one element must be selected to execute this operation.');
|
||||||
|
} else {
|
||||||
|
var isValid = true;
|
||||||
|
for (var j = 0; j < relationships.length; j++) {
|
||||||
|
var selectedLine = relationships[j];
|
||||||
|
isValid = true;
|
||||||
|
if ($defined(validate)) {
|
||||||
|
isValid = validate(selectedLine);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isValid) {
|
||||||
|
result.push(selectedLine.getId());
|
||||||
|
} else {
|
||||||
|
core.Monitor.getInstance().logMessage(errorMsg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
},
|
||||||
|
|
||||||
|
getRelationshipsById : function() {
|
||||||
|
return this._relationships;
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
@ -20,7 +20,7 @@ mindplot.DragTopicPositioner = new Class({
|
|||||||
initialize:function(layoutManager) {
|
initialize:function(layoutManager) {
|
||||||
$assert(layoutManager, 'layoutManager can not be null');
|
$assert(layoutManager, 'layoutManager can not be null');
|
||||||
this._layoutManager = layoutManager;
|
this._layoutManager = layoutManager;
|
||||||
this._topics = layoutManager.getDesigner()._getTopics();
|
this._topics = layoutManager.getDesigner().getModel().getTopics();
|
||||||
this._workspace = layoutManager.getDesigner().getWorkSpace();
|
this._workspace = layoutManager.getDesigner().getWorkSpace();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -54,7 +54,7 @@ mindplot.LocalActionDispatcher = new Class({
|
|||||||
},
|
},
|
||||||
|
|
||||||
deleteTopics: function(topicsIds) {
|
deleteTopics: function(topicsIds) {
|
||||||
var command = new mindplot.commands.DeleteTopicCommand(topicsIds);
|
var command = new mindplot.commands.DeleteCommand(topicsIds);
|
||||||
this.execute(command);
|
this.execute(command);
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -240,8 +240,9 @@ mindplot.CommandContext = new Class({
|
|||||||
$assert(designer, "designer can not be null");
|
$assert(designer, "designer can not be null");
|
||||||
this._designer = designer;
|
this._designer = designer;
|
||||||
},
|
},
|
||||||
|
|
||||||
findTopics:function(topicsIds) {
|
findTopics:function(topicsIds) {
|
||||||
var designerTopics = this._designer._topics;
|
var designerTopics = this._designer.getModel().getTopics();
|
||||||
if (!(topicsIds instanceof Array)) {
|
if (!(topicsIds instanceof Array)) {
|
||||||
topicsIds = [topicsIds];
|
topicsIds = [topicsIds];
|
||||||
}
|
}
|
||||||
@ -290,18 +291,14 @@ mindplot.CommandContext = new Class({
|
|||||||
|
|
||||||
findRelationships:function(lineIds) {
|
findRelationships:function(lineIds) {
|
||||||
var result = [];
|
var result = [];
|
||||||
lineIds.forEach(function(lineId, index) {
|
lineIds.forEach(function(lineId) {
|
||||||
var line = this._designer._relationships[lineId];
|
var line = this._designer.getModel().getRelationshipsById()[lineId];
|
||||||
if ($defined(line)) {
|
if ($defined(line)) {
|
||||||
result.push(line);
|
result.push(line);
|
||||||
}
|
}
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
return result;
|
return result;
|
||||||
},
|
},
|
||||||
|
|
||||||
getSelectedRelationshipLines:function() {
|
|
||||||
return this._designer.getSelectedRelationshipLines();
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
@ -26,34 +26,31 @@ mindplot.MindmapDesigner = new Class({
|
|||||||
var commandContext = new mindplot.CommandContext(this);
|
var commandContext = new mindplot.CommandContext(this);
|
||||||
// this._actionDispatcher = new mindplot.BrixActionDispatcher(commandContext);
|
// this._actionDispatcher = new mindplot.BrixActionDispatcher(commandContext);
|
||||||
this._actionDispatcher = new mindplot.LocalActionDispatcher(commandContext);
|
this._actionDispatcher = new mindplot.LocalActionDispatcher(commandContext);
|
||||||
|
|
||||||
this._actionDispatcher.addEvent("modelUpdate", function(event) {
|
this._actionDispatcher.addEvent("modelUpdate", function(event) {
|
||||||
this._fireEvent("modelUpdate", event);
|
this._fireEvent("modelUpdate", event);
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
|
|
||||||
mindplot.ActionDispatcher.setInstance(this._actionDispatcher);
|
mindplot.ActionDispatcher.setInstance(this._actionDispatcher);
|
||||||
|
|
||||||
// Initial Zoom
|
// Initial Zoom
|
||||||
this._zoom = profile.zoom;
|
this._zoom = profile.zoom;
|
||||||
|
|
||||||
|
this._model = new mindplot.DesignerModel(profile);
|
||||||
|
|
||||||
// Init Screen manager..
|
// Init Screen manager..
|
||||||
var screenManager = new mindplot.ScreenManager(profile.width, profile.height, divElement);
|
var screenManager = new mindplot.ScreenManager(profile.width, profile.height, divElement);
|
||||||
this._workspace = new mindplot.Workspace(profile, screenManager, this._zoom);
|
this._workspace = new mindplot.Workspace(profile, screenManager, this._zoom);
|
||||||
this._readOnly = profile.readOnly ? true : false;
|
this._readOnly = profile.readOnly ? true : false;
|
||||||
|
|
||||||
// Init layout managers ...
|
// Init layout managers ...
|
||||||
this._topics = [];
|
|
||||||
this._layoutManager = new mindplot.layout.OriginalLayoutManager(this);
|
this._layoutManager = new mindplot.layout.OriginalLayoutManager(this);
|
||||||
|
|
||||||
// Register handlers..
|
|
||||||
this._relationships = {};
|
|
||||||
this._events = {};
|
|
||||||
|
|
||||||
// Register events
|
// Register events
|
||||||
if (!profile.readOnly) {
|
if (!profile.readOnly) {
|
||||||
this._registerEvents();
|
this._registerEvents();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this._events = {};
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
_registerEvents : function() {
|
_registerEvents : function() {
|
||||||
@ -78,7 +75,7 @@ mindplot.MindmapDesigner = new Class({
|
|||||||
// Initialize workspace event listeners.
|
// Initialize workspace event listeners.
|
||||||
screenManager.addEvent('update', function() {
|
screenManager.addEvent('update', function() {
|
||||||
// Topic must be set to his original state. All editors must be closed.
|
// Topic must be set to his original state. All editors must be closed.
|
||||||
var objects = this.getObjects();
|
var objects = this.getModel().getObjects();
|
||||||
objects.forEach(function(object) {
|
objects.forEach(function(object) {
|
||||||
object.closeEditors();
|
object.closeEditors();
|
||||||
});
|
});
|
||||||
@ -105,7 +102,7 @@ mindplot.MindmapDesigner = new Class({
|
|||||||
model.setPosition(pos.x, pos.y);
|
model.setPosition(pos.x, pos.y);
|
||||||
|
|
||||||
// Get central topic ...
|
// Get central topic ...
|
||||||
var centralTopic = this.getCentralTopic();
|
var centralTopic = this.getModel().getCentralTopic();
|
||||||
var centralTopicId = centralTopic.getId();
|
var centralTopicId = centralTopic.getId();
|
||||||
|
|
||||||
// Execute action ...
|
// Execute action ...
|
||||||
@ -125,15 +122,6 @@ mindplot.MindmapDesigner = new Class({
|
|||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
_getTopics : function() {
|
|
||||||
return this._topics;
|
|
||||||
},
|
|
||||||
|
|
||||||
getCentralTopic : function() {
|
|
||||||
var topics = this._getTopics();
|
|
||||||
return topics[0];
|
|
||||||
},
|
|
||||||
|
|
||||||
addEvent : function(eventType, listener) {
|
addEvent : function(eventType, listener) {
|
||||||
this._events[eventType] = listener;
|
this._events[eventType] = listener;
|
||||||
},
|
},
|
||||||
@ -151,13 +139,10 @@ mindplot.MindmapDesigner = new Class({
|
|||||||
|
|
||||||
// Create node graph ...
|
// Create node graph ...
|
||||||
var topic = mindplot.NodeGraph.create(model);
|
var topic = mindplot.NodeGraph.create(model);
|
||||||
|
|
||||||
this._layoutManager.addHelpers(topic);
|
this._layoutManager.addHelpers(topic);
|
||||||
|
|
||||||
// Append it to the workspace ...
|
// Append it to the workspace ...
|
||||||
var topics = this._topics;
|
this.getModel().addTopic(topic);
|
||||||
topics.push(topic);
|
|
||||||
|
|
||||||
|
|
||||||
// Add Topic events ...
|
// Add Topic events ...
|
||||||
if (!this._readOnly) {
|
if (!this._readOnly) {
|
||||||
@ -195,12 +180,13 @@ mindplot.MindmapDesigner = new Class({
|
|||||||
|
|
||||||
onObjectFocusEvent : function(currentObject, event) {
|
onObjectFocusEvent : function(currentObject, event) {
|
||||||
// Close node editors ..
|
// Close node editors ..
|
||||||
var topics = this._getTopics();
|
var topics = this.getModel().getTopics();
|
||||||
topics.forEach(function(topic) {
|
topics.forEach(function(topic) {
|
||||||
topic.closeEditors();
|
topic.closeEditors();
|
||||||
});
|
});
|
||||||
|
|
||||||
var objects = this.getObjects();
|
var model = this.getModel();
|
||||||
|
var objects = model.getObjects();
|
||||||
objects.forEach(function(object) {
|
objects.forEach(function(object) {
|
||||||
// Disable all nodes on focus but not the current if Ctrl key isn't being pressed
|
// Disable all nodes on focus but not the current if Ctrl key isn't being pressed
|
||||||
if (!$defined(event) || (!event.ctrlKey && !event.metaKey)) {
|
if (!$defined(event) || (!event.ctrlKey && !event.metaKey)) {
|
||||||
@ -216,9 +202,10 @@ mindplot.MindmapDesigner = new Class({
|
|||||||
if (!factor)
|
if (!factor)
|
||||||
factor = 1.2;
|
factor = 1.2;
|
||||||
|
|
||||||
var scale = this._zoom * factor;
|
var model = this.getModel();
|
||||||
|
var scale = model.getZoom() * factor;
|
||||||
if (scale <= 4) {
|
if (scale <= 4) {
|
||||||
this._zoom = scale;
|
model.setZoom(scale);
|
||||||
this._workspace.setZoom(this._zoom);
|
this._workspace.setZoom(this._zoom);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -228,14 +215,15 @@ mindplot.MindmapDesigner = new Class({
|
|||||||
},
|
},
|
||||||
|
|
||||||
selectAll : function() {
|
selectAll : function() {
|
||||||
var objects = this.getObjects();
|
var model = this.getModel();
|
||||||
|
var objects = model.getObjects();
|
||||||
objects.forEach(function(object) {
|
objects.forEach(function(object) {
|
||||||
object.setOnFocus(true);
|
object.setOnFocus(true);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
deselectAll : function() {
|
deselectAll : function() {
|
||||||
var objects = this.getObjects();
|
var objects = this.getModel().getObjects();
|
||||||
objects.forEach(function(object) {
|
objects.forEach(function(object) {
|
||||||
object.setOnFocus(false);
|
object.setOnFocus(false);
|
||||||
});
|
});
|
||||||
@ -245,20 +233,24 @@ mindplot.MindmapDesigner = new Class({
|
|||||||
if (!factor)
|
if (!factor)
|
||||||
factor = 1.2;
|
factor = 1.2;
|
||||||
|
|
||||||
var scale = this._zoom / factor;
|
var model = this.getModel();
|
||||||
|
var scale = model.getZoom() / factor;
|
||||||
if (scale >= 0.3) {
|
if (scale >= 0.3) {
|
||||||
this._zoom = scale;
|
model.setZoom(scale);
|
||||||
this._workspace.setZoom(this._zoom);
|
this._workspace.setZoom(this._zoom);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
core.Monitor.getInstance().logMessage('Sorry, no more zoom can be applied. \n Why do you need more?');
|
core.Monitor.getInstance().logMessage('Sorry, no more zoom can be applied. \n Why do you need more?');
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
,
|
|
||||||
|
getModel : function() {
|
||||||
|
return this._model;
|
||||||
|
},
|
||||||
|
|
||||||
createChildForSelectedNode : function() {
|
createChildForSelectedNode : function() {
|
||||||
|
|
||||||
var nodes = this.getSelectedNodes();
|
var nodes = this.getModel().filterSelectedTopics();
|
||||||
if (nodes.length <= 0) {
|
if (nodes.length <= 0) {
|
||||||
// If there are more than one node selected,
|
// If there are more than one node selected,
|
||||||
core.Monitor.getInstance().logMessage('Could not create a topic. Only one node must be selected.');
|
core.Monitor.getInstance().logMessage('Could not create a topic. Only one node must be selected.');
|
||||||
@ -283,7 +275,7 @@ mindplot.MindmapDesigner = new Class({
|
|||||||
},
|
},
|
||||||
|
|
||||||
createSiblingForSelectedNode : function() {
|
createSiblingForSelectedNode : function() {
|
||||||
var nodes = this.getSelectedNodes();
|
var nodes = this.getModel().filterSelectedTopics();
|
||||||
if (nodes.length <= 0) {
|
if (nodes.length <= 0) {
|
||||||
// If there are more than one node selected,
|
// If there are more than one node selected,
|
||||||
core.Monitor.getInstance().logMessage('Could not create a topic. Only one node must be selected.');
|
core.Monitor.getInstance().logMessage('Could not create a topic. Only one node must be selected.');
|
||||||
@ -314,7 +306,7 @@ mindplot.MindmapDesigner = new Class({
|
|||||||
addRelationShip : function(event) {
|
addRelationShip : function(event) {
|
||||||
var screen = this._workspace.getScreenManager();
|
var screen = this._workspace.getScreenManager();
|
||||||
var pos = screen.getWorkspaceMousePosition(event);
|
var pos = screen.getWorkspaceMousePosition(event);
|
||||||
var selectedTopics = this.getSelectedNodes();
|
var selectedTopics = this.getModel().filterSelectedTopics();
|
||||||
if (selectedTopics.length > 0 &&
|
if (selectedTopics.length > 0 &&
|
||||||
(!$defined(this._creatingRelationship) || ($defined(this._creatingRelationship) && !this._creatingRelationship))) {
|
(!$defined(this._creatingRelationship) || ($defined(this._creatingRelationship) && !this._creatingRelationship))) {
|
||||||
this._workspace.enableWorkspaceEvents(false);
|
this._workspace.enableWorkspaceEvents(false);
|
||||||
@ -370,8 +362,7 @@ mindplot.MindmapDesigner = new Class({
|
|||||||
|
|
||||||
this._actionDispatcher.addRelationship(model, mindmap);
|
this._actionDispatcher.addRelationship(model, mindmap);
|
||||||
|
|
||||||
}
|
},
|
||||||
,
|
|
||||||
|
|
||||||
needsSave : function() {
|
needsSave : function() {
|
||||||
return this._actionRunner.hasBeenChanged();
|
return this._actionRunner.hasBeenChanged();
|
||||||
@ -398,20 +389,18 @@ mindplot.MindmapDesigner = new Class({
|
|||||||
|
|
||||||
// Refresh undo state...
|
// Refresh undo state...
|
||||||
this._actionRunner.markAsChangeBase();
|
this._actionRunner.markAsChangeBase();
|
||||||
}
|
},
|
||||||
,
|
|
||||||
|
|
||||||
loadFromCollaborativeModel: function(collaborationManager) {
|
loadFromCollaborativeModel: function(collaborationManager) {
|
||||||
var mindmap = collaborationManager.buildWiseModel();
|
var mindmap = collaborationManager.buildWiseModel();
|
||||||
this._loadMap(1, mindmap);
|
this._loadMap(1, mindmap);
|
||||||
|
|
||||||
// Place the focus on the Central Topic
|
// Place the focus on the Central Topic
|
||||||
var centralTopic = this.getCentralTopic();
|
var centralTopic = this.getModel().getCentralTopic();
|
||||||
this.goToNode.attempt(centralTopic, this);
|
this.goToNode.attempt(centralTopic, this);
|
||||||
|
|
||||||
this._fireEvent("loadsuccess");
|
this._fireEvent("loadsuccess");
|
||||||
}
|
},
|
||||||
,
|
|
||||||
|
|
||||||
loadFromXML : function(mapId, xmlContent) {
|
loadFromXML : function(mapId, xmlContent) {
|
||||||
$assert(xmlContent, 'mindmapId can not be null');
|
$assert(xmlContent, 'mindmapId can not be null');
|
||||||
@ -426,13 +415,12 @@ mindplot.MindmapDesigner = new Class({
|
|||||||
this._loadMap(mapId, mindmap);
|
this._loadMap(mapId, mindmap);
|
||||||
|
|
||||||
// Place the focus on the Central Topic
|
// Place the focus on the Central Topic
|
||||||
var centralTopic = this.getCentralTopic();
|
var centralTopic = this.getModel().getCentralTopic();
|
||||||
this.goToNode(centralTopic);
|
this.goToNode(centralTopic);
|
||||||
|
|
||||||
this._fireEvent("loadsuccess");
|
this._fireEvent("loadsuccess");
|
||||||
|
|
||||||
}
|
},
|
||||||
,
|
|
||||||
|
|
||||||
load : function(mapId) {
|
load : function(mapId) {
|
||||||
$assert(mapId, 'mapName can not be null');
|
$assert(mapId, 'mapName can not be null');
|
||||||
@ -447,7 +435,7 @@ mindplot.MindmapDesigner = new Class({
|
|||||||
this._loadMap(mapId, mindmap);
|
this._loadMap(mapId, mindmap);
|
||||||
|
|
||||||
// Place the focus on the Central Topic
|
// Place the focus on the Central Topic
|
||||||
var centralTopic = this.getCentralTopic();
|
var centralTopic = this.getModel().getCentralTopic();
|
||||||
this.goToNode.attempt(centralTopic, this);
|
this.goToNode.attempt(centralTopic, this);
|
||||||
|
|
||||||
this._fireEvent("loadsuccess");
|
this._fireEvent("loadsuccess");
|
||||||
@ -475,29 +463,26 @@ mindplot.MindmapDesigner = new Class({
|
|||||||
this._relationshipModelToRelationship(relationships[j]);
|
this._relationshipModelToRelationship(relationships[j]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this._getTopics().forEach(function(topic) {
|
|
||||||
|
this.getModel().getTopics().forEach(function(topic) {
|
||||||
delete topic.getModel()._finalPosition;
|
delete topic.getModel()._finalPosition;
|
||||||
});
|
});
|
||||||
|
|
||||||
this._fireEvent("loadsuccess");
|
this._fireEvent("loadsuccess");
|
||||||
|
|
||||||
}
|
},
|
||||||
,
|
|
||||||
|
|
||||||
|
|
||||||
getMindmap : function() {
|
getMindmap : function() {
|
||||||
return this._mindmap;
|
return this._mindmap;
|
||||||
}
|
},
|
||||||
,
|
|
||||||
|
|
||||||
undo : function() {
|
undo : function() {
|
||||||
this._actionRunner.undo();
|
this._actionRunner.undo();
|
||||||
}
|
},
|
||||||
,
|
|
||||||
|
|
||||||
redo : function() {
|
redo : function() {
|
||||||
this._actionRunner.redo();
|
this._actionRunner.redo();
|
||||||
}
|
},
|
||||||
,
|
|
||||||
|
|
||||||
_nodeModelToNodeGraph : function(nodeModel, isVisible) {
|
_nodeModelToNodeGraph : function(nodeModel, isVisible) {
|
||||||
$assert(nodeModel, "Node model can not be null");
|
$assert(nodeModel, "Node model can not be null");
|
||||||
@ -552,15 +537,16 @@ mindplot.MindmapDesigner = new Class({
|
|||||||
delete this._relationships[model.getId()];
|
delete this._relationships[model.getId()];
|
||||||
},
|
},
|
||||||
|
|
||||||
_buildRelationship : function (model) {
|
_buildRelationship : function (topicModel) {
|
||||||
var elem = this;
|
var elem = this;
|
||||||
|
|
||||||
var fromNodeId = model.getFromNode();
|
var fromNodeId = topicModel.getFromNode();
|
||||||
var toNodeId = model.getToNode();
|
var toNodeId = topicModel.getToNode();
|
||||||
|
|
||||||
var fromTopic = null;
|
var fromTopic = null;
|
||||||
var toTopic = null;
|
var toTopic = null;
|
||||||
var topics = this._topics;
|
var model = this.getModel();
|
||||||
|
var topics = model.getTopics();
|
||||||
|
|
||||||
for (var i = 0; i < topics.length; i++) {
|
for (var i = 0; i < topics.length; i++) {
|
||||||
var t = topics[i];
|
var t = topics[i];
|
||||||
@ -576,21 +562,21 @@ mindplot.MindmapDesigner = new Class({
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Create node graph ...
|
// Create node graph ...
|
||||||
var relationLine = new mindplot.RelationshipLine(fromTopic, toTopic, model.getLineType());
|
var relationLine = new mindplot.RelationshipLine(fromTopic, toTopic, topicModel.getLineType());
|
||||||
if ($defined(model.getSrcCtrlPoint())) {
|
if ($defined(topicModel.getSrcCtrlPoint())) {
|
||||||
var srcPoint = model.getSrcCtrlPoint().clone();
|
var srcPoint = topicModel.getSrcCtrlPoint().clone();
|
||||||
relationLine.setSrcControlPoint(srcPoint);
|
relationLine.setSrcControlPoint(srcPoint);
|
||||||
}
|
}
|
||||||
if ($defined(model.getDestCtrlPoint())) {
|
if ($defined(topicModel.getDestCtrlPoint())) {
|
||||||
var destPoint = model.getDestCtrlPoint().clone();
|
var destPoint = topicModel.getDestCtrlPoint().clone();
|
||||||
relationLine.setDestControlPoint(destPoint);
|
relationLine.setDestControlPoint(destPoint);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
relationLine.getLine().setDashed(3, 2);
|
relationLine.getLine().setDashed(3, 2);
|
||||||
relationLine.setShowEndArrow(model.getEndArrow());
|
relationLine.setShowEndArrow(topicModel.getEndArrow());
|
||||||
relationLine.setShowStartArrow(model.getStartArrow());
|
relationLine.setShowStartArrow(topicModel.getStartArrow());
|
||||||
relationLine.setModel(model);
|
relationLine.setModel(topicModel);
|
||||||
|
|
||||||
//Add Listeners
|
//Add Listeners
|
||||||
relationLine.addEvent('onfocus', function(event) {
|
relationLine.addEvent('onfocus', function(event) {
|
||||||
@ -598,7 +584,7 @@ mindplot.MindmapDesigner = new Class({
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Append it to the workspace ...
|
// Append it to the workspace ...
|
||||||
this._relationships[model.getId()] = relationLine;
|
this._relationships[topicModel.getId()] = relationLine;
|
||||||
|
|
||||||
return relationLine;
|
return relationLine;
|
||||||
},
|
},
|
||||||
@ -614,7 +600,7 @@ mindplot.MindmapDesigner = new Class({
|
|||||||
}
|
}
|
||||||
|
|
||||||
this._workspace.removeChild(node);
|
this._workspace.removeChild(node);
|
||||||
this._topics.erase(node);
|
this.getModel().removeTopic(node);
|
||||||
|
|
||||||
// Delete this node from the model...
|
// Delete this node from the model...
|
||||||
var model = node.getModel();
|
var model = node.getModel();
|
||||||
@ -632,16 +618,18 @@ mindplot.MindmapDesigner = new Class({
|
|||||||
return selectedObject.getType() == mindplot.RelationshipLine.type || selectedObject.getTopicType() != mindplot.model.NodeModel.CENTRAL_TOPIC_TYPE
|
return selectedObject.getType() == mindplot.RelationshipLine.type || selectedObject.getTopicType() != mindplot.model.NodeModel.CENTRAL_TOPIC_TYPE
|
||||||
};
|
};
|
||||||
var validateError = 'Central topic can not be deleted.';
|
var validateError = 'Central topic can not be deleted.';
|
||||||
var selectedObjects = this._getValidSelectedObjectsIds(validateFunc, validateError);
|
var model = this.getModel();
|
||||||
if (selectedObjects.nodes.length > 0 || selectedObjects.relationshipLines.length > 0) {
|
var topics = model.filterTopicsIds(validateFunc, validateError);
|
||||||
this._actionDispatcher.deleteTopics(selectedObjects);
|
var rel = model.filterRelationIds(validateFunc, validateError);
|
||||||
|
|
||||||
|
if (objects.length > 0) {
|
||||||
|
this._actionDispatcher.deleteTopics({'nodes':topics,'relationship':rel});
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
changeFontFamily : function(font) {
|
changeFontFamily : function(font) {
|
||||||
var validSelectedObjects = this._getValidSelectedObjectsIds();
|
var topicsIds = this.getModel().filterTopicsIds();
|
||||||
var topicsIds = validSelectedObjects.nodes;
|
|
||||||
if (topicsIds.length > 0) {
|
if (topicsIds.length > 0) {
|
||||||
this._actionDispatcher.changeFontFamilyToTopic(topicsIds, font);
|
this._actionDispatcher.changeFontFamilyToTopic(topicsIds, font);
|
||||||
|
|
||||||
@ -649,8 +637,7 @@ mindplot.MindmapDesigner = new Class({
|
|||||||
},
|
},
|
||||||
|
|
||||||
changeFontStyle : function() {
|
changeFontStyle : function() {
|
||||||
var validSelectedObjects = this._getValidSelectedObjectsIds();
|
var topicsIds = this.getModel().filterTopicsIds();
|
||||||
var topicsIds = validSelectedObjects.nodes;
|
|
||||||
if (topicsIds.length > 0) {
|
if (topicsIds.length > 0) {
|
||||||
this._actionDispatcher.changeFontStyleToTopic(topicsIds);
|
this._actionDispatcher.changeFontStyleToTopic(topicsIds);
|
||||||
}
|
}
|
||||||
@ -658,8 +645,8 @@ mindplot.MindmapDesigner = new Class({
|
|||||||
|
|
||||||
changeFontColor : function(color) {
|
changeFontColor : function(color) {
|
||||||
$assert(color, "color can not be null");
|
$assert(color, "color can not be null");
|
||||||
var validSelectedObjects = this._getValidSelectedObjectsIds();
|
|
||||||
var topicsIds = validSelectedObjects.nodes;
|
var topicsIds = this.getModel().filterTopicsIds();
|
||||||
if (topicsIds.length > 0) {
|
if (topicsIds.length > 0) {
|
||||||
this._actionDispatcher.changeFontColorToTopic(topicsIds, color);
|
this._actionDispatcher.changeFontColorToTopic(topicsIds, color);
|
||||||
}
|
}
|
||||||
@ -671,67 +658,26 @@ mindplot.MindmapDesigner = new Class({
|
|||||||
return topic.getShapeType() != mindplot.model.NodeModel.SHAPE_TYPE_LINE
|
return topic.getShapeType() != mindplot.model.NodeModel.SHAPE_TYPE_LINE
|
||||||
};
|
};
|
||||||
var validateError = 'Color can not be set to line topics.';
|
var validateError = 'Color can not be set to line topics.';
|
||||||
var validSelectedObjects = this._getValidSelectedObjectsIds(validateFunc, validateError);
|
|
||||||
var topicsIds = validSelectedObjects.nodes;
|
var topicsIds = this.getModel().filterTopicsIds(validateFunc, validateError);
|
||||||
if (topicsIds.length > 0) {
|
if (topicsIds.length > 0) {
|
||||||
this._actionDispatcher.changeBackgroundColorToTopic(topicsIds, color);
|
this._actionDispatcher.changeBackgroundColorToTopic(topicsIds, color);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
_getValidSelectedObjectsIds : function(validate, errorMsg) {
|
|
||||||
var result = {"nodes":[],"relationshipLines":[]};
|
|
||||||
var selectedNodes = this.getSelectedNodes();
|
|
||||||
var selectedRelationshipLines = this.getSelectedRelationshipLines();
|
|
||||||
if (selectedNodes.length == 0 && selectedRelationshipLines.length == 0) {
|
|
||||||
core.Monitor.getInstance().logMessage('At least one element must be selected to execute this operation.');
|
|
||||||
} else {
|
|
||||||
var isValid = true;
|
|
||||||
for (var i = 0; i < selectedNodes.length; i++) {
|
|
||||||
var selectedNode = selectedNodes[i];
|
|
||||||
if ($defined(validate)) {
|
|
||||||
isValid = validate(selectedNode);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add node only if it's valid.
|
|
||||||
if (isValid) {
|
|
||||||
result.nodes.push(selectedNode.getId());
|
|
||||||
} else {
|
|
||||||
core.Monitor.getInstance().logMessage(errorMsg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (var j = 0; j < selectedRelationshipLines.length; j++) {
|
|
||||||
var selectedLine = selectedRelationshipLines[j];
|
|
||||||
isValid = true;
|
|
||||||
if ($defined(validate)) {
|
|
||||||
isValid = validate(selectedLine);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isValid) {
|
|
||||||
result.relationshipLines.push(selectedLine.getId());
|
|
||||||
} else {
|
|
||||||
core.Monitor.getInstance().logMessage(errorMsg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
},
|
|
||||||
|
|
||||||
changeBorderColor : function(color) {
|
changeBorderColor : function(color) {
|
||||||
var validateFunc = function(topic) {
|
var validateFunc = function(topic) {
|
||||||
return topic.getShapeType() != mindplot.model.NodeModel.SHAPE_TYPE_LINE
|
return topic.getShapeType() != mindplot.model.NodeModel.SHAPE_TYPE_LINE
|
||||||
};
|
};
|
||||||
var validateError = 'Color can not be set to line topics.';
|
var validateError = 'Color can not be set to line topics.';
|
||||||
var validSelectedObjects = this._getValidSelectedObjectsIds(validateFunc, validateError);
|
var topicsIds = this.getModel().filterTopicsIds(validateFunc, validateError);
|
||||||
var topicsIds = validSelectedObjects.nodes;
|
|
||||||
|
|
||||||
if (topicsIds.length > 0) {
|
if (topicsIds.length > 0) {
|
||||||
this._actionDispatcher.changeBorderColorToTopic(topicsIds, color);
|
this._actionDispatcher.changeBorderColorToTopic(topicsIds, color);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
changeFontSize : function(size) {
|
changeFontSize : function(size) {
|
||||||
var validSelectedObjects = this._getValidSelectedObjectsIds();
|
var topicsIds = this.getModel().filterTopicsIds();
|
||||||
var topicsIds = validSelectedObjects.nodes;
|
|
||||||
if (topicsIds.length > 0) {
|
if (topicsIds.length > 0) {
|
||||||
this._actionDispatcher.changeFontSizeToTopic(topicsIds, size);
|
this._actionDispatcher.changeFontSizeToTopic(topicsIds, size);
|
||||||
}
|
}
|
||||||
@ -743,40 +689,35 @@ mindplot.MindmapDesigner = new Class({
|
|||||||
return !(topic.getType() == mindplot.model.NodeModel.CENTRAL_TOPIC_TYPE && shape == mindplot.model.NodeModel.SHAPE_TYPE_LINE)
|
return !(topic.getType() == mindplot.model.NodeModel.CENTRAL_TOPIC_TYPE && shape == mindplot.model.NodeModel.SHAPE_TYPE_LINE)
|
||||||
};
|
};
|
||||||
var validateError = 'Central Topic shape can not be changed to line figure.';
|
var validateError = 'Central Topic shape can not be changed to line figure.';
|
||||||
var validSelectedObjects = this._getValidSelectedObjectsIds(validateFunc, validateError);
|
var topicsIds = this.getModel().filterTopicsIds(validateFunc, validateError);
|
||||||
var topicsIds = validSelectedObjects.nodes;
|
|
||||||
|
|
||||||
if (topicsIds.length > 0) {
|
if (topicsIds.length > 0) {
|
||||||
this._actionDispatcher.changeShapeToTopic(topicsIds, shape);
|
this._actionDispatcher.changeShapeToTopic(topicsIds, shape);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
changeFontWeight : function() {
|
changeFontWeight : function() {
|
||||||
var validSelectedObjects = this._getValidSelectedObjectsIds();
|
var topicsIds = this.getModel().filterTopicsIds();
|
||||||
var topicsIds = validSelectedObjects.nodes;
|
|
||||||
if (topicsIds.length > 0) {
|
if (topicsIds.length > 0) {
|
||||||
this._actionDispatcher.changeFontWeightToTopic(topicsIds);
|
this._actionDispatcher.changeFontWeightToTopic(topicsIds);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
addIconType : function(iconType) {
|
addIconType : function(iconType) {
|
||||||
var validSelectedObjects = this._getValidSelectedObjectsIds();
|
var topicsIds = this.getModel().filterTopicsIds();
|
||||||
var topicsIds = validSelectedObjects.nodes;
|
|
||||||
if (topicsIds.length > 0) {
|
if (topicsIds.length > 0) {
|
||||||
this._actionDispatcher.addIconToTopic(topicsIds[0], iconType);
|
this._actionDispatcher.addIconToTopic(topicsIds[0], iconType);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
addLink2Node : function(url) {
|
addLink2Node : function(url) {
|
||||||
var validSelectedObjects = this._getValidSelectedObjectsIds();
|
var topicsIds = this.getModel().filterTopicsIds();
|
||||||
var topicsIds = validSelectedObjects.nodes;
|
|
||||||
if (topicsIds.length > 0) {
|
if (topicsIds.length > 0) {
|
||||||
this._actionDispatcher.addLinkToTopic(topicsIds[0], url);
|
this._actionDispatcher.addLinkToTopic(topicsIds[0], url);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
addLink : function() {
|
addLink : function() {
|
||||||
var selectedTopics = this.getSelectedNodes();
|
var selectedTopics = this.getModel().filterSelectedTopics();
|
||||||
var topic = null;
|
var topic = null;
|
||||||
if (selectedTopics.length > 0) {
|
if (selectedTopics.length > 0) {
|
||||||
topic = selectedTopics[0];
|
topic = selectedTopics[0];
|
||||||
@ -820,15 +761,14 @@ mindplot.MindmapDesigner = new Class({
|
|||||||
},
|
},
|
||||||
|
|
||||||
addNote2Node : function(text) {
|
addNote2Node : function(text) {
|
||||||
var validSelectedObjects = this._getValidSelectedObjectsIds();
|
var topicsIds = this.getModel().filterTopicsIds();
|
||||||
var topicsIds = validSelectedObjects.nodes;
|
|
||||||
if (topicsIds.length > 0) {
|
if (topicsIds.length > 0) {
|
||||||
this._actionDispatcher.addNoteToTopic(topicsIds[0], text);
|
this._actionDispatcher.addNoteToTopic(topicsIds[0], text);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
addNote : function() {
|
addNote : function() {
|
||||||
var selectedTopics = this.getSelectedNodes();
|
var selectedTopics = this.getModel().filterSelectedTopics();
|
||||||
var topic = null;
|
var topic = null;
|
||||||
if (selectedTopics.length > 0) {
|
if (selectedTopics.length > 0) {
|
||||||
topic = selectedTopics[0];
|
topic = selectedTopics[0];
|
||||||
@ -870,35 +810,6 @@ mindplot.MindmapDesigner = new Class({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
getSelectedNodes : function() {
|
|
||||||
var result = new Array();
|
|
||||||
for (var i = 0; i < this._topics.length; i++) {
|
|
||||||
if (this._topics[i].isOnFocus()) {
|
|
||||||
result.push(this._topics[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
},
|
|
||||||
|
|
||||||
getSelectedRelationshipLines : function() {
|
|
||||||
var result = new Array();
|
|
||||||
for (var id in this._relationships) {
|
|
||||||
var relationship = this._relationships[id];
|
|
||||||
if (relationship.isOnFocus()) {
|
|
||||||
result.push(relationship);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
},
|
|
||||||
|
|
||||||
getObjects : function() {
|
|
||||||
var result = [].append(this._topics);
|
|
||||||
for (var id in this._relationships) {
|
|
||||||
result.push(this._relationships[id]);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
},
|
|
||||||
|
|
||||||
goToNode : function(node) {
|
goToNode : function(node) {
|
||||||
node.setOnFocus(true);
|
node.setOnFocus(true);
|
||||||
this.onObjectFocusEvent(node);
|
this.onObjectFocusEvent(node);
|
||||||
|
@ -21,12 +21,12 @@ mindplot.commands.AddIconToTopicCommand = new Class({
|
|||||||
initialize: function(topicId, iconType) {
|
initialize: function(topicId, iconType) {
|
||||||
$assert(topicId, 'topicId can not be null');
|
$assert(topicId, 'topicId can not be null');
|
||||||
$assert(iconType, 'iconType can not be null');
|
$assert(iconType, 'iconType can not be null');
|
||||||
this._selectedObjectsIds = topicId;
|
this._objectsIds = topicId;
|
||||||
this._iconType = iconType;
|
this._iconType = iconType;
|
||||||
},
|
},
|
||||||
|
|
||||||
execute: function(commandContext) {
|
execute: function(commandContext) {
|
||||||
var topic = commandContext.findTopics(this._selectedObjectsIds)[0];
|
var topic = commandContext.findTopics(this._objectsIds)[0];
|
||||||
var updated = function() {
|
var updated = function() {
|
||||||
var iconImg = topic.addIcon(this._iconType, commandContext._designer);
|
var iconImg = topic.addIcon(this._iconType, commandContext._designer);
|
||||||
this._iconModel = iconImg.getModel();
|
this._iconModel = iconImg.getModel();
|
||||||
@ -36,7 +36,7 @@ mindplot.commands.AddIconToTopicCommand = new Class({
|
|||||||
},
|
},
|
||||||
|
|
||||||
undoExecute: function(commandContext) {
|
undoExecute: function(commandContext) {
|
||||||
var topic = commandContext.findTopics(this._selectedObjectsIds)[0];
|
var topic = commandContext.findTopics(this._objectsIds)[0];
|
||||||
var updated = function() {
|
var updated = function() {
|
||||||
topic.removeIcon(this._iconModel);
|
topic.removeIcon(this._iconModel);
|
||||||
topic.updateNode();
|
topic.updateNode();
|
||||||
|
@ -20,12 +20,12 @@ mindplot.commands.AddLinkToTopicCommand = new Class({
|
|||||||
Extends:mindplot.Command,
|
Extends:mindplot.Command,
|
||||||
initialize: function(topicId, url) {
|
initialize: function(topicId, url) {
|
||||||
$assert(topicId, 'topicId can not be null');
|
$assert(topicId, 'topicId can not be null');
|
||||||
this._selectedObjectsIds = topicId;
|
this._objectsIds = topicId;
|
||||||
this._url = url;
|
this._url = url;
|
||||||
this._id = mindplot.Command._nextUUID();
|
this._id = mindplot.Command._nextUUID();
|
||||||
},
|
},
|
||||||
execute: function(commandContext) {
|
execute: function(commandContext) {
|
||||||
var topic = commandContext.findTopics(this._selectedObjectsIds)[0];
|
var topic = commandContext.findTopics(this._objectsIds)[0];
|
||||||
var updated = function() {
|
var updated = function() {
|
||||||
topic.addLink(this._url, commandContext._designer);
|
topic.addLink(this._url, commandContext._designer);
|
||||||
topic.updateNode();
|
topic.updateNode();
|
||||||
@ -33,7 +33,7 @@ mindplot.commands.AddLinkToTopicCommand = new Class({
|
|||||||
updated.delay(0);
|
updated.delay(0);
|
||||||
},
|
},
|
||||||
undoExecute: function(commandContext) {
|
undoExecute: function(commandContext) {
|
||||||
var topic = commandContext.findTopics(this._selectedObjectsIds)[0];
|
var topic = commandContext.findTopics(this._objectsIds)[0];
|
||||||
var updated = function() {
|
var updated = function() {
|
||||||
topic.removeLink();
|
topic.removeLink();
|
||||||
}.bind(this);
|
}.bind(this);
|
||||||
|
@ -20,12 +20,12 @@ mindplot.commands.AddNoteToTopicCommand = new Class({
|
|||||||
Extends:mindplot.Command,
|
Extends:mindplot.Command,
|
||||||
initialize: function(topicId, text) {
|
initialize: function(topicId, text) {
|
||||||
$assert(topicId, 'topicId can not be null');
|
$assert(topicId, 'topicId can not be null');
|
||||||
this._selectedObjectsIds = topicId;
|
this._objectsIds = topicId;
|
||||||
this._text = text;
|
this._text = text;
|
||||||
this._id = mindplot.Command._nextUUID();
|
this._id = mindplot.Command._nextUUID();
|
||||||
},
|
},
|
||||||
execute: function(commandContext) {
|
execute: function(commandContext) {
|
||||||
var topic = commandContext.findTopics(this._selectedObjectsIds)[0];
|
var topic = commandContext.findTopics(this._objectsIds)[0];
|
||||||
var updated = function() {
|
var updated = function() {
|
||||||
topic.addNote(this._text, commandContext._designer);
|
topic.addNote(this._text, commandContext._designer);
|
||||||
topic.updateNode();
|
topic.updateNode();
|
||||||
@ -33,7 +33,7 @@ mindplot.commands.AddNoteToTopicCommand = new Class({
|
|||||||
updated.delay(0);
|
updated.delay(0);
|
||||||
},
|
},
|
||||||
undoExecute: function(commandContext) {
|
undoExecute: function(commandContext) {
|
||||||
var topic = commandContext.findTopics(this._selectedObjectsIds)[0];
|
var topic = commandContext.findTopics(this._objectsIds)[0];
|
||||||
var updated = function() {
|
var updated = function() {
|
||||||
topic.removeNote();
|
topic.removeNote();
|
||||||
}.bind(this);
|
}.bind(this);
|
||||||
|
@ -16,18 +16,19 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
mindplot.commands.DeleteTopicCommand = new Class({
|
mindplot.commands.DeleteCommand = new Class({
|
||||||
Extends:mindplot.Command,
|
Extends:mindplot.Command,
|
||||||
initialize: function(topicsIds) {
|
initialize: function(objectIds) {
|
||||||
$assert(topicsIds, "topicsIds must be defined");
|
$assert(objectIds, "objectIds must be defined");
|
||||||
this._selectedObjectsIds = topicsIds;
|
this._objectsIds = objectIds;
|
||||||
this._deletedTopicModels = [];
|
this._deletedTopicModels = [];
|
||||||
this._parentTopicIds = [];
|
this._parentTopicIds = [];
|
||||||
this._deletedRelationships = [];
|
this._deletedRelationships = [];
|
||||||
this._id = mindplot.Command._nextUUID();
|
this._id = mindplot.Command._nextUUID();
|
||||||
},
|
},
|
||||||
|
|
||||||
execute: function(commandContext) {
|
execute: function(commandContext) {
|
||||||
var topics = commandContext.findTopics(this._selectedObjectsIds.nodes);
|
var topics = commandContext.findTopics(this._objectsIds.nodes);
|
||||||
if (topics.length > 0) {
|
if (topics.length > 0) {
|
||||||
topics.forEach(
|
topics.forEach(
|
||||||
function(topic, index) {
|
function(topic, index) {
|
||||||
@ -57,7 +58,7 @@ mindplot.commands.DeleteTopicCommand = new Class({
|
|||||||
}.bind(this)
|
}.bind(this)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
var lines = commandContext.findRelationships(this._selectedObjectsIds.relationshipLines);
|
var lines = commandContext.findRelationships(this._objectsIds.relationship);
|
||||||
if (lines.length > 0) {
|
if (lines.length > 0) {
|
||||||
lines.forEach(function(line, index) {
|
lines.forEach(function(line, index) {
|
||||||
if (line.isInWorkspace()) {
|
if (line.isInWorkspace()) {
|
||||||
@ -69,7 +70,7 @@ mindplot.commands.DeleteTopicCommand = new Class({
|
|||||||
},
|
},
|
||||||
undoExecute: function(commandContext) {
|
undoExecute: function(commandContext) {
|
||||||
|
|
||||||
var topics = commandContext.findTopics(this._selectedObjectsIds);
|
var topics = commandContext.findTopics(this._objectsIds);
|
||||||
var parent = commandContext.findTopics(this._parentTopicIds);
|
var parent = commandContext.findTopics(this._parentTopicIds);
|
||||||
|
|
||||||
this._deletedTopicModels.forEach(
|
this._deletedTopicModels.forEach(
|
@ -21,7 +21,7 @@ mindplot.commands.DragTopicCommand = new Class({
|
|||||||
initialize: function(topicIds, position, order, parentTopic) {
|
initialize: function(topicIds, position, order, parentTopic) {
|
||||||
$assert(topicIds, "topicIds must be defined");
|
$assert(topicIds, "topicIds must be defined");
|
||||||
|
|
||||||
this._selectedObjectsIds = topicIds;
|
this._objectsIds = topicIds;
|
||||||
if ($defined(parentTopic))
|
if ($defined(parentTopic))
|
||||||
this._parentId = parentTopic.getId();
|
this._parentId = parentTopic.getId();
|
||||||
|
|
||||||
@ -31,7 +31,7 @@ mindplot.commands.DragTopicCommand = new Class({
|
|||||||
},
|
},
|
||||||
execute: function(commandContext) {
|
execute: function(commandContext) {
|
||||||
|
|
||||||
var topic = commandContext.findTopics([this._selectedObjectsIds])[0];
|
var topic = commandContext.findTopics([this._objectsIds])[0];
|
||||||
|
|
||||||
// Save old position ...
|
// Save old position ...
|
||||||
var origParentTopic = topic.getOutgoingConnectedTopic();
|
var origParentTopic = topic.getOutgoingConnectedTopic();
|
||||||
@ -80,7 +80,7 @@ mindplot.commands.DragTopicCommand = new Class({
|
|||||||
},
|
},
|
||||||
undoExecute: function(commandContext) {
|
undoExecute: function(commandContext) {
|
||||||
this.execute(commandContext);
|
this.execute(commandContext);
|
||||||
var selectedRelationships = commandContext.getSelectedRelationshipLines();
|
var selectedRelationships = commandContext.filterSelectedRelations();
|
||||||
selectedRelationships.forEach(function(relationshipLine) {
|
selectedRelationships.forEach(function(relationshipLine) {
|
||||||
relationshipLine.redraw();
|
relationshipLine.redraw();
|
||||||
});
|
});
|
||||||
|
@ -23,14 +23,14 @@ mindplot.commands.GenericFunctionCommand = new Class({
|
|||||||
$assert(topicsIds, "topicsIds must be defined");
|
$assert(topicsIds, "topicsIds must be defined");
|
||||||
|
|
||||||
this._value = value;
|
this._value = value;
|
||||||
this._selectedObjectsIds = topicsIds;
|
this._objectsIds = topicsIds;
|
||||||
this._commandFunc = commandFunc;
|
this._commandFunc = commandFunc;
|
||||||
this._oldValues = [];
|
this._oldValues = [];
|
||||||
this._id = mindplot.Command._nextUUID();
|
this._id = mindplot.Command._nextUUID();
|
||||||
},
|
},
|
||||||
execute: function(commandContext) {
|
execute: function(commandContext) {
|
||||||
if (!this.applied) {
|
if (!this.applied) {
|
||||||
var topics = commandContext.findTopics(this._selectedObjectsIds);
|
var topics = commandContext.findTopics(this._objectsIds);
|
||||||
topics.forEach(function(topic) {
|
topics.forEach(function(topic) {
|
||||||
var oldValue = this._commandFunc(topic, this._value);
|
var oldValue = this._commandFunc(topic, this._value);
|
||||||
this._oldValues.push(oldValue);
|
this._oldValues.push(oldValue);
|
||||||
@ -43,7 +43,7 @@ mindplot.commands.GenericFunctionCommand = new Class({
|
|||||||
},
|
},
|
||||||
undoExecute: function(commandContext) {
|
undoExecute: function(commandContext) {
|
||||||
if (this.applied) {
|
if (this.applied) {
|
||||||
var topics = commandContext.findTopics(this._selectedObjectsIds);
|
var topics = commandContext.findTopics(this._objectsIds);
|
||||||
topics.forEach(function(topic, index) {
|
topics.forEach(function(topic, index) {
|
||||||
this._commandFunc(topic, this._oldValues[index]);
|
this._commandFunc(topic, this._oldValues[index]);
|
||||||
|
|
||||||
|
@ -22,12 +22,12 @@ mindplot.commands.RemoveIconFromTopicCommand = new Class({
|
|||||||
{
|
{
|
||||||
$assert(topicId, 'topicId can not be null');
|
$assert(topicId, 'topicId can not be null');
|
||||||
$assert(iconModel, 'iconId can not be null');
|
$assert(iconModel, 'iconId can not be null');
|
||||||
this._selectedObjectsIds = topicId;
|
this._objectsIds = topicId;
|
||||||
this._iconModel = iconModel;
|
this._iconModel = iconModel;
|
||||||
},
|
},
|
||||||
execute: function(commandContext)
|
execute: function(commandContext)
|
||||||
{
|
{
|
||||||
var topic = commandContext.findTopics(this._selectedObjectsIds)[0];
|
var topic = commandContext.findTopics(this._objectsIds)[0];
|
||||||
var updated = function() {
|
var updated = function() {
|
||||||
topic.removeIcon(this._iconModel);
|
topic.removeIcon(this._iconModel);
|
||||||
topic.updateNode();
|
topic.updateNode();
|
||||||
@ -36,7 +36,7 @@ mindplot.commands.RemoveIconFromTopicCommand = new Class({
|
|||||||
},
|
},
|
||||||
undoExecute: function(commandContext)
|
undoExecute: function(commandContext)
|
||||||
{
|
{
|
||||||
var topic = commandContext.findTopics(this._selectedObjectsIds)[0];
|
var topic = commandContext.findTopics(this._objectsIds)[0];
|
||||||
var updated = function() {
|
var updated = function() {
|
||||||
var iconType = this._iconModel.getIconType();
|
var iconType = this._iconModel.getIconType();
|
||||||
var iconImg = topic.addIcon(iconType, commandContext._designer);
|
var iconImg = topic.addIcon(iconType, commandContext._designer);
|
||||||
|
@ -20,10 +20,10 @@ mindplot.commands.RemoveLinkFromTopicCommand = new Class({
|
|||||||
Extends:mindplot.Command,
|
Extends:mindplot.Command,
|
||||||
initialize: function(topicId) {
|
initialize: function(topicId) {
|
||||||
$assert(topicId, 'topicId can not be null');
|
$assert(topicId, 'topicId can not be null');
|
||||||
this._selectedObjectsIds = topicId;
|
this._objectsIds = topicId;
|
||||||
},
|
},
|
||||||
execute: function(commandContext) {
|
execute: function(commandContext) {
|
||||||
var topic = commandContext.findTopics(this._selectedObjectsIds)[0];
|
var topic = commandContext.findTopics(this._objectsIds)[0];
|
||||||
this._url = topic._link.getUrl();
|
this._url = topic._link.getUrl();
|
||||||
var updated = function() {
|
var updated = function() {
|
||||||
topic.removeLink();
|
topic.removeLink();
|
||||||
@ -31,7 +31,7 @@ mindplot.commands.RemoveLinkFromTopicCommand = new Class({
|
|||||||
updated.delay(0);
|
updated.delay(0);
|
||||||
},
|
},
|
||||||
undoExecute: function(commandContext) {
|
undoExecute: function(commandContext) {
|
||||||
var topic = commandContext.findTopics(this._selectedObjectsIds)[0];
|
var topic = commandContext.findTopics(this._objectsIds)[0];
|
||||||
var updated = function() {
|
var updated = function() {
|
||||||
topic.addLink(this._url, commandContext._designer);
|
topic.addLink(this._url, commandContext._designer);
|
||||||
topic.updateNode();
|
topic.updateNode();
|
||||||
|
@ -21,11 +21,11 @@ mindplot.commands.RemoveNoteFromTopicCommand = new Class({
|
|||||||
initialize: function(topicId)
|
initialize: function(topicId)
|
||||||
{
|
{
|
||||||
$assert(topicId, 'topicId can not be null');
|
$assert(topicId, 'topicId can not be null');
|
||||||
this._selectedObjectsIds = topicId;
|
this._objectsIds = topicId;
|
||||||
},
|
},
|
||||||
execute: function(commandContext)
|
execute: function(commandContext)
|
||||||
{
|
{
|
||||||
var topic = commandContext.findTopics(this._selectedObjectsIds)[0];
|
var topic = commandContext.findTopics(this._objectsIds)[0];
|
||||||
this._text = topic._note.getText();
|
this._text = topic._note.getText();
|
||||||
var updated = function() {
|
var updated = function() {
|
||||||
topic.removeNote();
|
topic.removeNote();
|
||||||
@ -34,7 +34,7 @@ mindplot.commands.RemoveNoteFromTopicCommand = new Class({
|
|||||||
},
|
},
|
||||||
undoExecute: function(commandContext)
|
undoExecute: function(commandContext)
|
||||||
{
|
{
|
||||||
var topic = commandContext.findTopics(this._selectedObjectsIds)[0];
|
var topic = commandContext.findTopics(this._objectsIds)[0];
|
||||||
var updated = function() {
|
var updated = function() {
|
||||||
topic.addNote(this._text,commandContext._designer);
|
topic.addNote(this._text,commandContext._designer);
|
||||||
topic.updateNode();
|
topic.updateNode();
|
||||||
|
@ -79,7 +79,7 @@ mindplot.layout.OriginalLayoutManager = new Class({
|
|||||||
_buildDragManager: function(workspace) {
|
_buildDragManager: function(workspace) {
|
||||||
// Init dragger manager.
|
// Init dragger manager.
|
||||||
var dragger = new mindplot.DragManager(workspace);
|
var dragger = new mindplot.DragManager(workspace);
|
||||||
var topics = this.getDesigner()._getTopics();
|
var topics = this.getDesigner().getModel().getTopics();
|
||||||
|
|
||||||
var dragTopicPositioner = this.getDragTopicPositioner();
|
var dragTopicPositioner = this.getDragTopicPositioner();
|
||||||
|
|
||||||
|
@ -28,8 +28,8 @@ mindplot.layout.boards.freemind.Board = mindplot.layout.boards.Board.extend({
|
|||||||
var result = this.findNewNodeEntryIndex(entry);
|
var result = this.findNewNodeEntryIndex(entry);
|
||||||
|
|
||||||
// if creating a sibling or child
|
// if creating a sibling or child
|
||||||
if(!this._layoutManager._isMovingNode && this._layoutManager.getDesigner().getSelectedNodes().length>0){
|
if(!this._layoutManager._isMovingNode && this._layoutManager.getDesigner().filterSelectedTopics().length>0){
|
||||||
var selectedNode = this._layoutManager.getDesigner().getSelectedNodes()[0];
|
var selectedNode = this._layoutManager.getDesigner().filterSelectedTopics()[0];
|
||||||
if(!$defined(pos)){
|
if(!$defined(pos)){
|
||||||
if(selectedNode.getParent()!= null && node.getParent().getId() == selectedNode.getParent().getId()){
|
if(selectedNode.getParent()!= null && node.getParent().getId() == selectedNode.getParent().getId()){
|
||||||
//creating a sibling - Lets put the new node below the selected node.
|
//creating a sibling - Lets put the new node below the selected node.
|
||||||
|
@ -40,9 +40,10 @@ mindplot.widget.Menu = new Class({
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Create panels ...
|
// Create panels ...
|
||||||
|
var designerModel = designer.getModel();
|
||||||
var fontFamilyModel = {
|
var fontFamilyModel = {
|
||||||
getValue: function() {
|
getValue: function() {
|
||||||
var nodes = designer.getSelectedNodes();
|
var nodes = designerModel.filterSelectedTopics();
|
||||||
var result = null;
|
var result = null;
|
||||||
for (var i = 0; i < nodes.length; i++) {
|
for (var i = 0; i < nodes.length; i++) {
|
||||||
var fontFamily = nodes[i].getFontFamily();
|
var fontFamily = nodes[i].getFontFamily();
|
||||||
@ -64,7 +65,7 @@ mindplot.widget.Menu = new Class({
|
|||||||
|
|
||||||
var fontSizeModel = {
|
var fontSizeModel = {
|
||||||
getValue: function() {
|
getValue: function() {
|
||||||
var nodes = designer.getSelectedNodes();
|
var nodes = designerModel.filterSelectedTopics();
|
||||||
var result = null;
|
var result = null;
|
||||||
for (var i = 0; i < nodes.length; i++) {
|
for (var i = 0; i < nodes.length; i++) {
|
||||||
var fontSize = nodes[i].getFontSize();
|
var fontSize = nodes[i].getFontSize();
|
||||||
@ -84,7 +85,7 @@ mindplot.widget.Menu = new Class({
|
|||||||
|
|
||||||
var topicShapeModel = {
|
var topicShapeModel = {
|
||||||
getValue: function() {
|
getValue: function() {
|
||||||
var nodes = designer.getSelectedNodes();
|
var nodes = designerModel.filterSelectedTopics();
|
||||||
var result = null;
|
var result = null;
|
||||||
for (var i = 0; i < nodes.length; i++) {
|
for (var i = 0; i < nodes.length; i++) {
|
||||||
var shapeType = nodes[i].getShapeType();
|
var shapeType = nodes[i].getShapeType();
|
||||||
@ -117,7 +118,7 @@ mindplot.widget.Menu = new Class({
|
|||||||
var topicColorModel =
|
var topicColorModel =
|
||||||
{
|
{
|
||||||
getValue : function() {
|
getValue : function() {
|
||||||
var nodes = designer.getSelectedNodes();
|
var nodes = designerModel.filterSelectedTopics();
|
||||||
var result = null;
|
var result = null;
|
||||||
for (var i = 0; i < nodes.length; i++) {
|
for (var i = 0; i < nodes.length; i++) {
|
||||||
var color = nodes[i].getBackgroundColor();
|
var color = nodes[i].getBackgroundColor();
|
||||||
@ -139,7 +140,7 @@ mindplot.widget.Menu = new Class({
|
|||||||
var borderColorModel =
|
var borderColorModel =
|
||||||
{
|
{
|
||||||
getValue : function() {
|
getValue : function() {
|
||||||
var nodes = designer.getSelectedNodes();
|
var nodes = designerModel.filterSelectedTopics();
|
||||||
var result = null;
|
var result = null;
|
||||||
for (var i = 0; i < nodes.length; i++) {
|
for (var i = 0; i < nodes.length; i++) {
|
||||||
var color = nodes[i].getBorderColor();
|
var color = nodes[i].getBorderColor();
|
||||||
@ -162,7 +163,7 @@ mindplot.widget.Menu = new Class({
|
|||||||
{
|
{
|
||||||
getValue : function() {
|
getValue : function() {
|
||||||
var result = null;
|
var result = null;
|
||||||
var nodes = designer.getSelectedNodes();
|
var nodes = designerModel.filterSelectedTopics();
|
||||||
for (var i = 0; i < nodes.length; i++) {
|
for (var i = 0; i < nodes.length; i++) {
|
||||||
var color = nodes[i].getFontColor();
|
var color = nodes[i].getFontColor();
|
||||||
if (result != null && result != color) {
|
if (result != null && result != color) {
|
||||||
|
@ -89,9 +89,9 @@ TestCase("Mindplot test",{
|
|||||||
var centralTopic = designer.getCentralTopic();
|
var centralTopic = designer.getCentralTopic();
|
||||||
assertNotNull(centralTopic);
|
assertNotNull(centralTopic);
|
||||||
var target = designer.getWorkSpace().getScreenManager().getContainer();
|
var target = designer.getWorkSpace().getScreenManager().getContainer();
|
||||||
var size = designer._getTopics().length;
|
var size = designer.getModel().getTopics().length;
|
||||||
fireNativeEvent('dblclick',target,new core.Point(50,50));
|
fireNativeEvent('dblclick',target,new core.Point(50,50));
|
||||||
assertEquals(size+1, designer._getTopics().length);
|
assertEquals(size+1, designer.getModel().getTopics().length);
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -309,7 +309,7 @@ function buildMindmapDesigner() {
|
|||||||
var screenWidth = window.getWidth();
|
var screenWidth = window.getWidth();
|
||||||
var screenHeight = window.getHeight();
|
var screenHeight = window.getHeight();
|
||||||
|
|
||||||
// Positionate node ...
|
// Position node ...
|
||||||
// header - footer
|
// header - footer
|
||||||
screenHeight = screenHeight - 90 - 61;
|
screenHeight = screenHeight - 90 - 61;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user