Merge branch 'wise-doc' into collaboration
Conflicts: mindplot/pom.xml mindplot/src/main/javascript/DesignerActionRunner.js mindplot/src/main/javascript/DragTopic.js mindplot/src/main/javascript/MindmapDesigner.js wise-doc/src/main/webapp/html/editor.html wise-doc/src/main/webapp/js/editor.js
This commit is contained in:
116
mindplot/src/main/javascript/ActionDispatcher.js
Normal file
116
mindplot/src/main/javascript/ActionDispatcher.js
Normal file
@@ -0,0 +1,116 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
//noinspection JSUnusedLocalSymbols
|
||||
mindplot.ActionDispatcher = new Class({
|
||||
Implements:[Events],
|
||||
initialize: function(commandContext) {
|
||||
$assert(commandContext, "commandContext can not be null");
|
||||
},
|
||||
|
||||
addIconToTopic: function(topicId, iconType) {
|
||||
throw "method must be implemented.";
|
||||
},
|
||||
|
||||
addLinkToTopic: function(topicId, url) {
|
||||
throw "method must be implemented.";
|
||||
},
|
||||
|
||||
addNoteToTopic: function(topicId, text) {
|
||||
throw "method must be implemented.";
|
||||
},
|
||||
|
||||
addRelationship: function(model, mindmap) {
|
||||
throw "method must be implemented.";
|
||||
},
|
||||
|
||||
addTopic: function(model, parentTopicId, animated) {
|
||||
throw "method must be implemented.";
|
||||
},
|
||||
|
||||
deleteTopics: function(topicsIds) {
|
||||
throw "method must be implemented.";
|
||||
},
|
||||
|
||||
dragTopic: function(topicId, position, order, parentTopic) {
|
||||
throw "method must be implemented.";
|
||||
},
|
||||
|
||||
moveControlPoint: function(ctrlPoint, point) {
|
||||
throw "method must be implemented.";
|
||||
},
|
||||
|
||||
removeIconFromTopic: function(topicId, iconModel) {
|
||||
throw "method must be implemented.";
|
||||
},
|
||||
|
||||
removeLinkFromTopic: function(topicId) {
|
||||
throw "method must be implemented.";
|
||||
},
|
||||
|
||||
removeNoteFromTopic: function(topicId) {
|
||||
throw "method must be implemented.";
|
||||
},
|
||||
|
||||
changeFontFamilyToTopic: function(topicIds, fontFamily) {
|
||||
throw "method must be implemented.";
|
||||
},
|
||||
|
||||
changeFontStyleToTopic: function(topicsIds) {
|
||||
throw "method must be implemented.";
|
||||
},
|
||||
|
||||
changeFontColorToTopic: function(topicsIds, color) {
|
||||
throw "method must be implemented.";
|
||||
},
|
||||
|
||||
changeBackgroundColorToTopic: function(topicsIds, color) {
|
||||
throw "method must be implemented.";
|
||||
},
|
||||
|
||||
changeBorderColorToTopic: function(topicsIds, color) {
|
||||
throw "method must be implemented.";
|
||||
},
|
||||
|
||||
changeShapeToTopic : function(topicsIds, shapeType) {
|
||||
throw "method must be implemented.";
|
||||
},
|
||||
|
||||
changeFontWeightToTopic : function(topicsIds) {
|
||||
throw "method must be implemented.";
|
||||
},
|
||||
|
||||
changeTextOnTopic : function(topicsIds, text) {
|
||||
throw "method must be implemented.";
|
||||
},
|
||||
|
||||
shrinkBranch : function(topicsIds, collapse)
|
||||
{
|
||||
throw "method must be implemented.";
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
mindplot.ActionDispatcher.setInstance = function(dispatcher) {
|
||||
mindplot.ActionDispatcher._instance = dispatcher;
|
||||
};
|
||||
|
||||
mindplot.ActionDispatcher.getInstance = function() {
|
||||
return mindplot.ActionDispatcher._instance;
|
||||
};
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
mindplot.ActionIcon = new Class({
|
||||
Extends:mindplot.Icon,
|
||||
initialize: function(topic, url) {
|
||||
mindplot.Icon.call(this, url);
|
||||
this.parent(url);
|
||||
this._node = topic;
|
||||
},
|
||||
getNode:function() {
|
||||
|
||||
@@ -1,51 +0,0 @@
|
||||
/*
|
||||
* 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.BaseCommandDispatcher = new Class({
|
||||
|
||||
initialize: function() {
|
||||
},
|
||||
addIconToTopic: function() {
|
||||
throw "method must be implemented.";
|
||||
},
|
||||
addLinkToTopic: function() {
|
||||
throw "method must be implemented.";
|
||||
},
|
||||
addNoteToTopic: function() {
|
||||
throw "method must be implemented.";
|
||||
},addRelationship: function() {
|
||||
throw "method must be implemented.";
|
||||
},addTopic: function() {
|
||||
throw "method must be implemented.";
|
||||
},changeIcon: function() {
|
||||
throw "method must be implemented.";
|
||||
},deleteTopic: function() {
|
||||
throw "method must be implemented.";
|
||||
},dragTopic: function() {
|
||||
throw "method must be implemented.";
|
||||
},moveControllPoint: function() {
|
||||
throw "method must be implemented.";
|
||||
} ,removeIconFromTopic: function() {
|
||||
throw "method must be implemented.";
|
||||
},removeLinkFromTopic: function() {
|
||||
throw "method must be implemented.";
|
||||
},removeNodeFromTopic: function() {
|
||||
throw "method must be implemented.";
|
||||
}
|
||||
});
|
||||
|
||||
25
mindplot/src/main/javascript/BrixActionDispatcher.js
Normal file
25
mindplot/src/main/javascript/BrixActionDispatcher.js
Normal file
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* 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.BrixActionDispatcher = new Class({
|
||||
Extends: mindplot.ActionDispatcher,
|
||||
initialize: function(commandContext, fireOnChange) {
|
||||
this.parent(commandContext, fireOnChange);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -33,7 +33,7 @@ mindplot.CentralTopic = new Class({
|
||||
|
||||
setCursor : function(type) {
|
||||
type = (type == 'move') ? 'default' : type;
|
||||
mindplot.Topic.prototype.setCursor.call(this, type);
|
||||
this.parent(type);
|
||||
},
|
||||
|
||||
isConnectedToCentralTopic : function() {
|
||||
|
||||
@@ -113,8 +113,10 @@ mindplot.ControlPoint = new Class({
|
||||
_mouseUp : function(event, point) {
|
||||
this._workspace.getScreenManager().removeEventListener('mousemove', this._mouseMoveFunction);
|
||||
this._workspace.getScreenManager().removeEventListener('mouseup', this._mouseUpFunction);
|
||||
var command = new mindplot.commands.MoveControlPointCommand(this, point);
|
||||
designer._actionRunner.execute(command); //todo:Uggly!! designer is global!!
|
||||
|
||||
var actionDispatcher = mindplot.ActionDispatcher.getInstance();
|
||||
actionDispatcher.moveControlPoint(this, point);
|
||||
|
||||
this._isBinded = false;
|
||||
/*event.preventDefault();
|
||||
event.stop();
|
||||
|
||||
@@ -17,40 +17,34 @@
|
||||
*/
|
||||
|
||||
mindplot.DesignerActionRunner = new Class({
|
||||
initialize: function(designer) {
|
||||
this._designer = designer;
|
||||
initialize: function(commandContext, notifier) {
|
||||
$assert(commandContext, "commandContext 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() {
|
||||
@@ -60,75 +54,3 @@ mindplot.DesignerActionRunner = new Class({
|
||||
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.model.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();
|
||||
}
|
||||
});
|
||||
|
||||
mindplot.DesignerActionRunner.setInstance = function(actionRunner) {
|
||||
mindplot.DesignerActionRunner._instance = actionRunner;
|
||||
};
|
||||
|
||||
mindplot.DesignerActionRunner.getInstance = function() {
|
||||
return mindplot.DesignerActionRunner._instance;
|
||||
};
|
||||
|
||||
@@ -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};
|
||||
},
|
||||
|
||||
|
||||
@@ -201,8 +201,11 @@ mindplot.DragPivot = new Class({
|
||||
// Connected to Rect ...
|
||||
var connectRect = this._connectRect;
|
||||
var targetSize = targetTopic.getSize();
|
||||
var width = targetSize.width;
|
||||
var height = targetSize.height;
|
||||
|
||||
// Add 4 pixel in order to keep create a rect bigger than the topic.
|
||||
var width = targetSize.width + 4;
|
||||
var height = targetSize.height + 4;
|
||||
|
||||
connectRect.setSize(width, height);
|
||||
|
||||
var targetPosition = targetTopic.getPosition();
|
||||
|
||||
@@ -1,239 +1,203 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
* 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.DragTopic = function(dragShape, draggedNode)
|
||||
{
|
||||
$assert(dragShape, 'Rect can not be null.');
|
||||
$assert(draggedNode, 'draggedNode can not be null.');
|
||||
mindplot.DragTopic = new Class({
|
||||
initialize:function(dragShape, draggedNode) {
|
||||
$assert(dragShape, 'Rect can not be null.');
|
||||
$assert(draggedNode, 'draggedNode can not be null.');
|
||||
|
||||
this._elem2d = dragShape;
|
||||
this._order = null;
|
||||
this._draggedNode = draggedNode;
|
||||
this._position = new core.Point();
|
||||
};
|
||||
this._elem2d = dragShape;
|
||||
this._order = null;
|
||||
this._draggedNode = draggedNode;
|
||||
this._position = new core.Point();
|
||||
},
|
||||
|
||||
mindplot.DragTopic.initialize = function(workspace)
|
||||
{
|
||||
setOrder : function(order) {
|
||||
this._order = order;
|
||||
},
|
||||
|
||||
setPosition : function(x, y) {
|
||||
this._position.setValue(x, y);
|
||||
|
||||
// Elements are positioned in the center.
|
||||
// All topic element must be positioned based on the innerShape.
|
||||
var draggedNode = this._draggedNode;
|
||||
var size = draggedNode.getSize();
|
||||
|
||||
var cx = Math.ceil(x - (size.width / 2));
|
||||
var cy = Math.ceil(y - (size.height / 2));
|
||||
|
||||
// Update visual position.
|
||||
this._elem2d.setPosition(cx, cy);
|
||||
},
|
||||
|
||||
getInnerShape : function() {
|
||||
return this._elem2d;
|
||||
},
|
||||
|
||||
disconnect : function(workspace) {
|
||||
// Clear connection line ...
|
||||
var dragPivot = this._getDragPivot();
|
||||
dragPivot.disconnect(workspace);
|
||||
},
|
||||
|
||||
canBeConnectedTo : function(targetTopic) {
|
||||
$assert(targetTopic, 'parent can not be null');
|
||||
|
||||
var result = true;
|
||||
if (!targetTopic.areChildrenShrinked() && !targetTopic.isCollapsed()) {
|
||||
// Dragged node can not be connected to himself.
|
||||
if (targetTopic == this._draggedNode) {
|
||||
result = false;
|
||||
} else {
|
||||
var draggedNode = this.getDraggedTopic();
|
||||
var topicPosition = this.getPosition();
|
||||
|
||||
var targetTopicModel = targetTopic.getModel();
|
||||
var childTopicModel = draggedNode.getModel();
|
||||
|
||||
result = targetTopicModel.canBeConnected(childTopicModel, topicPosition, 18);
|
||||
}
|
||||
} else {
|
||||
result = false;
|
||||
}
|
||||
return result;
|
||||
},
|
||||
|
||||
connectTo : function(parent) {
|
||||
$assert(parent, 'Parent connection node can not be null.');
|
||||
|
||||
var dragPivot = this._getDragPivot();
|
||||
dragPivot.connectTo(parent);
|
||||
},
|
||||
|
||||
getDraggedTopic : function() {
|
||||
return this._draggedNode;
|
||||
},
|
||||
|
||||
|
||||
removeFromWorkspace : function(workspace) {
|
||||
// Remove drag shadow.
|
||||
workspace.removeChild(this._elem2d);
|
||||
|
||||
// Remove pivot shape. To improve performace it will not be removed. Only the visilility will be changed.
|
||||
var dragPivot = this._getDragPivot();
|
||||
dragPivot.setVisibility(false);
|
||||
},
|
||||
|
||||
addToWorkspace : function(workspace) {
|
||||
workspace.appendChild(this._elem2d);
|
||||
var dragPivot = this._getDragPivot();
|
||||
|
||||
dragPivot.addToWorkspace(workspace);
|
||||
dragPivot.setVisibility(true);
|
||||
},
|
||||
|
||||
_getDragPivot : function() {
|
||||
return mindplot.DragTopic.__getDragPivot();
|
||||
},
|
||||
|
||||
getPosition:function() {
|
||||
return this._position;
|
||||
}
|
||||
,
|
||||
|
||||
isDragTopic : function() {
|
||||
return true;
|
||||
},
|
||||
|
||||
updateDraggedTopic : function(workspace) {
|
||||
$assert(workspace, 'workspace can not be null');
|
||||
|
||||
var dragPivot = this._getDragPivot();
|
||||
var draggedTopic = this.getDraggedTopic();
|
||||
|
||||
var isDragConnected = this.isConnected();
|
||||
// @Todo: Remove this static ...
|
||||
var actionDispatcher = mindplot.ActionDispatcher.getInstance();
|
||||
var topicId = draggedTopic.getId();
|
||||
|
||||
if (isDragConnected) {
|
||||
|
||||
var targetTopic = this.getConnectedToTopic();
|
||||
if (targetTopic.getType() == mindplot.NodeModel.CENTRAL_TOPIC_TYPE) {
|
||||
// Update topic position ...
|
||||
var dragPivotPosition = dragPivot.getPosition();
|
||||
|
||||
// Must position the dragged topic taking into account the current node size.
|
||||
var pivotSize = dragPivot.getSize();
|
||||
var draggedTopicSize = draggedTopic.getSize();
|
||||
var xOffset = draggedTopicSize.width - pivotSize.width;
|
||||
xOffset = Math.round(xOffset / 2);
|
||||
|
||||
if (dragPivotPosition.x > 0) {
|
||||
dragPivotPosition.x = parseInt(dragPivotPosition.x) + xOffset;
|
||||
}
|
||||
else {
|
||||
dragPivotPosition.x = parseInt(dragPivotPosition.x) - xOffset;
|
||||
}
|
||||
// Set new position ...
|
||||
actionDispatcher.dragTopic(topicId, dragPivotPosition, null, targetTopic);
|
||||
|
||||
} else {
|
||||
// Main topic connections can be positioned only with the order ...
|
||||
actionDispatcher.dragTopic(topicId, null, this._order, targetTopic);
|
||||
}
|
||||
} else {
|
||||
|
||||
// If the node is not connected, positionate based on the original drag topic position.
|
||||
var dragPosition = this.getPosition();
|
||||
actionDispatcher.dragTopic(topicId, dragPosition);
|
||||
}
|
||||
},
|
||||
|
||||
setBoardPosition : function(point) {
|
||||
$assert(point, 'point can not be null');
|
||||
var dragPivot = this._getDragPivot();
|
||||
dragPivot.setPosition(point);
|
||||
},
|
||||
|
||||
getConnectedToTopic : function() {
|
||||
var dragPivot = this._getDragPivot();
|
||||
return dragPivot.getTargetTopic();
|
||||
},
|
||||
|
||||
isConnected : function() {
|
||||
return this.getConnectedToTopic() != null;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
mindplot.DragTopic.PIVOT_SIZE = {width:50,height:10};
|
||||
|
||||
mindplot.DragTopic.init = function(workspace) {
|
||||
|
||||
$assert(workspace, "workspace can not be null");
|
||||
var pivot = mindplot.DragTopic.__getDragPivot();
|
||||
workspace.appendChild(pivot);
|
||||
};
|
||||
}
|
||||
|
||||
mindplot.DragTopic.prototype.setOrder = function(order)
|
||||
{
|
||||
this._order = order;
|
||||
};
|
||||
|
||||
mindplot.DragTopic.prototype.setPosition = function(x, y)
|
||||
{
|
||||
this._position.setValue(x, y);
|
||||
|
||||
// Elements are positioned in the center.
|
||||
// All topic element must be positioned based on the innerShape.
|
||||
var draggedNode = this._draggedNode;
|
||||
var size = draggedNode.getSize();
|
||||
|
||||
var cx = Math.ceil(x - (size.width / 2));
|
||||
var cy = Math.ceil(y - (size.height / 2));
|
||||
|
||||
// Update visual position.
|
||||
this._elem2d.setPosition(cx, cy);
|
||||
};
|
||||
|
||||
mindplot.DragTopic.prototype.getInnerShape = function()
|
||||
{
|
||||
return this._elem2d;
|
||||
};
|
||||
|
||||
mindplot.DragTopic.prototype.disconnect = function(workspace)
|
||||
{
|
||||
// Clear connection line ...
|
||||
var dragPivot = this._getDragPivot();
|
||||
dragPivot.disconnect(workspace);
|
||||
};
|
||||
|
||||
mindplot.DragTopic.prototype.canBeConnectedTo = function(targetTopic)
|
||||
{
|
||||
$assert(targetTopic, 'parent can not be null');
|
||||
|
||||
var result = true;
|
||||
if (!targetTopic.areChildrenShrinked() && !targetTopic.isCollapsed())
|
||||
{
|
||||
// Dragged node can not be connected to himself.
|
||||
if (targetTopic == this._draggedNode)
|
||||
{
|
||||
result = false;
|
||||
} else
|
||||
{
|
||||
var draggedNode = this.getDraggedTopic();
|
||||
var topicPosition = this.getPosition();
|
||||
|
||||
var targetTopicModel = targetTopic.getModel();
|
||||
var childTopicModel = draggedNode.getModel();
|
||||
|
||||
result = targetTopicModel.canBeConnected(childTopicModel, topicPosition, 18);
|
||||
}
|
||||
} else
|
||||
{
|
||||
result = false;
|
||||
}
|
||||
return result;
|
||||
};
|
||||
|
||||
mindplot.DragTopic.prototype.connectTo = function(parent)
|
||||
{
|
||||
$assert(parent, 'Parent connection node can not be null.');
|
||||
|
||||
var dragPivot = this._getDragPivot();
|
||||
dragPivot.connectTo(parent);
|
||||
};
|
||||
|
||||
mindplot.DragTopic.prototype.getDraggedTopic = function()
|
||||
{
|
||||
return this._draggedNode;
|
||||
};
|
||||
|
||||
|
||||
mindplot.DragTopic.prototype.removeFromWorkspace = function(workspace)
|
||||
{
|
||||
// Remove drag shadow.
|
||||
workspace.removeChild(this._elem2d);
|
||||
|
||||
// Remove pivot shape. To improve performace it will not be removed. Only the visilility will be changed.
|
||||
var dragPivot = this._getDragPivot();
|
||||
dragPivot.setVisibility(false);
|
||||
};
|
||||
|
||||
mindplot.DragTopic.prototype.addToWorkspace = function(workspace)
|
||||
{
|
||||
workspace.appendChild(this._elem2d);
|
||||
var dragPivot = this._getDragPivot();
|
||||
|
||||
dragPivot.addToWorkspace(workspace);
|
||||
dragPivot.setVisibility(true);
|
||||
};
|
||||
|
||||
mindplot.DragTopic.prototype._getDragPivot = function()
|
||||
{
|
||||
return mindplot.DragTopic.__getDragPivot();
|
||||
};
|
||||
|
||||
mindplot.DragTopic.__getDragPivot = function()
|
||||
{
|
||||
mindplot.DragTopic.__getDragPivot = function() {
|
||||
var result = mindplot.DragTopic._dragPivot;
|
||||
if (!$defined(result))
|
||||
{
|
||||
if (!$defined(result)) {
|
||||
result = new mindplot.DragPivot();
|
||||
mindplot.DragTopic._dragPivot = result;
|
||||
}
|
||||
return result;
|
||||
};
|
||||
|
||||
|
||||
mindplot.DragTopic.prototype.getPosition = function()
|
||||
{
|
||||
return this._position;
|
||||
};
|
||||
|
||||
mindplot.DragTopic.prototype.isDragTopic = function()
|
||||
{
|
||||
return true;
|
||||
};
|
||||
|
||||
mindplot.DragTopic.prototype.updateDraggedTopic = function(workspace)
|
||||
{
|
||||
$assert(workspace, 'workspace can not be null');
|
||||
|
||||
var dragPivot = this._getDragPivot();
|
||||
var draggedTopic = this.getDraggedTopic();
|
||||
|
||||
var isDragConnected = this.isConnected();
|
||||
var actionRunner = mindplot.DesignerActionRunner.getInstance();
|
||||
var topicId = draggedTopic.getId();
|
||||
var command = new mindplot.commands.DragTopicCommand(topicId);
|
||||
|
||||
if (isDragConnected)
|
||||
{
|
||||
|
||||
var targetTopic = this.getConnectedToTopic();
|
||||
if (targetTopic.getType() == mindplot.model.NodeModel.CENTRAL_TOPIC_TYPE)
|
||||
{
|
||||
// Update topic position ...
|
||||
var dragPivotPosition = dragPivot.getPosition();
|
||||
|
||||
// Must position the dragged topic taking into account the current node size.
|
||||
var pivotSize = dragPivot.getSize();
|
||||
var draggedTopicSize = draggedTopic.getSize();
|
||||
var xOffset = draggedTopicSize.width - pivotSize.width;
|
||||
xOffset = Math.round(xOffset / 2);
|
||||
|
||||
if (dragPivotPosition.x > 0)
|
||||
{
|
||||
dragPivotPosition.x = parseInt(dragPivotPosition.x) + xOffset;
|
||||
}
|
||||
else
|
||||
{
|
||||
dragPivotPosition.x = parseInt(dragPivotPosition.x) - xOffset;
|
||||
}
|
||||
// Set new position ...
|
||||
command.setPosition(dragPivotPosition);
|
||||
|
||||
} else
|
||||
{
|
||||
// Main topic connections can be positioned only with the order ...
|
||||
command.setOrder(this._order);
|
||||
}
|
||||
|
||||
// Set new parent topic ..
|
||||
command.setParetTopic(targetTopic);
|
||||
} else {
|
||||
|
||||
// If the node is not connected, positionate based on the original drag topic position.
|
||||
var dragPosition = this.getPosition();
|
||||
command = new mindplot.commands.DragTopicCommand(topicId, dragPosition);
|
||||
command.setPosition(dragPosition);
|
||||
}
|
||||
actionRunner.execute(command);
|
||||
};
|
||||
|
||||
mindplot.DragTopic.prototype.setBoardPosition = function(point)
|
||||
{
|
||||
$assert(point, 'point can not be null');
|
||||
var dragPivot = this._getDragPivot();
|
||||
dragPivot.setPosition(point);
|
||||
};
|
||||
|
||||
|
||||
mindplot.DragTopic.prototype.getBoardPosition = function(point)
|
||||
{
|
||||
$assert(point, 'point can not be null');
|
||||
var dragPivot = this._getDragPivot();
|
||||
return dragPivot.getPosition();
|
||||
};
|
||||
|
||||
mindplot.DragTopic.prototype.getConnectedToTopic = function()
|
||||
{
|
||||
var dragPivot = this._getDragPivot();
|
||||
return dragPivot.getTargetTopic();
|
||||
};
|
||||
|
||||
mindplot.DragTopic.prototype.isConnected = function()
|
||||
{
|
||||
return this.getConnectedToTopic() != null;
|
||||
};
|
||||
|
||||
mindplot.DragTopic.PIVOT_SIZE = {width:50,height:10};
|
||||
}
|
||||
|
||||
|
||||
@@ -71,7 +71,8 @@ mindplot.DragTopicPositioner = new Class({
|
||||
// Finally, connect nodes ...
|
||||
if (!dragTopic.isConnected()) {
|
||||
var centalTopic = topics[0];
|
||||
if ($defined(mainTopicToMainTopicConnection)) {
|
||||
if ($defined(mainTopicToMainTopicConnection))
|
||||
{
|
||||
dragTopic.connectTo(mainTopicToMainTopicConnection);
|
||||
} else if (Math.abs(dragTopic.getPosition().x - centalTopic.getPosition().x) <= mindplot.DragTopicPositioner.CENTRAL_TO_MAINTOPIC_MAX_HORIZONTAL_DISTANCE) {
|
||||
dragTopic.connectTo(centalTopic);
|
||||
@@ -82,7 +83,6 @@ mindplot.DragTopicPositioner = new Class({
|
||||
_lookUpForMainTopicToMainTopicConnection : function(dragTopic) {
|
||||
var topics = this._topics;
|
||||
var result = null;
|
||||
var clouserDistance = -1;
|
||||
var draggedNode = dragTopic.getDraggedTopic();
|
||||
var distance = null;
|
||||
|
||||
|
||||
@@ -55,9 +55,12 @@ mindplot.IconGroup = new Class({
|
||||
},
|
||||
|
||||
addIcon : function(icon) {
|
||||
$defined(icon,"icon is not defined");
|
||||
icon.setGroup(this);
|
||||
|
||||
var newIcon = icon.getImage();
|
||||
var nativeElem = this.options.nativeElem;
|
||||
|
||||
var iconSize = newIcon.getSize();
|
||||
var size = nativeElem.getSize();
|
||||
newIcon.setPosition(size.width, 0);
|
||||
@@ -186,8 +189,10 @@ mindplot.IconGroup = new Class({
|
||||
_calculateOffsets : function() {
|
||||
var offset = this.options.topic.getOffset();
|
||||
var text = this.options.topic.getTextShape();
|
||||
|
||||
var sizeHeight = text.getHtmlFontSize();
|
||||
var yOffset = offset;
|
||||
|
||||
var shape = this.options.topic.getShapeType();
|
||||
yOffset = text.getPosition().y + (sizeHeight - 18) / 2 + 1;
|
||||
return {x:offset, y:yOffset};
|
||||
|
||||
@@ -16,13 +16,13 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
mindplot.ImageIcon = new Class(
|
||||
{
|
||||
mindplot.ImageIcon = new Class({
|
||||
Extends:mindplot.Icon,
|
||||
initialize:function(iconModel, topic, designer) {
|
||||
$assert(iconModel, 'iconModel can not be null');
|
||||
$assert(topic, 'topic can not be null');
|
||||
$assert(designer, 'designer can not be null');
|
||||
|
||||
this._topic = topic;
|
||||
this._iconModel = iconModel;
|
||||
this._designer = designer;
|
||||
@@ -44,16 +44,16 @@ mindplot.ImageIcon = new Class(
|
||||
|
||||
if (!$defined(designer._viewMode) || ($defined(designer._viewMode) && !designer._viewMode)) {
|
||||
|
||||
removeImage.addEvent('click', function(event) {
|
||||
var actionRunner = designer._actionRunner;
|
||||
var command = new mindplot.commands.RemoveIconFromTopicCommand(this._topic.getId(), iconModel);
|
||||
actionRunner.execute(command);
|
||||
removeImage.addEvent('click', function() {
|
||||
var actionDispatcher = mindplot.ActionDispatcher.getInstance();
|
||||
actionDispatcher.removeIconFromTopic(this._topic.getId(), iconModel);
|
||||
tip.forceClose();
|
||||
}.bindWithEvent(this));
|
||||
});
|
||||
|
||||
//Icon
|
||||
var image = this.getImage();
|
||||
image.addEventListener('click', function(event) {
|
||||
image.addEventListener('click', function() {
|
||||
|
||||
var iconType = iconModel.getIconType();
|
||||
var newIconType = this._getNextFamilyIconId(iconType);
|
||||
iconModel.setIconType(newIconType);
|
||||
@@ -61,21 +61,16 @@ mindplot.ImageIcon = new Class(
|
||||
var imgUrl = this._getImageUrl(newIconType);
|
||||
this._image.setHref(imgUrl);
|
||||
|
||||
// // @Todo: Support revert of change icon ...
|
||||
// var actionRunner = designer._actionRunner;
|
||||
// var command = new mindplot.commands.ChangeIconFromTopicCommand(this._topic.getId());
|
||||
// this._actionRunner.execute(command);
|
||||
}.bind(this));
|
||||
|
||||
|
||||
}.bindWithEvent(this));
|
||||
|
||||
var imageIcon = this;
|
||||
image.addEventListener('mouseover', function(event) {
|
||||
tip.open(event, container, imageIcon);
|
||||
});
|
||||
tip.open(event, container, this);
|
||||
}.bind(this));
|
||||
|
||||
image.addEventListener('mouseout', function(event) {
|
||||
tip.close(event);
|
||||
});
|
||||
|
||||
image.addEventListener('mousemove', function(event) {
|
||||
tip.updatePosition(event);
|
||||
});
|
||||
@@ -83,7 +78,7 @@ mindplot.ImageIcon = new Class(
|
||||
}
|
||||
},
|
||||
|
||||
_getImageUrl : function(iconId) {
|
||||
_getImageUrl : function(iconId) {
|
||||
return "../icons/" + iconId + ".png";
|
||||
},
|
||||
|
||||
@@ -99,7 +94,6 @@ mindplot.ImageIcon = new Class(
|
||||
var result = null;
|
||||
for (var i = 0; i < familyIcons.length && result == null; i++) {
|
||||
if (familyIcons[i] == iconId) {
|
||||
var nextIconId;
|
||||
//Is last one?
|
||||
if (i == (familyIcons.length - 1)) {
|
||||
result = familyIcons[0];
|
||||
@@ -164,7 +158,7 @@ mindplot.ImageIcon.prototype.ICON_FAMILIES = [
|
||||
{"id": "bullet", "icons" : ["bullet_black","bullet_blue","bullet_green","bullet_orange","bullet_red","bullet_pink","bullet_purple"]},
|
||||
{"id": "tag", "icons" : ["tag_blue","tag_green","tag_orange","tag_red","tag_pink","tag_yellow"]},
|
||||
{"id": "object", "icons" : ["object_bell","object_clanbomber","object_key","object_pencil","object_phone","object_magnifier","object_clip","object_music","object_star","object_wizard","object_house","object_cake","object_camera","object_palette","object_rainbow"]}
|
||||
]
|
||||
];
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -90,8 +90,9 @@ mindplot.LinkIcon = new Class({
|
||||
removeBtn.setStyle("margin-left", "3px");
|
||||
|
||||
removeBtn.addEvent('click', function(event) {
|
||||
var command = new mindplot.commands.RemoveLinkFromTopicCommand(this._topic.getId());
|
||||
designer._actionRunner.execute(command);
|
||||
|
||||
var actionDispatcher = mindplot.ActionDispatcher.getInstance();
|
||||
actionDispatcher.removeLinkFromTopic(this._topic.getId());
|
||||
bubbleTip.forceClose();
|
||||
}.bindWithEvent(this));
|
||||
|
||||
@@ -148,7 +149,7 @@ mindplot.LinkIcon = new Class({
|
||||
});
|
||||
},
|
||||
|
||||
getUrl : function() {
|
||||
getUrl : function() {
|
||||
return this._url;
|
||||
},
|
||||
|
||||
|
||||
310
mindplot/src/main/javascript/LocalActionDispatcher.js
Normal file
310
mindplot/src/main/javascript/LocalActionDispatcher.js
Normal file
@@ -0,0 +1,310 @@
|
||||
/*
|
||||
* 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.LocalActionDispatcher = new Class({
|
||||
Extends: mindplot.ActionDispatcher,
|
||||
initialize: function(commandContext) {
|
||||
this.parent(commandContext);
|
||||
this._actionRunner = new mindplot.DesignerActionRunner(commandContext, this);
|
||||
},
|
||||
|
||||
hasBeenChanged: function() {
|
||||
// @todo: This don't seems to belong here.
|
||||
this._actionRunner.hasBeenChanged();
|
||||
},
|
||||
|
||||
addIconToTopic: function(topicId, iconType) {
|
||||
var command = new mindplot.commands.AddIconToTopicCommand(topicId, iconType);
|
||||
this.execute(command);
|
||||
},
|
||||
|
||||
addLinkToTopic: function(topicId, url) {
|
||||
var command = new mindplot.commands.AddLinkToTopicCommand(topicId, url);
|
||||
this.execute(command);
|
||||
},
|
||||
|
||||
addTopic:function(model, parentTopicId, animated) {
|
||||
var command = new mindplot.commands.AddTopicCommand(model, parentTopicId, animated);
|
||||
this.execute(command);
|
||||
},
|
||||
|
||||
addNoteToTopic: function(topicId, text) {
|
||||
var command = new mindplot.commands.AddNoteToTopicCommand(topicId, text);
|
||||
this.execute(command);
|
||||
},
|
||||
|
||||
addRelationship: function(model, mindmap) {
|
||||
var command = new mindplot.commands.AddRelationshipCommand(model, mindmap);
|
||||
this.execute(command);
|
||||
},
|
||||
|
||||
deleteTopics: function(topicsIds) {
|
||||
var command = new mindplot.commands.DeleteTopicCommand(topicsIds);
|
||||
this.execute(command);
|
||||
},
|
||||
|
||||
dragTopic: function(topicId, position, order, parentTopic) {
|
||||
var command = new mindplot.commands.DragTopicCommand(topicId, position, order, parentTopic);
|
||||
this.execute(command);
|
||||
},
|
||||
|
||||
moveControlPoint: function(ctrlPoint, point) {
|
||||
var command = new mindplot.commands.MoveControlPointCommand(ctrlPoint, point);
|
||||
this.execute(command);
|
||||
},
|
||||
|
||||
removeIconFromTopic: function(topicId, iconModel) {
|
||||
var command = new mindplot.commands.RemoveIconFromTopicCommand(topicId, iconModel);
|
||||
this.execute(command);
|
||||
},
|
||||
removeLinkFromTopic: function(topicId) {
|
||||
var command = new mindplot.commands.RemoveLinkFromTopicCommand(topicId);
|
||||
this.execute(command);
|
||||
},
|
||||
|
||||
removeNoteFromTopic: function(topicId) {
|
||||
var command = new mindplot.commands.RemoveNoteFromTopicCommand(topicId);
|
||||
this.execute(command);
|
||||
},
|
||||
changeFontStyleToTopic: function(topicsIds) {
|
||||
|
||||
var commandFunc = function(topic) {
|
||||
var result = topic.getFontStyle();
|
||||
var style = (result == "italic") ? "normal" : "italic";
|
||||
topic.setFontStyle(style, true);
|
||||
return result;
|
||||
};
|
||||
var command = new mindplot.commands.GenericFunctionCommand(commandFunc, topicsIds);
|
||||
this._actionRunner.execute(command);
|
||||
|
||||
},
|
||||
|
||||
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");
|
||||
|
||||
|
||||
var commandFunc = function(topic, fontFamily) {
|
||||
var result = topic.getFontFamily();
|
||||
topic.setFontFamily(fontFamily, true);
|
||||
|
||||
core.Executor.instance.delay(topic.updateNode, 0, topic);
|
||||
return result;
|
||||
};
|
||||
|
||||
var command = new mindplot.commands.GenericFunctionCommand(commandFunc, topicIds, fontFamily);
|
||||
this.execute(command);
|
||||
},
|
||||
|
||||
changeFontColorToTopic: function(topicsIds, color) {
|
||||
$assert(topicsIds, "topicIds can not be null");
|
||||
$assert(color, "color can not be null");
|
||||
|
||||
var commandFunc = function(topic, color) {
|
||||
var result = topic.getFontColor();
|
||||
topic.setFontColor(color, true);
|
||||
return result;
|
||||
};
|
||||
|
||||
var command = new mindplot.commands.GenericFunctionCommand(commandFunc, topicsIds, color);
|
||||
command.discartDuplicated = "fontColorCommandId";
|
||||
this.execute(command);
|
||||
},
|
||||
|
||||
changeBackgroundColorToTopic: function(topicsIds, color) {
|
||||
$assert(topicsIds, "topicIds can not be null");
|
||||
$assert(color, "color can not be null");
|
||||
|
||||
var commandFunc = function(topic, color) {
|
||||
var result = topic.getBackgroundColor();
|
||||
topic.setBackgroundColor(color);
|
||||
return result;
|
||||
};
|
||||
|
||||
var command = new mindplot.commands.GenericFunctionCommand(commandFunc, topicsIds, color);
|
||||
command.discartDuplicated = "backColor";
|
||||
this.execute(command);
|
||||
},
|
||||
|
||||
changeBorderColorToTopic : function(topicsIds, color) {
|
||||
$assert(topicsIds, "topicIds can not be null");
|
||||
$assert(color, "topicIds can not be null");
|
||||
|
||||
var commandFunc = function(topic, color) {
|
||||
var result = topic.getBorderColor();
|
||||
topic.setBorderColor(color);
|
||||
return result;
|
||||
};
|
||||
|
||||
var command = new mindplot.commands.GenericFunctionCommand(commandFunc, topicsIds, color);
|
||||
command.discartDuplicated = "borderColorCommandId";
|
||||
this.execute(command);
|
||||
},
|
||||
|
||||
changeFontSizeToTopic : function(topicsIds, size) {
|
||||
$assert(topicsIds, "topicIds can not be null");
|
||||
$assert(size, "size can not be null");
|
||||
|
||||
var commandFunc = function(topic, size) {
|
||||
var result = topic.getFontSize();
|
||||
topic.setFontSize(size, true);
|
||||
|
||||
core.Executor.instance.delay(topic.updateNode, 0, topic);
|
||||
return result;
|
||||
};
|
||||
|
||||
var command = new mindplot.commands.GenericFunctionCommand(commandFunc, topicsIds, size);
|
||||
this.execute(command);
|
||||
},
|
||||
|
||||
changeShapeToTopic : function(topicsIds, shapeType) {
|
||||
$assert(topicsIds, "topicsIds can not be null");
|
||||
$assert(shapeType, "shapeType can not be null");
|
||||
|
||||
var commandFunc = function(topic, shapeType) {
|
||||
var result = topic.getShapeType();
|
||||
topic.setShapeType(shapeType, true);
|
||||
return result;
|
||||
};
|
||||
|
||||
var command = new mindplot.commands.GenericFunctionCommand(commandFunc, topicsIds, shapeType);
|
||||
this.execute(command);
|
||||
},
|
||||
|
||||
changeFontWeightToTopic : function(topicsIds) {
|
||||
$assert(topicsIds, "topicsIds can not be null");
|
||||
|
||||
var commandFunc = function(topic) {
|
||||
var result = topic.getFontWeight();
|
||||
var weight = (result == "bold") ? "normal" : "bold";
|
||||
topic.setFontWeight(weight, true);
|
||||
|
||||
core.Executor.instance.delay(topic.updateNode, 0, topic);
|
||||
/*var updated = function() {
|
||||
topic.updateNode();
|
||||
};
|
||||
updated.delay(0);*/
|
||||
return result;
|
||||
};
|
||||
|
||||
var command = new mindplot.commands.GenericFunctionCommand(commandFunc, topicsIds);
|
||||
this.execute(command);
|
||||
},
|
||||
|
||||
shrinkBranch : function(topicsIds, collapse) {
|
||||
$assert(topicsIds, "topicsIds can not be null");
|
||||
|
||||
var commandFunc = function(topic, isShrink) {
|
||||
topic.setChildrenShrinked(isShrink);
|
||||
return !isShrink;
|
||||
};
|
||||
|
||||
var command = new mindplot.commands.GenericFunctionCommand(commandFunc, topicsIds, collapse);
|
||||
this.execute(command);
|
||||
},
|
||||
|
||||
execute:function(command) {
|
||||
this._actionRunner.execute(command);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
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();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -119,7 +119,7 @@ mindplot.MainTopic = new Class({
|
||||
},
|
||||
|
||||
disconnect : function(workspace) {
|
||||
mindplot.Topic.prototype.disconnect.call(this, workspace);
|
||||
this.parent(workspace);
|
||||
var size = this.getSize();
|
||||
|
||||
var model = this.getModel();
|
||||
|
||||
@@ -22,9 +22,14 @@ mindplot.MindmapDesigner = new Class({
|
||||
$assert(profile.zoom, "zoom must be defined");
|
||||
$assert(divElement, "divElement must be defined");
|
||||
|
||||
// Undo manager ...
|
||||
this._actionRunner = new mindplot.DesignerActionRunner(this);
|
||||
mindplot.DesignerActionRunner.setInstance(this._actionRunner);
|
||||
// Dispatcher manager ...
|
||||
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;
|
||||
@@ -39,18 +44,13 @@ mindplot.MindmapDesigner = new Class({
|
||||
var editorClass = mindplot.TextEditorFactory.getTextEditorFromName(mindplot.EditorOptions.textEditor);
|
||||
this._editor = new editorClass(this, this._actionRunner);
|
||||
|
||||
|
||||
// Init layout managers ...
|
||||
this._topics = [];
|
||||
// var layoutManagerClass = mindplot.layout.LayoutManagerFactory.getManagerByName(mindplot.EditorOptions.LayoutManager);
|
||||
// this._layoutManager = new layoutManagerClass(this);
|
||||
this._layoutManager = new mindplot.layout.OriginalLayoutManager(this);
|
||||
|
||||
// Register handlers..
|
||||
this._registerEvents();
|
||||
|
||||
this._relationships = {};
|
||||
|
||||
this._events = {};
|
||||
},
|
||||
|
||||
@@ -63,11 +63,8 @@ mindplot.MindmapDesigner = new Class({
|
||||
return topics[0];
|
||||
},
|
||||
|
||||
|
||||
addEventListener : function(eventType, listener) {
|
||||
|
||||
this._events[eventType] = listener;
|
||||
|
||||
},
|
||||
|
||||
_fireEvent : function(eventType, event) {
|
||||
@@ -87,7 +84,7 @@ mindplot.MindmapDesigner = new Class({
|
||||
// Create nodes on double click...
|
||||
screenManager.addEventListener('click', function(event) {
|
||||
if (workspace.isWorkspaceEventsEnabled()) {
|
||||
var t = mindmapDesigner.getEditor().isVisible();
|
||||
mindmapDesigner.getEditor().isVisible();
|
||||
mindmapDesigner.getEditor().lostFocus();
|
||||
// @todo: Puaj hack...
|
||||
mindmapDesigner._cleanScreen();
|
||||
@@ -110,8 +107,7 @@ mindplot.MindmapDesigner = new Class({
|
||||
var centralTopicId = centralTopic.getId();
|
||||
|
||||
// Execute action ...
|
||||
var command = new mindplot.commands.AddTopicCommand(model, centralTopicId, true);
|
||||
this._actionRunner.execute(command);
|
||||
this._actionDispatcher.addTopic(model, centralTopicId, true);
|
||||
}
|
||||
}.bind(this));
|
||||
}
|
||||
@@ -159,14 +155,14 @@ mindplot.MindmapDesigner = new Class({
|
||||
onObjectFocusEvent : function(currentObject, event) {
|
||||
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) {
|
||||
for (var i = 0; i < selectableObjects.length; i++) {
|
||||
var selectableObject = selectableObjects[i];
|
||||
selectableObjects.forEach(function(selectableObject) {
|
||||
if (selectableObject.isOnFocus() && selectableObject != currentObject) {
|
||||
selectableObject.setOnFocus(false);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
@@ -214,8 +210,9 @@ mindplot.MindmapDesigner = new Class({
|
||||
var parentTopicId = centalTopic.getId();
|
||||
var childModel = centalTopic.createChildModel(this._layoutManager.needsPrepositioning());
|
||||
|
||||
var command = new mindplot.commands.AddTopicCommand(childModel, parentTopicId, true);
|
||||
this._actionRunner.execute(command);
|
||||
// Execute event ...
|
||||
this._actionDispatcher.addTopic(childModel, parentTopicId, true);
|
||||
|
||||
},
|
||||
|
||||
createSiblingForSelectedNode : function() {
|
||||
@@ -241,9 +238,8 @@ mindplot.MindmapDesigner = new Class({
|
||||
var parentTopic = topic.getOutgoingConnectedTopic();
|
||||
var siblingModel = topic.createSiblingModel(this._layoutManager.needsPrepositioning());
|
||||
var parentTopicId = parentTopic.getId();
|
||||
var command = new mindplot.commands.AddTopicCommand(siblingModel, parentTopicId, true);
|
||||
|
||||
this._actionRunner.execute(command);
|
||||
this._actionDispatcher.addTopic(siblingModel, parentTopicId, true);
|
||||
}
|
||||
},
|
||||
|
||||
@@ -303,8 +299,8 @@ mindplot.MindmapDesigner = new Class({
|
||||
var mindmap = this.getMindmap();
|
||||
var model = mindmap.createRelationship(fromNode.getModel().getId(), toNode.getModel().getId());
|
||||
|
||||
var command = new mindplot.commands.AddRelationshipCommand(model, mindmap);
|
||||
this._actionRunner.execute(command);
|
||||
this._actionDispatcher.addRelationship(model, mindmap);
|
||||
|
||||
},
|
||||
|
||||
needsSave : function() {
|
||||
@@ -364,7 +360,8 @@ mindplot.MindmapDesigner = new Class({
|
||||
|
||||
this._fireEvent("loadsuccess");
|
||||
|
||||
},
|
||||
}
|
||||
,
|
||||
|
||||
load : function(mapId) {
|
||||
$assert(mapId, 'mapName can not be null');
|
||||
@@ -383,7 +380,8 @@ mindplot.MindmapDesigner = new Class({
|
||||
this._goToNode.attempt(centralTopic, this);
|
||||
|
||||
this._fireEvent("loadsuccess");
|
||||
},
|
||||
}
|
||||
,
|
||||
|
||||
_loadMap : function(mapId, mindmapModel) {
|
||||
var designer = this;
|
||||
@@ -396,7 +394,7 @@ mindplot.MindmapDesigner = new Class({
|
||||
for (var i = 0; i < branches.length; i++) {
|
||||
// NodeModel -> NodeGraph ...
|
||||
var nodeModel = branches[i];
|
||||
var nodeGraph = this._nodeModelToNodeGraph(nodeModel);
|
||||
var nodeGraph = this._nodeModelToNodeGraph(nodeModel, false);
|
||||
|
||||
// Update shrink render state...
|
||||
nodeGraph.setBranchVisibility(true);
|
||||
@@ -412,42 +410,46 @@ mindplot.MindmapDesigner = new Class({
|
||||
});
|
||||
this._fireEvent("loadsuccess");
|
||||
|
||||
},
|
||||
}
|
||||
,
|
||||
|
||||
|
||||
getMindmap : function() {
|
||||
return this._mindmap;
|
||||
},
|
||||
}
|
||||
,
|
||||
|
||||
undo : function() {
|
||||
this._actionRunner.undo();
|
||||
},
|
||||
}
|
||||
,
|
||||
|
||||
redo : function() {
|
||||
this._actionRunner.redo();
|
||||
},
|
||||
}
|
||||
,
|
||||
|
||||
_nodeModelToNodeGraph : function(nodeModel, isVisible) {
|
||||
$assert(nodeModel, "Node model can not be null");
|
||||
var nodeGraph = this._buildNodeGraph(nodeModel);
|
||||
|
||||
if ($defined(isVisible))
|
||||
if (isVisible)
|
||||
nodeGraph.setVisibility(isVisible);
|
||||
|
||||
var children = nodeModel.getChildren().slice();
|
||||
|
||||
children = this._layoutManager.prepareNode(nodeGraph, children);
|
||||
|
||||
for (var i = 0; i < children.length; i++) {
|
||||
var child = children[i];
|
||||
if ($defined(child))
|
||||
this._nodeModelToNodeGraph(child);
|
||||
this._nodeModelToNodeGraph(child, false);
|
||||
}
|
||||
|
||||
var workspace = this._workspace;
|
||||
workspace.appendChild(nodeGraph);
|
||||
return nodeGraph;
|
||||
},
|
||||
}
|
||||
,
|
||||
|
||||
_relationshipModelToRelationship : function(model) {
|
||||
$assert(model, "Node model can not be null");
|
||||
@@ -480,7 +482,6 @@ mindplot.MindmapDesigner = new Class({
|
||||
},
|
||||
|
||||
_buildRelationship : function (model) {
|
||||
var workspace = this._workspace;
|
||||
var elem = this;
|
||||
|
||||
var fromNodeId = model.getFromNode();
|
||||
@@ -521,7 +522,6 @@ mindplot.MindmapDesigner = new Class({
|
||||
relationLine.setModel(model);
|
||||
|
||||
//Add Listeners
|
||||
var elem = this;
|
||||
relationLine.addEventListener('onfocus', function(event) {
|
||||
elem.onObjectFocusEvent.attempt([relationLine, event], elem);
|
||||
});
|
||||
@@ -567,8 +567,7 @@ mindplot.MindmapDesigner = new Class({
|
||||
var validateError = 'Central topic can not be deleted.';
|
||||
var selectedObjects = this._getValidSelectedObjectsIds(validateFunc, validateError);
|
||||
if (selectedObjects.nodes.length > 0 || selectedObjects.relationshipLines.length > 0) {
|
||||
var command = new mindplot.commands.DeleteTopicCommand(selectedObjects);
|
||||
this._actionRunner.execute(command);
|
||||
this._actionDispatcher.deleteTopics(selectedObjects);
|
||||
}
|
||||
|
||||
},
|
||||
@@ -577,19 +576,8 @@ mindplot.MindmapDesigner = new Class({
|
||||
var validSelectedObjects = this._getValidSelectedObjectsIds();
|
||||
var topicsIds = validSelectedObjects.nodes;
|
||||
if (topicsIds.length > 0) {
|
||||
var commandFunc = function(topic, font) {
|
||||
var result = topic.getFontFamily();
|
||||
topic.setFontFamily(font, true);
|
||||
this._actionDispatcher.changeFontFamilyToTopic(topicsIds, font);
|
||||
|
||||
core.Executor.instance.delay(topic.updateNode, 0, topic);
|
||||
/*var updated = function() {
|
||||
topic.updateNode();
|
||||
};
|
||||
updated.delay(0);*/
|
||||
return result;
|
||||
}
|
||||
var command = new mindplot.commands.GenericFunctionCommand(commandFunc, font, topicsIds);
|
||||
this._actionRunner.execute(command);
|
||||
}
|
||||
},
|
||||
|
||||
@@ -597,14 +585,7 @@ mindplot.MindmapDesigner = new Class({
|
||||
var validSelectedObjects = this._getValidSelectedObjectsIds();
|
||||
var topicsIds = validSelectedObjects.nodes;
|
||||
if (topicsIds.length > 0) {
|
||||
var commandFunc = function(topic) {
|
||||
var result = topic.getFontStyle();
|
||||
var style = (result == "italic") ? "normal" : "italic";
|
||||
topic.setFontStyle(style, true);
|
||||
return result;
|
||||
}
|
||||
var command = new mindplot.commands.GenericFunctionCommand(commandFunc, "", topicsIds);
|
||||
this._actionRunner.execute(command);
|
||||
this._actionDispatcher.changeFontStyleToTopic(topicsIds);
|
||||
}
|
||||
},
|
||||
|
||||
@@ -612,14 +593,7 @@ mindplot.MindmapDesigner = new Class({
|
||||
var validSelectedObjects = this._getValidSelectedObjectsIds();
|
||||
var topicsIds = validSelectedObjects.nodes;
|
||||
if (topicsIds.length > 0) {
|
||||
var commandFunc = function(topic, color) {
|
||||
var result = topic.getFontColor();
|
||||
topic.setFontColor(color, true);
|
||||
return result;
|
||||
}
|
||||
var command = new mindplot.commands.GenericFunctionCommand(commandFunc, color, topicsIds);
|
||||
command.discartDuplicated = "fontColorCommandId";
|
||||
this._actionRunner.execute(command);
|
||||
this._actionDispatcher.changeFontColorToTopic(topicsIds, color);
|
||||
}
|
||||
},
|
||||
|
||||
@@ -628,20 +602,11 @@ mindplot.MindmapDesigner = new Class({
|
||||
var validateFunc = function(topic) {
|
||||
return topic.getShapeType() != mindplot.model.NodeModel.SHAPE_TYPE_LINE
|
||||
};
|
||||
var validateError = 'Color can not be setted to line topics.';
|
||||
var validateError = 'Color can not be set to line topics.';
|
||||
var validSelectedObjects = this._getValidSelectedObjectsIds(validateFunc, validateError);
|
||||
;
|
||||
var topicsIds = validSelectedObjects.nodes;
|
||||
|
||||
if (topicsIds.length > 0) {
|
||||
var commandFunc = function(topic, color) {
|
||||
var result = topic.getBackgroundColor();
|
||||
topic.setBackgroundColor(color);
|
||||
return result;
|
||||
}
|
||||
var command = new mindplot.commands.GenericFunctionCommand(commandFunc, color, topicsIds);
|
||||
command.discartDuplicated = "backColor";
|
||||
this._actionRunner.execute(command);
|
||||
this._actionDispatcher.changeBackgroundColorToTopic(topicsIds, color);
|
||||
}
|
||||
},
|
||||
|
||||
@@ -688,20 +653,12 @@ mindplot.MindmapDesigner = new Class({
|
||||
var validateFunc = function(topic) {
|
||||
return topic.getShapeType() != mindplot.model.NodeModel.SHAPE_TYPE_LINE
|
||||
};
|
||||
var validateError = 'Color can not be setted to line topics.';
|
||||
var validateError = 'Color can not be set to line topics.';
|
||||
var validSelectedObjects = this._getValidSelectedObjectsIds(validateFunc, validateError);
|
||||
;
|
||||
var topicsIds = validSelectedObjects.nodes;
|
||||
|
||||
if (topicsIds.length > 0) {
|
||||
var commandFunc = function(topic, color) {
|
||||
var result = topic.getBorderColor();
|
||||
topic.setBorderColor(color);
|
||||
return result;
|
||||
}
|
||||
var command = new mindplot.commands.GenericFunctionCommand(commandFunc, color, topicsIds);
|
||||
command.discartDuplicated = "borderColorCommandId";
|
||||
this._actionRunner.execute(command);
|
||||
this._actionDispatcher.changeBorderColorToTopic(topicsIds, color);
|
||||
}
|
||||
},
|
||||
|
||||
@@ -709,19 +666,7 @@ mindplot.MindmapDesigner = new Class({
|
||||
var validSelectedObjects = this._getValidSelectedObjectsIds();
|
||||
var topicsIds = validSelectedObjects.nodes;
|
||||
if (topicsIds.length > 0) {
|
||||
var commandFunc = function(topic, size) {
|
||||
var result = topic.getFontSize();
|
||||
topic.setFontSize(size, true);
|
||||
|
||||
core.Executor.instance.delay(topic.updateNode, 0, topic);
|
||||
/*var updated = function() {
|
||||
topic.updateNode();
|
||||
};
|
||||
updated.delay(0);*/
|
||||
return result;
|
||||
}
|
||||
var command = new mindplot.commands.GenericFunctionCommand(commandFunc, size, topicsIds);
|
||||
this._actionRunner.execute(command);
|
||||
this._actionDispatcher.changeFontSizeToTopic(topicsIds, size);
|
||||
}
|
||||
},
|
||||
|
||||
@@ -734,13 +679,7 @@ mindplot.MindmapDesigner = new Class({
|
||||
var topicsIds = validSelectedObjects.nodes;
|
||||
|
||||
if (topicsIds.length > 0) {
|
||||
var commandFunc = function(topic, size) {
|
||||
var result = topic.getShapeType();
|
||||
topic.setShapeType(size, true);
|
||||
return result;
|
||||
}
|
||||
var command = new mindplot.commands.GenericFunctionCommand(commandFunc, shape, topicsIds);
|
||||
this._actionRunner.execute(command);
|
||||
this._actionDispatcher.changeShapeToTopic(topicsIds, shape);
|
||||
}
|
||||
},
|
||||
|
||||
@@ -749,30 +688,15 @@ mindplot.MindmapDesigner = new Class({
|
||||
var validSelectedObjects = this._getValidSelectedObjectsIds();
|
||||
var topicsIds = validSelectedObjects.nodes;
|
||||
if (topicsIds.length > 0) {
|
||||
var commandFunc = function(topic) {
|
||||
var result = topic.getFontWeight();
|
||||
var weight = (result == "bold") ? "normal" : "bold";
|
||||
topic.setFontWeight(weight, true);
|
||||
|
||||
core.Executor.instance.delay(topic.updateNode, 0, topic);
|
||||
/*var updated = function() {
|
||||
topic.updateNode();
|
||||
};
|
||||
updated.delay(0);*/
|
||||
return result;
|
||||
}
|
||||
var command = new mindplot.commands.GenericFunctionCommand(commandFunc, "", topicsIds);
|
||||
this._actionRunner.execute(command);
|
||||
this._actionDispatcher.changeFontWeightToTopic(topicsIds);
|
||||
}
|
||||
},
|
||||
|
||||
addImage2SelectedNode : function(iconType) {
|
||||
addIconType2SelectedNode : function(iconType) {
|
||||
var validSelectedObjects = this._getValidSelectedObjectsIds();
|
||||
var topicsIds = validSelectedObjects.nodes;
|
||||
if (topicsIds.length > 0) {
|
||||
|
||||
var command = new mindplot.commands.AddIconToTopicCommand(topicsIds[0], iconType);
|
||||
this._actionRunner.execute(command);
|
||||
this._actionDispatcher.addIconToTopic(topicsIds[0], iconType);
|
||||
}
|
||||
},
|
||||
|
||||
@@ -780,8 +704,7 @@ mindplot.MindmapDesigner = new Class({
|
||||
var validSelectedObjects = this._getValidSelectedObjectsIds();
|
||||
var topicsIds = validSelectedObjects.nodes;
|
||||
if (topicsIds.length > 0) {
|
||||
var command = new mindplot.commands.AddLinkToTopicCommand(topicsIds[0], url);
|
||||
this._actionRunner.execute(command);
|
||||
this._actionDispatcher.addLinkToTopic(topicsIds[0], url);
|
||||
}
|
||||
},
|
||||
|
||||
@@ -793,11 +716,11 @@ mindplot.MindmapDesigner = new Class({
|
||||
if (!$defined(topic._hasLink)) {
|
||||
var msg = new Element('div');
|
||||
var urlText = new Element('div').inject(msg);
|
||||
urlText.innerHTML = "URL:"
|
||||
urlText.innerHTML = "URL:";
|
||||
var formElem = new Element('form', {'action': 'none', 'id':'linkFormId'});
|
||||
var urlInput = new Element('input', {'type': 'text', 'size':30});
|
||||
urlInput.inject(formElem);
|
||||
formElem.inject(msg)
|
||||
formElem.inject(msg);
|
||||
|
||||
var okButtonId = "linkOkButtonId";
|
||||
formElem.addEvent('submit', function(e) {
|
||||
@@ -833,8 +756,7 @@ mindplot.MindmapDesigner = new Class({
|
||||
var validSelectedObjects = this._getValidSelectedObjectsIds();
|
||||
var topicsIds = validSelectedObjects.nodes;
|
||||
if (topicsIds.length > 0) {
|
||||
var command = new mindplot.commands.AddNoteToTopicCommand(topicsIds[0], text);
|
||||
this._actionRunner.execute(command);
|
||||
this._actionDispatcher.addNoteToTopic(topicsIds[0], text);
|
||||
}
|
||||
},
|
||||
|
||||
@@ -881,27 +803,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++) {
|
||||
@@ -951,6 +852,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()) {
|
||||
@@ -961,6 +863,8 @@ mindplot.MindmapDesigner = new Class({
|
||||
this._showEditor(key);
|
||||
}
|
||||
else {
|
||||
var nodes;
|
||||
var node;
|
||||
switch (key) {
|
||||
case 'delete':
|
||||
this.deleteCurrentNode();
|
||||
@@ -974,9 +878,9 @@ mindplot.MindmapDesigner = new Class({
|
||||
this.createChildForSelectedNode();
|
||||
break;
|
||||
case 'right':
|
||||
var nodes = this._getSelectedNodes();
|
||||
nodes = this._getSelectedNodes();
|
||||
if (nodes.length > 0) {
|
||||
var node = nodes[0];
|
||||
node = nodes[0];
|
||||
if (node.getTopicType() == mindplot.model.NodeModel.CENTRAL_TOPIC_TYPE) {
|
||||
this._goToSideChild(node, 'RIGHT');
|
||||
}
|
||||
@@ -991,9 +895,9 @@ mindplot.MindmapDesigner = new Class({
|
||||
}
|
||||
break;
|
||||
case 'left':
|
||||
var nodes = this._getSelectedNodes();
|
||||
nodes = this._getSelectedNodes();
|
||||
if (nodes.length > 0) {
|
||||
var node = nodes[0];
|
||||
node = nodes[0];
|
||||
if (node.getTopicType() == mindplot.model.NodeModel.CENTRAL_TOPIC_TYPE) {
|
||||
this._goToSideChild(node, 'LEFT');
|
||||
}
|
||||
@@ -1008,18 +912,18 @@ mindplot.MindmapDesigner = new Class({
|
||||
}
|
||||
break;
|
||||
case'up':
|
||||
var nodes = this._getSelectedNodes();
|
||||
nodes = this._getSelectedNodes();
|
||||
if (nodes.length > 0) {
|
||||
var node = nodes[0];
|
||||
node = nodes[0];
|
||||
if (node.getTopicType() != mindplot.model.NodeModel.CENTRAL_TOPIC_TYPE) {
|
||||
this._goToBrother(node, 'UP');
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'down':
|
||||
var nodes = this._getSelectedNodes();
|
||||
nodes = this._getSelectedNodes();
|
||||
if (nodes.length > 0) {
|
||||
var node = nodes[0];
|
||||
node = nodes[0];
|
||||
if (node.getTopicType() != mindplot.model.NodeModel.CENTRAL_TOPIC_TYPE) {
|
||||
this._goToBrother(node, 'DOWN');
|
||||
}
|
||||
@@ -1029,8 +933,7 @@ mindplot.MindmapDesigner = new Class({
|
||||
this._showEditor();
|
||||
break;
|
||||
case 'space':
|
||||
|
||||
var nodes = this._getSelectedNodes();
|
||||
nodes = this._getSelectedNodes();
|
||||
if (nodes.length > 0) {
|
||||
var topic = nodes[0];
|
||||
|
||||
@@ -1043,9 +946,9 @@ mindplot.MindmapDesigner = new Class({
|
||||
evt.preventDefault();
|
||||
break;
|
||||
case 'esc':
|
||||
var nodes = this._getSelectedNodes();
|
||||
nodes = this._getSelectedNodes();
|
||||
for (var i = 0; i < nodes.length; i++) {
|
||||
var node = nodes[i];
|
||||
node = nodes[i];
|
||||
node.setOnFocus(false);
|
||||
}
|
||||
break;
|
||||
@@ -1170,17 +1073,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;
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
mindplot.NodeGraph = new Class({
|
||||
initialize:function(nodeModel) {
|
||||
$assert(nodeModel,"model can not be null");
|
||||
$assert(nodeModel, "model can not be null");
|
||||
this._mouseEvents = true;
|
||||
this.setModel(nodeModel);
|
||||
this._onFocus = false;
|
||||
@@ -74,13 +74,10 @@ mindplot.NodeGraph = new Class({
|
||||
this._model.setSize(size.width, size.height);
|
||||
},
|
||||
|
||||
getModel
|
||||
:
|
||||
function() {
|
||||
$assert(this._model, 'Model has not been initialized yet');
|
||||
return this._model;
|
||||
}
|
||||
,
|
||||
getModel:function() {
|
||||
$assert(this._model, 'Model has not been initialized yet');
|
||||
return this._model;
|
||||
},
|
||||
|
||||
setModel : function(model) {
|
||||
$assert(model, 'Model can not be null');
|
||||
|
||||
@@ -21,7 +21,7 @@ mindplot.Note = new Class({
|
||||
initialize : function(textModel, topic, designer) {
|
||||
var divContainer = designer.getWorkSpace().getScreenManager().getContainer();
|
||||
var bubbleTip = mindplot.BubbleTip.getInstance(divContainer);
|
||||
mindplot.Icon.call(this, mindplot.Note.IMAGE_URL);
|
||||
this.parent(mindplot.Note.IMAGE_URL);
|
||||
this._noteModel = textModel;
|
||||
this._topic = topic;
|
||||
this._designer = designer;
|
||||
@@ -50,8 +50,9 @@ mindplot.Note = new Class({
|
||||
removeBtn.setStyle("margin-left", "3px");
|
||||
|
||||
removeBtn.addEvent('click', function(event) {
|
||||
var command = new mindplot.commands.RemoveNoteFromTopicCommand(this._topic.getId());
|
||||
designer._actionRunner.execute(command);
|
||||
var actionDispatcher = mindplot.ActionDispatcher.getInstance();
|
||||
actionDispatcher.removeNoteFromTopic(this._topic.getId());
|
||||
|
||||
bubbleTip.forceClose();
|
||||
}.bindWithEvent(this));
|
||||
|
||||
|
||||
@@ -45,8 +45,7 @@ mindplot.RelationshipLine = new Class({
|
||||
},
|
||||
|
||||
setStroke : function(color, style, opacity) {
|
||||
// @Todo: How this is supported in mootools ?
|
||||
mindplot.ConnectionLine.prototype.setStroke.call(this, color, style, opacity);
|
||||
this.parent(color, style, opacity);
|
||||
this._startArrow.setStrokeColor(color);
|
||||
},
|
||||
|
||||
@@ -126,7 +125,7 @@ mindplot.RelationshipLine = new Class({
|
||||
workspace.appendChild(this._startArrow);
|
||||
workspace.appendChild(this._endArrow);
|
||||
|
||||
mindplot.ConnectionLine.prototype.addToWorkspace.call(this, workspace);
|
||||
this.parent(workspace);
|
||||
},
|
||||
|
||||
_initializeControlPointController : function(event, workspace) {
|
||||
@@ -141,7 +140,7 @@ mindplot.RelationshipLine = new Class({
|
||||
workspace.removeChild(this._startArrow);
|
||||
workspace.removeChild(this._endArrow);
|
||||
|
||||
mindplot.ConnectionLine.prototype.removeFromWorkspace.call(this, workspace);
|
||||
this.parent(workspace);
|
||||
},
|
||||
|
||||
getType : function() {
|
||||
@@ -195,13 +194,13 @@ mindplot.RelationshipLine = new Class({
|
||||
},
|
||||
|
||||
setVisibility : function(value) {
|
||||
mindplot.ConnectionLine.prototype.setVisibility.call(this, value);
|
||||
this.parent(value);
|
||||
this._endArrow.setVisibility(this._showEndArrow && value);
|
||||
this._startArrow.setVisibility(this._showStartArrow && value);
|
||||
},
|
||||
|
||||
setOpacity : function(opacity) {
|
||||
mindplot.ConnectionLine.prototype.setOpacity.call(this, opacity);
|
||||
this.parent(opacity);
|
||||
if (this._showEndArrow)
|
||||
this._endArrow.setOpacity(opacity);
|
||||
if (this._showStartArrow)
|
||||
|
||||
@@ -26,18 +26,11 @@ mindplot.ShirinkConnector = new Class({
|
||||
elipse.setSize(mindplot.Topic.CONNECTOR_WIDTH, mindplot.Topic.CONNECTOR_WIDTH);
|
||||
elipse.addEventListener('click', function(event) {
|
||||
var model = topic.getModel();
|
||||
var isShrink = !model.areChildrenShrinked();
|
||||
var collapse = !model.areChildrenShrinked();
|
||||
|
||||
var actionRunner = mindplot.DesignerActionRunner.getInstance();
|
||||
var topicId = topic.getId();
|
||||
|
||||
var commandFunc = function(topic, isShrink) {
|
||||
topic.setChildrenShrinked(isShrink);
|
||||
return !isShrink;
|
||||
};
|
||||
|
||||
var command = new mindplot.commands.GenericFunctionCommand(commandFunc, isShrink, [topicId]);
|
||||
actionRunner.execute(command);
|
||||
var actionDispatcher = mindplot.ActionDispatcher.getInstance();
|
||||
actionDispatcher.shrinkBranch([topicId],collapse);
|
||||
|
||||
var e = new Event(event).stop();
|
||||
e.preventDefault();
|
||||
|
||||
@@ -1,53 +0,0 @@
|
||||
/*
|
||||
* 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.SingleCommandDispatcher = new Class(
|
||||
{
|
||||
Extends:mindplot.BaseCommandDispatcher,
|
||||
initialize: function() {
|
||||
|
||||
},
|
||||
addIconToTopic: function() {
|
||||
throw "method must be implemented.";
|
||||
},
|
||||
addLinkToTopic: function() {
|
||||
throw "method must be implemented.";
|
||||
},
|
||||
addNoteToTopic: function() {
|
||||
throw "method must be implemented.";
|
||||
},addRelationship: function() {
|
||||
throw "method must be implemented.";
|
||||
},addTopic: function() {
|
||||
throw "method must be implemented.";
|
||||
},changeIcon: function() {
|
||||
throw "method must be implemented.";
|
||||
},deleteTopic: function() {
|
||||
throw "method must be implemented.";
|
||||
},dragTopic: function() {
|
||||
throw "method must be implemented.";
|
||||
},moveControllPoint: function() {
|
||||
throw "method must be implemented.";
|
||||
} ,removeIconFromTopic: function() {
|
||||
throw "method must be implemented.";
|
||||
},removeLinkFromTopic: function() {
|
||||
throw "method must be implemented.";
|
||||
},removeNodeFromTopic: function() {
|
||||
throw "method must be implemented.";
|
||||
}
|
||||
});
|
||||
|
||||
@@ -17,11 +17,10 @@
|
||||
*/
|
||||
|
||||
mindplot.TextEditor = new Class({
|
||||
initialize:function(designer, actionRunner) {
|
||||
initialize:function(designer) {
|
||||
this._designer = designer;
|
||||
this._screenManager = designer.getWorkSpace().getScreenManager();
|
||||
this._container = this._screenManager.getContainer();
|
||||
this._actionRunner = actionRunner;
|
||||
this._isVisible = false;
|
||||
|
||||
//Create editor ui
|
||||
@@ -132,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);
|
||||
}
|
||||
},
|
||||
|
||||
@@ -221,7 +215,6 @@ mindplot.TextEditor = new Class({
|
||||
};
|
||||
|
||||
setTimeout(executor(this), 10);
|
||||
//console.log('init done');
|
||||
},
|
||||
|
||||
setStyle : function (fontStyle) {
|
||||
|
||||
@@ -30,8 +30,7 @@ mindplot.Topic = new Class({
|
||||
this._buildShape();
|
||||
this.setMouseEventsEnabled(true);
|
||||
|
||||
// Positionate topic ....
|
||||
var model = this.getModel();
|
||||
// Position a topic ....
|
||||
var pos = model.getPosition();
|
||||
if (pos != null && model.getType() == mindplot.model.NodeModel.CENTRAL_TOPIC_TYPE) {
|
||||
this.setPosition(pos);
|
||||
@@ -65,8 +64,8 @@ mindplot.Topic = new Class({
|
||||
|
||||
//Let's register all the events. The first one is the default one. The others will be copied.
|
||||
//this._registerDefaultListenersToElement(innerShape, this);
|
||||
|
||||
var dispatcher = dispatcherByEventType['mousedown'];
|
||||
|
||||
if ($defined(dispatcher)) {
|
||||
for (var i = 1; i < dispatcher._listeners.length; i++) {
|
||||
innerShape.addEventListener('mousedown', dispatcher._listeners[i]);
|
||||
@@ -245,7 +244,7 @@ mindplot.Topic = new Class({
|
||||
return this._icon;
|
||||
},
|
||||
|
||||
_buildIconGroup : function(disableEventsListeners) {
|
||||
_buildIconGroup : function() {
|
||||
var result = new mindplot.IconGroup(this);
|
||||
var model = this.getModel();
|
||||
|
||||
@@ -455,16 +454,6 @@ mindplot.Topic = new Class({
|
||||
var model = this.getModel();
|
||||
model.setFontFamily(value);
|
||||
}
|
||||
/*var elem = this;
|
||||
var executor = function(editor)
|
||||
{
|
||||
return function()
|
||||
{
|
||||
elem.updateNode(updateModel);
|
||||
};
|
||||
};
|
||||
|
||||
setTimeout(executor(this), 0);*/
|
||||
core.Executor.instance.delay(this.updateNode, 0, this, [updateModel]);
|
||||
},
|
||||
|
||||
@@ -475,16 +464,6 @@ mindplot.Topic = new Class({
|
||||
var model = this.getModel();
|
||||
model.setFontSize(value);
|
||||
}
|
||||
/*var elem = this;
|
||||
var executor = function(editor)
|
||||
{
|
||||
return function()
|
||||
{
|
||||
elem.updateNode(updateModel);
|
||||
};
|
||||
};
|
||||
|
||||
setTimeout(executor(this), 0);*/
|
||||
core.Executor.instance.delay(this.updateNode, 0, this, [updateModel]);
|
||||
|
||||
},
|
||||
@@ -496,16 +475,6 @@ mindplot.Topic = new Class({
|
||||
var model = this.getModel();
|
||||
model.setFontStyle(value);
|
||||
}
|
||||
/*var elem = this;
|
||||
var executor = function(editor)
|
||||
{
|
||||
return function()
|
||||
{
|
||||
elem.updateNode(updateModel);
|
||||
};
|
||||
};
|
||||
|
||||
setTimeout(executor(this), 0);*/
|
||||
core.Executor.instance.delay(this.updateNode, 0, this, [updateModel]);
|
||||
},
|
||||
|
||||
@@ -870,9 +839,7 @@ mindplot.Topic = new Class({
|
||||
},
|
||||
|
||||
moveToBack : function() {
|
||||
// this._helpers.forEach(function(helper, index){
|
||||
// helper.moveToBack();
|
||||
// });
|
||||
|
||||
// Update relationship lines
|
||||
for (var j = 0; j < this._relationships.length; j++) {
|
||||
this._relationships[j].moveToBack();
|
||||
@@ -883,8 +850,6 @@ mindplot.Topic = new Class({
|
||||
}
|
||||
|
||||
this.get2DElement().moveToBack();
|
||||
|
||||
|
||||
},
|
||||
|
||||
moveToFront : function() {
|
||||
@@ -906,7 +871,6 @@ mindplot.Topic = new Class({
|
||||
},
|
||||
|
||||
_setRelationshipLinesVisibility : function(value) {
|
||||
//var relationships = designer.findRelationShipsByTopicId(this.getId());
|
||||
this._relationships.forEach(function(relationship, index) {
|
||||
relationship.setVisibility(value);
|
||||
});
|
||||
@@ -974,14 +938,6 @@ mindplot.Topic = new Class({
|
||||
type = 'mousedown';
|
||||
}
|
||||
|
||||
/* var textShape = this.getTextShape();
|
||||
textShape.addEventListener(type, listener);
|
||||
|
||||
var outerShape = this.getOuterShape();
|
||||
outerShape.addEventListener(type, listener);
|
||||
|
||||
var innerShape = this.getInnerShape();
|
||||
innerShape.addEventListener(type, listener);*/
|
||||
var shape = this.get2DElement();
|
||||
shape.addEventListener(type, listener);
|
||||
},
|
||||
@@ -991,15 +947,6 @@ mindplot.Topic = new Class({
|
||||
if (type == 'onfocus') {
|
||||
type = 'mousedown';
|
||||
}
|
||||
/*var textShape = this.getTextShape();
|
||||
textShape.removeEventListener(type, listener);
|
||||
|
||||
var outerShape = this.getOuterShape();
|
||||
outerShape.removeEventListener(type, listener);
|
||||
|
||||
var innerShape = this.getInnerShape();
|
||||
innerShape.removeEventListener(type, listener);*/
|
||||
|
||||
var shape = this.get2DElement();
|
||||
shape.removeEventListener(type, listener);
|
||||
},
|
||||
@@ -1013,7 +960,6 @@ mindplot.Topic = new Class({
|
||||
|
||||
var outerShape = this.getOuterShape();
|
||||
var innerShape = this.getInnerShape();
|
||||
var connector = this.getShrinkConnector();
|
||||
|
||||
outerShape.setSize(size.width + 4, size.height + 6);
|
||||
innerShape.setSize(size.width, size.height);
|
||||
@@ -1177,14 +1123,14 @@ mindplot.Topic = new Class({
|
||||
},
|
||||
|
||||
createDragNode : function() {
|
||||
var dragNode = mindplot.NodeGraph.prototype.createDragNode.call(this);
|
||||
var result = this.parent();
|
||||
|
||||
// Is the node already connected ?
|
||||
var targetTopic = this.getOutgoingConnectedTopic();
|
||||
if ($defined(targetTopic)) {
|
||||
dragNode.connectTo(targetTopic);
|
||||
result.connectTo(targetTopic);
|
||||
}
|
||||
return dragNode;
|
||||
return result;
|
||||
},
|
||||
|
||||
updateNode : function(updatePosition) {
|
||||
|
||||
@@ -1,53 +0,0 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
//@Todo: Por que lo cambiaste a Board ?
|
||||
mindplot.TopicBoard = new Class({
|
||||
|
||||
initialize: function() {
|
||||
this._height = null;
|
||||
},
|
||||
|
||||
_removeEntryByOrder : function(order, position) {
|
||||
var board = this._getBoard(position);
|
||||
var entry = board.lookupEntryByOrder(order);
|
||||
|
||||
$assert(!entry.isAvailable(), 'Entry must not be available in order to be removed.Entry Order:' + order);
|
||||
entry.removeTopic();
|
||||
board.update(entry);
|
||||
},
|
||||
|
||||
removeTopicFromBoard : function(topic) {
|
||||
var position = topic.getPosition();
|
||||
var order = topic.getOrder();
|
||||
|
||||
this._removeEntryByOrder(order, position);
|
||||
topic.setOrder(null);
|
||||
},
|
||||
|
||||
positionateDragTopic :function(dragTopic) {
|
||||
throw "this method must be overrided";
|
||||
},
|
||||
|
||||
getHeight: function() {
|
||||
var board = this._getBoard();
|
||||
return board.getHeight();
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
@@ -29,6 +29,7 @@ mindplot.collaboration.frameworks.brix.BrixFramework.instanciate=function(){
|
||||
if($defined(isGoogleBrix) && !instanciated){
|
||||
instanciated=true;
|
||||
var app = new goog.collab.CollaborativeApp();
|
||||
mindplot.collaboration.frameworks.brix.BrixFramework.buildMenu(app);
|
||||
app.start();
|
||||
app.addListener('modelLoad', function(model){
|
||||
var framework = new mindplot.collaboration.frameworks.brix.BrixFramework(model, app);
|
||||
@@ -37,6 +38,32 @@ mindplot.collaboration.frameworks.brix.BrixFramework.instanciate=function(){
|
||||
}
|
||||
};
|
||||
|
||||
mindplot.collaboration.frameworks.brix.BrixFramework.buildMenu=function(app){
|
||||
var menuBar = new goog.collab.ui.MenuBar();
|
||||
|
||||
// Configure toolbar menu ...
|
||||
var fileMenu = menuBar.addSubMenu("File");
|
||||
fileMenu.addItem("Save", function() {
|
||||
});
|
||||
fileMenu.addItem("Export", function() {
|
||||
});
|
||||
|
||||
var editMenu = menuBar.addSubMenu("Edit");
|
||||
editMenu.addItem("Undo", function() {
|
||||
});
|
||||
editMenu.addItem("Redo", function() {
|
||||
});
|
||||
|
||||
var formatMenu = menuBar.addSubMenu("Format");
|
||||
formatMenu.addItem("Bold", function() {
|
||||
});
|
||||
|
||||
var helpMenu = menuBar.addSubMenu("Help");
|
||||
helpMenu.addItem("Shortcuts", function() {
|
||||
});
|
||||
|
||||
app.setMenuBar(menuBar);
|
||||
};
|
||||
mindplot.collaboration.frameworks.brix.BrixFramework.instanciate();
|
||||
|
||||
|
||||
|
||||
@@ -1,33 +1,30 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
* 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.commands.AddIconToTopicCommand = new Class(
|
||||
{
|
||||
mindplot.commands.AddIconToTopicCommand = new Class({
|
||||
Extends:mindplot.Command,
|
||||
initialize: function(topicId, iconType)
|
||||
{
|
||||
initialize: function(topicId, iconType) {
|
||||
$assert(topicId, 'topicId can not be null');
|
||||
$assert(iconType, 'iconType can not be null');
|
||||
this._selectedObjectsIds = topicId;
|
||||
this._iconType = iconType;
|
||||
},
|
||||
execute: function(commandContext)
|
||||
{
|
||||
execute: function(commandContext) {
|
||||
var topic = commandContext.findTopics(this._selectedObjectsIds)[0];
|
||||
var updated = function() {
|
||||
var iconImg = topic.addIcon(this._iconType, commandContext._designer);
|
||||
@@ -36,8 +33,7 @@ mindplot.commands.AddIconToTopicCommand = new Class(
|
||||
}.bind(this);
|
||||
updated.delay(0);
|
||||
},
|
||||
undoExecute: function(commandContext)
|
||||
{
|
||||
undoExecute: function(commandContext) {
|
||||
var topic = commandContext.findTopics(this._selectedObjectsIds)[0];
|
||||
var updated = function() {
|
||||
topic.removeIcon(this._iconModel);
|
||||
|
||||
@@ -1,42 +1,38 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
* 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.commands.AddLinkToTopicCommand =new Class(
|
||||
{
|
||||
mindplot.commands.AddLinkToTopicCommand = new Class({
|
||||
Extends:mindplot.Command,
|
||||
initialize: function(topicId,url)
|
||||
{
|
||||
initialize: function(topicId, url) {
|
||||
$assert(topicId, 'topicId can not be null');
|
||||
this._selectedObjectsIds = topicId;
|
||||
this._url = url;
|
||||
this._id = mindplot.Command._nextUUID();
|
||||
},
|
||||
execute: function(commandContext)
|
||||
{
|
||||
execute: function(commandContext) {
|
||||
var topic = commandContext.findTopics(this._selectedObjectsIds)[0];
|
||||
var updated = function() {
|
||||
topic.addLink(this._url,commandContext._designer);
|
||||
topic.addLink(this._url, commandContext._designer);
|
||||
topic.updateNode();
|
||||
}.bind(this);
|
||||
updated.delay(0);
|
||||
},
|
||||
undoExecute: function(commandContext)
|
||||
{
|
||||
undoExecute: function(commandContext) {
|
||||
var topic = commandContext.findTopics(this._selectedObjectsIds)[0];
|
||||
var updated = function() {
|
||||
topic.removeLink();
|
||||
|
||||
@@ -1,42 +1,38 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
* 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.commands.AddNoteToTopicCommand = new Class(
|
||||
{
|
||||
mindplot.commands.AddNoteToTopicCommand = new Class({
|
||||
Extends:mindplot.Command,
|
||||
initialize: function(topicId,text)
|
||||
{
|
||||
initialize: function(topicId, text) {
|
||||
$assert(topicId, 'topicId can not be null');
|
||||
this._selectedObjectsIds = topicId;
|
||||
this._text = text;
|
||||
this._id = mindplot.Command._nextUUID();
|
||||
},
|
||||
execute: function(commandContext)
|
||||
{
|
||||
execute: function(commandContext) {
|
||||
var topic = commandContext.findTopics(this._selectedObjectsIds)[0];
|
||||
var updated = function() {
|
||||
topic.addNote(this._text,commandContext._designer);
|
||||
topic.addNote(this._text, commandContext._designer);
|
||||
topic.updateNode();
|
||||
}.bind(this);
|
||||
updated.delay(0);
|
||||
},
|
||||
undoExecute: function(commandContext)
|
||||
{
|
||||
undoExecute: function(commandContext) {
|
||||
var topic = commandContext.findTopics(this._selectedObjectsIds)[0];
|
||||
var updated = function() {
|
||||
topic.removeNote();
|
||||
|
||||
@@ -1,40 +1,36 @@
|
||||
/*
|
||||
* 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.commands.AddRelationshipCommand = new Class(
|
||||
{
|
||||
* 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.commands.AddRelationshipCommand = new Class({
|
||||
Extends:mindplot.Command,
|
||||
initialize: function(model, mindmap)
|
||||
{
|
||||
initialize: function(model, mindmap) {
|
||||
$assert(model, 'Relationship model can not be null');
|
||||
this._model = model;
|
||||
this._mindmap = mindmap;
|
||||
this._id = mindplot.Command._nextUUID();
|
||||
},
|
||||
execute: function(commandContext)
|
||||
{
|
||||
execute: function(commandContext) {
|
||||
var relationship = commandContext.createRelationship(this._model);
|
||||
// Finally, focus ...
|
||||
var designer = commandContext._designer;
|
||||
designer.onObjectFocusEvent.attempt(relationship, designer);
|
||||
relationship.setOnFocus(true);
|
||||
},
|
||||
undoExecute: function(commandContext)
|
||||
{
|
||||
undoExecute: function(commandContext) {
|
||||
var relationship = commandContext.removeRelationship(this._model);
|
||||
this._mindmap.removeRelationship(this._model);
|
||||
}
|
||||
|
||||
@@ -1,69 +1,67 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
* 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.commands.AddTopicCommand = new Class(
|
||||
{
|
||||
Extends:mindplot.Command,
|
||||
initialize: function(model, parentTopicId, animated)
|
||||
{
|
||||
$assert(model, 'Model can not be null');
|
||||
this._model = model;
|
||||
this._parentId = parentTopicId;
|
||||
this._id = mindplot.Command._nextUUID();
|
||||
this._animated = $defined(animated)?animated:false;
|
||||
},
|
||||
execute: function(commandContext)
|
||||
{
|
||||
// Add a new topic ...
|
||||
Extends:mindplot.Command,
|
||||
initialize: function(model, parentTopicId, animated) {
|
||||
$assert(model, 'Model can not be null');
|
||||
this._model = model;
|
||||
this._parentId = parentTopicId;
|
||||
this._id = mindplot.Command._nextUUID();
|
||||
this._animated = $defined(animated) ? animated : false;
|
||||
},
|
||||
|
||||
var topic = commandContext.createTopic(this._model, !this._animated);
|
||||
execute: function(commandContext) {
|
||||
|
||||
// Connect to topic ...
|
||||
if ($defined(this._parentId))
|
||||
{
|
||||
var parentTopic = commandContext.findTopics(this._parentId)[0];
|
||||
commandContext.connect(topic, parentTopic, !this._animated);
|
||||
// Add a new topic ...
|
||||
var topic = commandContext.createTopic(this._model, !this._animated);
|
||||
|
||||
// Connect to topic ...
|
||||
if ($defined(this._parentId)) {
|
||||
var parentTopic = commandContext.findTopics(this._parentId)[0];
|
||||
commandContext.connect(topic, parentTopic, !this._animated);
|
||||
}
|
||||
|
||||
var doneFn = function() {
|
||||
// Finally, focus ...
|
||||
var designer = commandContext._designer;
|
||||
designer.onObjectFocusEvent(topic);
|
||||
topic.setOnFocus(true);
|
||||
};
|
||||
|
||||
if (this._animated) {
|
||||
core.Utils.setVisibilityAnimated([topic,topic.getOutgoingLine()], true, doneFn);
|
||||
} else
|
||||
doneFn.attempt();
|
||||
},
|
||||
|
||||
undoExecute: function(commandContext) {
|
||||
// Finally, delete the topic from the workspace ...
|
||||
var topicId = this._model.getId();
|
||||
var topic = commandContext.findTopics(topicId)[0];
|
||||
var doneFn = function() {
|
||||
commandContext.deleteTopic(topic);
|
||||
};
|
||||
if (this._animated) {
|
||||
core.Utils.setVisibilityAnimated([topic,topic.getOutgoingLine()], false, doneFn);
|
||||
}
|
||||
else
|
||||
doneFn.attempt();
|
||||
}
|
||||
|
||||
var doneFn = function(){
|
||||
// Finally, focus ...
|
||||
var designer = commandContext._designer;
|
||||
designer.onObjectFocusEvent.attempt(topic, designer);
|
||||
topic.setOnFocus(true);
|
||||
};
|
||||
|
||||
if(this._animated){
|
||||
core.Utils.setVisibilityAnimated([topic,topic.getOutgoingLine()],true,doneFn);
|
||||
} else
|
||||
doneFn.attempt();
|
||||
},
|
||||
undoExecute: function(commandContext)
|
||||
{
|
||||
// Finally, delete the topic from the workspace ...
|
||||
var topicId = this._model.getId();
|
||||
var topic = commandContext.findTopics(topicId)[0];
|
||||
var doneFn = function(){
|
||||
commandContext.deleteTopic(topic);
|
||||
};
|
||||
if(this._animated){
|
||||
core.Utils.setVisibilityAnimated([topic,topic.getOutgoingLine()],false, doneFn);
|
||||
}
|
||||
else
|
||||
doneFn.attempt();
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -1,49 +0,0 @@
|
||||
/*
|
||||
* 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.commands.ChangeIconFromTopicCommand = new Class(
|
||||
{
|
||||
Extends:mindplot.Command,
|
||||
initialize: function(topicId, iconId, iconType)
|
||||
{
|
||||
$assert(topicId, 'topicId can not be null');
|
||||
$assert(iconId, 'iconId can not be null');
|
||||
$assert(iconType, 'iconType can not be null');
|
||||
this._selectedObjectsIds = topicId;
|
||||
this._iconModel = iconId;
|
||||
this._iconType = iconType;
|
||||
},
|
||||
execute: function(commandContext)
|
||||
{
|
||||
var topic = commandContext.findTopics(this._selectedObjectsIds)[0];
|
||||
var updated = function() {
|
||||
topic.removeIcon(this._iconModel);
|
||||
topic.updateNode();
|
||||
}.bind(this);
|
||||
updated.delay(0);
|
||||
},
|
||||
undoExecute: function(commandContext)
|
||||
{
|
||||
var topic = commandContext.findTopics(this._selectedObjectsIds)[0];
|
||||
var updated = function() {
|
||||
topic.addIcon(this._iconModel, commandContext._designer);
|
||||
topic.updateNode();
|
||||
}.bind(this);
|
||||
updated.delay(0);
|
||||
}
|
||||
});
|
||||
@@ -1,26 +1,24 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
* 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.commands.DeleteTopicCommand = new Class(
|
||||
{
|
||||
mindplot.commands.DeleteTopicCommand = new Class({
|
||||
Extends:mindplot.Command,
|
||||
initialize: function(topicsIds)
|
||||
{
|
||||
initialize: function(topicsIds) {
|
||||
$assert(topicsIds, "topicsIds must be defined");
|
||||
this._selectedObjectsIds = topicsIds;
|
||||
this._deletedTopicModels = [];
|
||||
@@ -28,18 +26,16 @@ mindplot.commands.DeleteTopicCommand = new Class(
|
||||
this._deletedRelationships = [];
|
||||
this._id = mindplot.Command._nextUUID();
|
||||
},
|
||||
execute: function(commandContext)
|
||||
{
|
||||
execute: function(commandContext) {
|
||||
var topics = commandContext.findTopics(this._selectedObjectsIds.nodes);
|
||||
if(topics.length>0){
|
||||
topics.forEach(
|
||||
function(topic, index)
|
||||
{
|
||||
if (topics.length > 0) {
|
||||
topics.forEach(
|
||||
function(topic, index) {
|
||||
var model = topic.getModel().clone();
|
||||
|
||||
//delete relationships
|
||||
//delete relationships
|
||||
var relationships = topic.getRelationships();
|
||||
while(relationships.length>0){
|
||||
while (relationships.length > 0) {
|
||||
var relationship = relationships[0];
|
||||
this._deletedRelationships.push(relationship.getModel().clone());
|
||||
commandContext.removeRelationship(relationship.getModel());
|
||||
@@ -50,8 +46,7 @@ mindplot.commands.DeleteTopicCommand = new Class(
|
||||
// Is connected?.
|
||||
var outTopic = topic.getOutgoingConnectedTopic();
|
||||
var outTopicId = null;
|
||||
if (outTopic != null)
|
||||
{
|
||||
if (outTopic != null) {
|
||||
outTopicId = outTopic.getId();
|
||||
}
|
||||
this._parentTopicIds.push(outTopicId);
|
||||
@@ -60,41 +55,39 @@ mindplot.commands.DeleteTopicCommand = new Class(
|
||||
commandContext.deleteTopic(topic);
|
||||
|
||||
}.bind(this)
|
||||
); }
|
||||
);
|
||||
}
|
||||
var lines = commandContext.findRelationships(this._selectedObjectsIds.relationshipLines);
|
||||
if(lines.length>0){
|
||||
lines.forEach(function(line,index){
|
||||
if(line.isInWorkspace()){
|
||||
if (lines.length > 0) {
|
||||
lines.forEach(function(line, index) {
|
||||
if (line.isInWorkspace()) {
|
||||
this._deletedRelationships.push(line.getModel().clone());
|
||||
commandContext.removeRelationship(line.getModel());
|
||||
commandContext.removeRelationship(line.getModel());
|
||||
}
|
||||
}.bind(this));
|
||||
}
|
||||
},
|
||||
undoExecute: function(commandContext)
|
||||
{
|
||||
undoExecute: function(commandContext) {
|
||||
|
||||
var topics = commandContext.findTopics(this._selectedObjectsIds);
|
||||
var parent = commandContext.findTopics(this._parentTopicIds);
|
||||
|
||||
this._deletedTopicModels.forEach(
|
||||
function(model, index)
|
||||
{
|
||||
var topic = commandContext.createTopic(model);
|
||||
function(model, index) {
|
||||
var topic = commandContext.createTopic(model);
|
||||
|
||||
// Was the topic connected?
|
||||
var parentTopic = parent[index];
|
||||
if (parentTopic != null)
|
||||
{
|
||||
commandContext.connect(topic, parentTopic);
|
||||
}
|
||||
// Was the topic connected?
|
||||
var parentTopic = parent[index];
|
||||
if (parentTopic != null) {
|
||||
commandContext.connect(topic, parentTopic);
|
||||
}
|
||||
|
||||
}.bind(this)
|
||||
);
|
||||
}.bind(this)
|
||||
);
|
||||
this._deletedRelationships.forEach(
|
||||
function(relationship, index){
|
||||
commandContext.createRelationship(relationship);
|
||||
}.bind(this));
|
||||
function(relationship, index) {
|
||||
commandContext.createRelationship(relationship);
|
||||
}.bind(this));
|
||||
|
||||
this._deletedTopicModels = [];
|
||||
this._parentTopicIds = [];
|
||||
|
||||
@@ -1,35 +1,35 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
* 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.commands.DragTopicCommand = new Class(
|
||||
{
|
||||
mindplot.commands.DragTopicCommand = new Class({
|
||||
Extends:mindplot.Command,
|
||||
initialize: function(topicId)
|
||||
{
|
||||
$assert(topicId, "topicId must be defined");
|
||||
this._selectedObjectsIds = topicId;
|
||||
this._parentTopic = null;
|
||||
this._position = null;
|
||||
this._order = null;
|
||||
initialize: function(topicIds, position, order, parentTopic) {
|
||||
$assert(topicIds, "topicIds must be defined");
|
||||
|
||||
this._selectedObjectsIds = topicIds;
|
||||
if ($defined(parentTopic))
|
||||
this._parentId = parentTopic.getId();
|
||||
|
||||
this._position = position;
|
||||
this._order = order;
|
||||
this._id = mindplot.Command._nextUUID();
|
||||
},
|
||||
execute: function(commandContext)
|
||||
{
|
||||
execute: function(commandContext) {
|
||||
|
||||
var topic = commandContext.findTopics([this._selectedObjectsIds])[0];
|
||||
|
||||
@@ -39,70 +39,51 @@ mindplot.commands.DragTopicCommand = new Class(
|
||||
var origPosition = null;
|
||||
// if (topic.getType() == mindplot.model.NodeModel.MAIN_TOPIC_TYPE && origParentTopic != null && origParentTopic.getType() == mindplot.model.NodeModel.MAIN_TOPIC_TYPE)
|
||||
// {
|
||||
// In this case, topics are positioned using order ...
|
||||
origOrder = topic.getOrder();
|
||||
// In this case, topics are positioned using order ...
|
||||
origOrder = topic.getOrder();
|
||||
// } else
|
||||
// {
|
||||
origPosition = topic.getPosition().clone();
|
||||
origPosition = topic.getPosition().clone();
|
||||
// }
|
||||
|
||||
// Disconnect topic ..
|
||||
if ($defined(origParentTopic))
|
||||
{
|
||||
if ($defined(origParentTopic)) {
|
||||
commandContext.disconnect(topic);
|
||||
}
|
||||
|
||||
|
||||
// Set topic order ...
|
||||
if (this._order != null)
|
||||
{
|
||||
if (this._order != null) {
|
||||
topic.setOrder(this._order);
|
||||
} else if (this._position != null)
|
||||
{
|
||||
} else if (this._position != null) {
|
||||
// Set position ...
|
||||
topic.setPosition(this._position);
|
||||
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
$assert("Illegal commnad state exception.");
|
||||
}
|
||||
this._order = origOrder;
|
||||
this._position = origPosition;
|
||||
|
||||
// Finally, connect topic ...
|
||||
if ($defined(this._parentId))
|
||||
{
|
||||
if ($defined(this._parentId)) {
|
||||
var parentTopic = commandContext.findTopics([this._parentId])[0];
|
||||
commandContext.connect(topic, parentTopic);
|
||||
}
|
||||
|
||||
// Backup old parent id ...
|
||||
this._parentId = null;
|
||||
if ($defined(origParentTopic))
|
||||
{
|
||||
if ($defined(origParentTopic)) {
|
||||
this._parentId = origParentTopic.getId();
|
||||
}
|
||||
|
||||
},
|
||||
undoExecute: function(commandContext)
|
||||
{
|
||||
undoExecute: function(commandContext) {
|
||||
this.execute(commandContext);
|
||||
var selectedRelationships = commandContext.getSelectedRelationshipLines();
|
||||
selectedRelationships.forEach(function(relationshipLine,index){
|
||||
selectedRelationships.forEach(function(relationshipLine) {
|
||||
relationshipLine.redraw();
|
||||
});
|
||||
|
||||
},
|
||||
setPosition: function(point)
|
||||
{
|
||||
this._position = point;
|
||||
},
|
||||
setParetTopic: function(topic) {
|
||||
this._parentId = topic.getId();
|
||||
|
||||
},
|
||||
setOrder: function(order)
|
||||
{
|
||||
this._order = order
|
||||
}
|
||||
});
|
||||
@@ -1,66 +1,57 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
* 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.commands.GenericFunctionCommand =new Class(
|
||||
{
|
||||
mindplot.commands.GenericFunctionCommand = new Class({
|
||||
Extends:mindplot.Command,
|
||||
initialize: function(commandFunc,value,topicsIds)
|
||||
{
|
||||
initialize: function(commandFunc, topicsIds,value) {
|
||||
$assert(commandFunc, "commandFunc must be defined");
|
||||
$assert(topicsIds, "topicsIds must be defined");
|
||||
|
||||
this._value = value;
|
||||
this._selectedObjectsIds = topicsIds;
|
||||
this._commandFunc = commandFunc;
|
||||
this._oldValues = [];
|
||||
this._id = mindplot.Command._nextUUID();
|
||||
},
|
||||
execute: function(commandContext)
|
||||
{
|
||||
if (!this.applied)
|
||||
{
|
||||
execute: function(commandContext) {
|
||||
if (!this.applied) {
|
||||
var topics = commandContext.findTopics(this._selectedObjectsIds);
|
||||
topics.forEach(function(topic)
|
||||
{
|
||||
topics.forEach(function(topic) {
|
||||
var oldValue = this._commandFunc(topic, this._value);
|
||||
this._oldValues.push(oldValue);
|
||||
}.bind(this));
|
||||
this.applied = true;
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
throw "Command can not be applied two times in a row.";
|
||||
}
|
||||
|
||||
},
|
||||
undoExecute: function(commandContext)
|
||||
{
|
||||
if (this.applied)
|
||||
{
|
||||
undoExecute: function(commandContext) {
|
||||
if (this.applied) {
|
||||
var topics = commandContext.findTopics(this._selectedObjectsIds);
|
||||
topics.forEach(function(topic,index)
|
||||
{
|
||||
topics.forEach(function(topic, index) {
|
||||
this._commandFunc(topic, this._oldValues[index]);
|
||||
|
||||
}.bind(this));
|
||||
|
||||
this.applied = false;
|
||||
this._oldValues = [];
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
throw "undo can not be applied.";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,33 +1,32 @@
|
||||
/*
|
||||
* 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.commands.MoveControlPointCommand = new Class(
|
||||
{
|
||||
* 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.commands.MoveControlPointCommand = new Class({
|
||||
Extends:mindplot.Command,
|
||||
initialize: function(ctrlPointController, point)
|
||||
{
|
||||
initialize: function(ctrlPointController, point) {
|
||||
$assert(ctrlPointController, 'line can not be null');
|
||||
$assert(point, 'point can not be null');
|
||||
|
||||
this._ctrlPointControler = ctrlPointController;
|
||||
this._line = ctrlPointController._line;
|
||||
var model = this._line.getModel();
|
||||
this._controlPoint = this._ctrlPointControler.getControlPoint(point).clone();
|
||||
this._oldControlPoint= this._ctrlPointControler.getOriginalCtrlPoint(point).clone();
|
||||
this._oldControlPoint = this._ctrlPointControler.getOriginalCtrlPoint(point).clone();
|
||||
this._originalEndPoint = this._ctrlPointControler.getOriginalEndPoint(point).clone();
|
||||
switch (point){
|
||||
switch (point) {
|
||||
case 0:
|
||||
this._wasCustom = this._line.getLine().isSrcControlPointCustom();
|
||||
this._endPoint = this._line.getLine().getFrom().clone();
|
||||
@@ -40,10 +39,9 @@ mindplot.commands.MoveControlPointCommand = new Class(
|
||||
this._id = mindplot.Command._nextUUID();
|
||||
this._point = point;
|
||||
},
|
||||
execute: function(commandContext)
|
||||
{
|
||||
execute: function(commandContext) {
|
||||
var model = this._line.getModel();
|
||||
switch (this._point){
|
||||
switch (this._point) {
|
||||
case 0:
|
||||
model.setSrcCtrlPoint(this._controlPoint.clone());
|
||||
this._line.setFrom(this._endPoint.x, this._endPoint.y);
|
||||
@@ -58,36 +56,35 @@ mindplot.commands.MoveControlPointCommand = new Class(
|
||||
this._line.setDestControlPoint(this._controlPoint.clone());
|
||||
break;
|
||||
}
|
||||
if(this._line.isOnFocus()){
|
||||
if (this._line.isOnFocus()) {
|
||||
this._line._refreshSelectedShape();
|
||||
this._ctrlPointControler.setLine(this._line);
|
||||
}
|
||||
this._line.getLine().updateLine(this._point);
|
||||
},
|
||||
undoExecute: function(commandContext)
|
||||
{
|
||||
undoExecute: function(commandContext) {
|
||||
var line = this._line;
|
||||
var model = line.getModel();
|
||||
switch (this._point){
|
||||
switch (this._point) {
|
||||
case 0:
|
||||
if($defined(this._oldControlPoint)){
|
||||
if ($defined(this._oldControlPoint)) {
|
||||
line.setFrom(this._originalEndPoint.x, this._originalEndPoint.y);
|
||||
model.setSrcCtrlPoint(this._oldControlPoint.clone());
|
||||
line.setSrcControlPoint(this._oldControlPoint.clone());
|
||||
line.setIsSrcControlPointCustom(this._wasCustom);
|
||||
}
|
||||
break;
|
||||
break;
|
||||
case 1:
|
||||
if($defined(this._oldControlPoint)){
|
||||
if ($defined(this._oldControlPoint)) {
|
||||
line.setTo(this._originalEndPoint.x, this._originalEndPoint.y);
|
||||
model.setDestCtrlPoint(this._oldControlPoint.clone());
|
||||
line.setDestControlPoint(this._oldControlPoint.clone());
|
||||
line.setIsDestControlPointCustom(this._wasCustom);
|
||||
}
|
||||
break;
|
||||
break;
|
||||
}
|
||||
this._line.getLine().updateLine(this._point);
|
||||
if(this._line.isOnFocus()){
|
||||
if (this._line.isOnFocus()) {
|
||||
this._ctrlPointControler.setLine(line);
|
||||
line._refreshSelectedShape();
|
||||
}
|
||||
|
||||
@@ -16,8 +16,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
mindplot.commands.RemoveIconFromTopicCommand = new Class(
|
||||
{
|
||||
mindplot.commands.RemoveIconFromTopicCommand = new Class({
|
||||
Extends:mindplot.Command,
|
||||
initialize: function(topicId, iconModel)
|
||||
{
|
||||
|
||||
@@ -1,31 +1,28 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
* 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.commands.RemoveLinkFromTopicCommand =new Class(
|
||||
{
|
||||
mindplot.commands.RemoveLinkFromTopicCommand = new Class({
|
||||
Extends:mindplot.Command,
|
||||
initialize: function(topicId)
|
||||
{
|
||||
initialize: function(topicId) {
|
||||
$assert(topicId, 'topicId can not be null');
|
||||
this._selectedObjectsIds = topicId;
|
||||
},
|
||||
execute: function(commandContext)
|
||||
{
|
||||
execute: function(commandContext) {
|
||||
var topic = commandContext.findTopics(this._selectedObjectsIds)[0];
|
||||
this._url = topic._link.getUrl();
|
||||
var updated = function() {
|
||||
@@ -33,11 +30,10 @@ mindplot.commands.RemoveLinkFromTopicCommand =new Class(
|
||||
}.bind(this);
|
||||
updated.delay(0);
|
||||
},
|
||||
undoExecute: function(commandContext)
|
||||
{
|
||||
undoExecute: function(commandContext) {
|
||||
var topic = commandContext.findTopics(this._selectedObjectsIds)[0];
|
||||
var updated = function() {
|
||||
topic.addLink(this._url,commandContext._designer);
|
||||
topic.addLink(this._url, commandContext._designer);
|
||||
topic.updateNode();
|
||||
}.bind(this);
|
||||
updated.delay(0);
|
||||
|
||||
@@ -16,8 +16,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
mindplot.commands.RemoveNoteFromTopicCommand = new Class(
|
||||
{
|
||||
mindplot.commands.RemoveNoteFromTopicCommand = new Class({
|
||||
Extends:mindplot.Command,
|
||||
initialize: function(topicId)
|
||||
{
|
||||
|
||||
@@ -15,8 +15,3 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
if($defined(afterMindpotLibraryLoading))
|
||||
{
|
||||
afterMindpotLibraryLoading();
|
||||
}
|
||||
|
||||
@@ -25,4 +25,5 @@
|
||||
var mindplot = {};
|
||||
mindplot.util = {};
|
||||
mindplot.commands = {};
|
||||
mindplot.layout = {};
|
||||
mindplot.layout = {};
|
||||
mindplot.widget = {};
|
||||
@@ -24,12 +24,13 @@ mindplot.layout.OriginalLayoutManager = new Class({
|
||||
initialize:function(designer, options) {
|
||||
this.parent(designer, options);
|
||||
this._dragTopicPositioner = new mindplot.DragTopicPositioner(this);
|
||||
// Init dragger manager.
|
||||
|
||||
// Init drag manager.
|
||||
var workSpace = this.getDesigner().getWorkSpace();
|
||||
this._dragger = this._buildDragManager(workSpace);
|
||||
|
||||
// Add shapes to speed up the loading process ...
|
||||
mindplot.DragTopic.initialize(workSpace);
|
||||
mindplot.DragTopic.init(workSpace);
|
||||
},
|
||||
prepareNode:function(node, children) {
|
||||
// Sort children by order to solve adding order in for OriginalLayoutManager...
|
||||
@@ -62,15 +63,19 @@ mindplot.layout.OriginalLayoutManager = new Class({
|
||||
nodesByOrder = null;
|
||||
return node.getTopicType() != mindplot.model.NodeModel.CENTRAL_TOPIC_TYPE ? result : children;
|
||||
},
|
||||
|
||||
_nodeResizeEvent:function(node) {
|
||||
|
||||
},
|
||||
|
||||
_nodeRepositionateEvent:function(node) {
|
||||
this.getTopicBoardForTopic(node).repositionate();
|
||||
},
|
||||
|
||||
getDragTopicPositioner : function() {
|
||||
return this._dragTopicPositioner;
|
||||
},
|
||||
|
||||
_buildDragManager: function(workspace) {
|
||||
// Init dragger manager.
|
||||
var dragger = new mindplot.DragManager(workspace);
|
||||
@@ -115,11 +120,12 @@ mindplot.layout.OriginalLayoutManager = new Class({
|
||||
|
||||
return dragger;
|
||||
},
|
||||
|
||||
registerListenersOnNode : function(topic) {
|
||||
// Register node listeners ...
|
||||
var designer = this.getDesigner();
|
||||
topic.addEventListener('onfocus', function(event) {
|
||||
designer.onObjectFocusEvent.attempt([topic, event], designer);
|
||||
designer.onObjectFocusEvent(topic, event);
|
||||
});
|
||||
|
||||
// Add drag behaviour ...
|
||||
@@ -136,12 +142,15 @@ mindplot.layout.OriginalLayoutManager = new Class({
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
_createMainTopicBoard:function(node) {
|
||||
return new mindplot.MainTopicBoard(node, this);
|
||||
},
|
||||
|
||||
_createCentralTopicBoard:function(node) {
|
||||
return new mindplot.CentralTopicBoard(node, this);
|
||||
},
|
||||
|
||||
getClassName:function() {
|
||||
return mindplot.layout.OriginalLayoutManager.NAME;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
37
mindplot/src/main/javascript/widget/FontFamilyPanel.js
Normal file
37
mindplot/src/main/javascript/widget/FontFamilyPanel.js
Normal file
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* 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.widget.FontFamilyPanel = new Class({
|
||||
Extends : mindplot.widget.ToolbarPanel,
|
||||
initialize : function(buttonId, model) {
|
||||
this.parent(buttonId, model);
|
||||
},
|
||||
|
||||
buildPanel: function() {
|
||||
|
||||
var content = new Element("div", {'class':'toolbarPanel','id':'fontFamilyPanel'});
|
||||
content.innerHTML = '' +
|
||||
'<div id="times" model="Times" class="toolbarPanelLink" style="font-family:times;">Times</div>' +
|
||||
'<div id="arial" model="Arial" style="font-family:arial;">Arial</div>' +
|
||||
'<div id="tahoma" model="Tahoma" style="font-family:tahoma;">Tahoma</div>' +
|
||||
'<div id="verdana" model="Verdana" style="font-family:verdana;">Verdana</div>';
|
||||
|
||||
return content;
|
||||
|
||||
}
|
||||
});
|
||||
37
mindplot/src/main/javascript/widget/FontSizePanel.js
Normal file
37
mindplot/src/main/javascript/widget/FontSizePanel.js
Normal file
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* 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.widget.FontSizePanel = new Class({
|
||||
Extends : mindplot.widget.ToolbarPanel,
|
||||
initialize : function(buttonId, model) {
|
||||
this.parent(buttonId, model);
|
||||
},
|
||||
|
||||
buildPanel: function() {
|
||||
|
||||
var content = new Element("div", {'class':'toolbarPanel','id':'fontSizePanel'});
|
||||
content.innerHTML = '' +
|
||||
'<div id="small" model="6" style="font-size:8px">Small</div>' +
|
||||
'<div id="normal" model="8" style="font-size:12px">Normal</div>' +
|
||||
'<div id="large" model="10" style="font-size:15px">Large</div>' +
|
||||
'<div id="huge" model="15" style="font-size:24px">Huge</div>';
|
||||
|
||||
return content;
|
||||
|
||||
}
|
||||
});
|
||||
141
mindplot/src/main/javascript/widget/IconPanel.js
Normal file
141
mindplot/src/main/javascript/widget/IconPanel.js
Normal file
@@ -0,0 +1,141 @@
|
||||
/*
|
||||
* 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.widget.IconPanel = new Class({
|
||||
Implements:[Options,Events],
|
||||
options:{
|
||||
width:253,
|
||||
initialWidth:0,
|
||||
height:200,
|
||||
panel:null,
|
||||
onStart:Class.empty,
|
||||
state:'close'
|
||||
},
|
||||
|
||||
initialize:function(buttonId, model) {
|
||||
this._buttonId = buttonId;
|
||||
this._model = model;
|
||||
|
||||
this.options.content = this._build();
|
||||
this.init();
|
||||
|
||||
},
|
||||
|
||||
init:function() {
|
||||
var panel = new Element('div');
|
||||
var buttonElem = $(this._buttonId);
|
||||
|
||||
var coord = buttonElem.getCoordinates();
|
||||
var top = buttonElem.getTop() + coord.height + 2;
|
||||
var left = buttonElem.getLeft();
|
||||
|
||||
panel.setStyles({
|
||||
width:this.options.initialWidth,
|
||||
height:0,position:'absolute',
|
||||
top:top,
|
||||
left:left,
|
||||
background:'#e5e5e5',
|
||||
border:'1px solid #BBB4D6',
|
||||
zIndex:20,
|
||||
overflow:'hidden'}
|
||||
);
|
||||
|
||||
this.options.panel = panel;
|
||||
this.options.content.inject(panel);
|
||||
|
||||
this.options.content.addEvent('click', function() {
|
||||
this.hide();
|
||||
}.bind(this));
|
||||
|
||||
panel.setStyle('opacity', 0);
|
||||
panel.inject($(document.body));
|
||||
this.registerOpenPanel();
|
||||
},
|
||||
|
||||
show:function() {
|
||||
this.fireEvent("show");
|
||||
if (this.options.state == 'close') {
|
||||
if (!$defined(this.options.panel)) {
|
||||
this.init();
|
||||
}
|
||||
|
||||
var panel = this.options.panel;
|
||||
panel.setStyles({
|
||||
border: '1px solid #636163',
|
||||
opacity:100,
|
||||
height:this.options.height,
|
||||
width:this.options.width
|
||||
});
|
||||
this.fireEvent('onStart');
|
||||
this.registerClosePanel();
|
||||
this.options.state = 'open';
|
||||
|
||||
}
|
||||
},
|
||||
|
||||
hide:function() {
|
||||
if (this.options.state == 'open') {
|
||||
// Magic, disappear effect ;)
|
||||
this.options.panel.setStyles({border: '1px solid transparent', opacity:0});
|
||||
this.registerOpenPanel();
|
||||
this.options.state = 'close';
|
||||
}
|
||||
},
|
||||
|
||||
registerOpenPanel:function() {
|
||||
$(this._buttonId).removeEvents('click');
|
||||
$(this._buttonId).addEvent('click', function() {
|
||||
this.show();
|
||||
}.bind(this));
|
||||
},
|
||||
|
||||
registerClosePanel:function() {
|
||||
$(this._buttonId).removeEvents('click');
|
||||
$(this._buttonId).addEvent('click', function() {
|
||||
this.hide();
|
||||
}.bind(this));
|
||||
} ,
|
||||
|
||||
_build : function() {
|
||||
var content = new Element('div').setStyles({width:253,height:200,padding:5});
|
||||
var count = 0;
|
||||
for (var i = 0; i < mindplot.ImageIcon.prototype.ICON_FAMILIES.length; i = i + 1) {
|
||||
var familyIcons = mindplot.ImageIcon.prototype.ICON_FAMILIES[i].icons;
|
||||
for (var j = 0; j < familyIcons.length; j = j + 1) {
|
||||
// Separate icons by line ...
|
||||
var familyContent;
|
||||
if ((count % 12) == 0) {
|
||||
familyContent = new Element('div').inject(content);
|
||||
}
|
||||
|
||||
var iconId = familyIcons[j];
|
||||
var img = new Element('img').setStyles({width:16,height:16,padding:"0px 2px"}).inject(familyContent);
|
||||
img.id = iconId;
|
||||
img.src = mindplot.ImageIcon.prototype._getImageUrl(iconId);
|
||||
|
||||
img.addEvent('click', function() {
|
||||
this._model.setValue(img.id);
|
||||
}.bind(this));
|
||||
|
||||
count = count + 1;
|
||||
}
|
||||
}
|
||||
return content;
|
||||
}
|
||||
|
||||
});
|
||||
150
mindplot/src/main/javascript/widget/Menu.js
Normal file
150
mindplot/src/main/javascript/widget/Menu.js
Normal file
@@ -0,0 +1,150 @@
|
||||
/*
|
||||
* 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.widget.Menu = new Class({
|
||||
initialize : function(designer) {
|
||||
this._designer = designer;
|
||||
this._toolbarElems = [];
|
||||
this._colorPickers = [];
|
||||
|
||||
var fontFamilyModel = {
|
||||
getValue: function() {
|
||||
var nodes = designer.getSelectedNodes();
|
||||
var length = nodes.length;
|
||||
if (length == 1) {
|
||||
return nodes[0].getFontFamily();
|
||||
}
|
||||
},
|
||||
|
||||
setValue: function(value) {
|
||||
designer.setFont2SelectedNode(value);
|
||||
|
||||
}
|
||||
};
|
||||
var fontFamilyPanel = new mindplot.widget.FontFamilyPanel("fontFamily", fontFamilyModel);
|
||||
fontFamilyPanel.addEvent('show',function(){this.clear()}.bind(this));
|
||||
this._toolbarElems.push(fontFamilyPanel);
|
||||
|
||||
var fontSizeModel = {
|
||||
getValue: function() {
|
||||
var nodes = designer.getSelectedNodes();
|
||||
var length = nodes.length;
|
||||
if (length == 1) {
|
||||
return nodes[0].getFontSize();
|
||||
}
|
||||
},
|
||||
setValue: function(value) {
|
||||
designer.setFontSize2SelectedNode(value);
|
||||
}
|
||||
};
|
||||
var fontSizePanel = new mindplot.widget.FontSizePanel("fontSize", fontSizeModel);
|
||||
fontSizePanel.addEvent('show',function(){this.clear()}.bind(this));
|
||||
this._toolbarElems.push(fontSizePanel);
|
||||
|
||||
var topicShapeModel = {
|
||||
getValue: function() {
|
||||
var nodes = designer.getSelectedNodes();
|
||||
var length = nodes.length;
|
||||
if (length == 1) {
|
||||
return nodes[0].getShapeType();
|
||||
}
|
||||
},
|
||||
setValue: function(value) {
|
||||
designer.setShape2SelectedNode(value);
|
||||
}
|
||||
};
|
||||
var topicShapePanel = new mindplot.widget.TopicShapePanel("topicShape", topicShapeModel);
|
||||
topicShapePanel.addEvent('show',function(){this.clear()}.bind(this));
|
||||
this._toolbarElems.push(topicShapePanel);
|
||||
|
||||
// Create icon panel dialog ...
|
||||
var topicIconModel = {
|
||||
getValue: function() {
|
||||
return null;
|
||||
},
|
||||
setValue: function(value) {
|
||||
designer.addIconType2SelectedNode(value);
|
||||
}
|
||||
};
|
||||
var iconPanel = new mindplot.widget.IconPanel('topicIcon', topicIconModel);
|
||||
iconPanel.addEvent('show',function(){this.clear()}.bind(this));
|
||||
this._toolbarElems.push(iconPanel);
|
||||
|
||||
|
||||
var topicColorPicker = new MooRainbow('topicColor', {
|
||||
id: 'topicColor',
|
||||
imgPath: '../images/',
|
||||
startColor: [255, 255, 255],
|
||||
onInit: function() {
|
||||
this.clear();
|
||||
}.bind(this),
|
||||
|
||||
onChange: function(color) {
|
||||
designer.setBackColor2SelectedNode(color.hex);
|
||||
},
|
||||
onComplete: function() {
|
||||
this.clear();
|
||||
}.bind(this)
|
||||
});
|
||||
this._colorPickers.push(topicColorPicker);
|
||||
|
||||
var borderColorPicker = new MooRainbow('topicBorder', {
|
||||
id: 'topicBorder',
|
||||
imgPath: '../images/',
|
||||
startColor: [255, 255, 255],
|
||||
onInit: function() {
|
||||
this.clear();
|
||||
}.bind(this),
|
||||
onChange: function(color) {
|
||||
designer.setBorderColor2SelectedNode(color.hex);
|
||||
},
|
||||
onComplete: function() {
|
||||
this.clear();
|
||||
}.bind(this)
|
||||
|
||||
});
|
||||
this._colorPickers.push(borderColorPicker);
|
||||
|
||||
var fontColorPicker = new MooRainbow('fontColor', {
|
||||
id: 'fontColor',
|
||||
imgPath: '../images/',
|
||||
startColor: [255, 255, 255],
|
||||
onInit: function() {
|
||||
this.clear();
|
||||
}.bind(this),
|
||||
onChange: function(color) {
|
||||
designer.setFontColor2SelectedNode(color.hex);
|
||||
},
|
||||
onComplete: function() {
|
||||
this.clear();
|
||||
}.bind(this)
|
||||
});
|
||||
this._colorPickers.push(fontColorPicker);
|
||||
},
|
||||
|
||||
clear : function() {
|
||||
this._toolbarElems.forEach(function(elem) {
|
||||
elem.hide();
|
||||
});
|
||||
|
||||
this._colorPickers.forEach(function(elem) {
|
||||
$clear(elem);
|
||||
elem.hide();
|
||||
});
|
||||
}
|
||||
});
|
||||
89
mindplot/src/main/javascript/widget/ToolbarPanel.js
Normal file
89
mindplot/src/main/javascript/widget/ToolbarPanel.js
Normal file
@@ -0,0 +1,89 @@
|
||||
/*
|
||||
* 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.widget.ToolbarPanel = new Class({
|
||||
Implements:[Events],
|
||||
initialize : function(buttonId, model) {
|
||||
$assert(buttonId, "buttonId can not be null");
|
||||
$assert(model, "model can not be null");
|
||||
this._model = model;
|
||||
this._panelId = this.initPanel(buttonId);
|
||||
},
|
||||
|
||||
buildPanel : function() {
|
||||
throw "Method must be implemented";
|
||||
}.protect(),
|
||||
|
||||
initPanel: function (buttonId) {
|
||||
$assert(buttonId, "buttonId can not be null");
|
||||
|
||||
var panelElem = this.buildPanel();
|
||||
var buttonElem = $(buttonId);
|
||||
|
||||
// Add panel content ..
|
||||
panelElem.setStyle('display', 'none');
|
||||
panelElem.inject(buttonElem);
|
||||
|
||||
// Register on toolbar elements ...
|
||||
var menuElems = panelElem.getElements('div');
|
||||
menuElems.forEach(function(elem) {
|
||||
elem.addEvent('click', function() {
|
||||
var value = $defined(elem.getAttribute('model')) ? elem.getAttribute('model') : elem.id;
|
||||
this._model.setValue(value);
|
||||
this.hide();
|
||||
}.bind(this));
|
||||
}.bind(this));
|
||||
|
||||
// Font family event handling ....
|
||||
buttonElem.addEvent('click', function() {
|
||||
|
||||
// Is the panel being displayed ?
|
||||
if (this.isVisible()) {
|
||||
this.hide();
|
||||
} else {
|
||||
this.show();
|
||||
}
|
||||
|
||||
}.bind(this));
|
||||
return panelElem.id;
|
||||
},
|
||||
|
||||
show : function() {
|
||||
this.fireEvent('show');
|
||||
|
||||
var menuElems = $(this._panelId).getElements('div');
|
||||
var value = this._model.getValue();
|
||||
menuElems.forEach(function(elem) {
|
||||
var elemValue = $defined(elem.getAttribute('model')) ? elem.getAttribute('model') : elem.id;
|
||||
if (elemValue == value)
|
||||
elem.className = "toolbarPanelLinkSelectedLink";
|
||||
else
|
||||
elem.className = "toolbarPanelLink";
|
||||
});
|
||||
$(this._panelId).setStyle('display', 'block');
|
||||
|
||||
},
|
||||
|
||||
hide : function() {
|
||||
$(this._panelId).setStyle('display', 'none');
|
||||
},
|
||||
|
||||
isVisible : function() {
|
||||
return $(this._panelId).getStyle('display') == 'block';
|
||||
}
|
||||
});
|
||||
37
mindplot/src/main/javascript/widget/TopicShapePanel.js
Normal file
37
mindplot/src/main/javascript/widget/TopicShapePanel.js
Normal file
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* 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.widget.TopicShapePanel = new Class({
|
||||
Extends : mindplot.widget.ToolbarPanel,
|
||||
initialize : function(buttonId, model) {
|
||||
this.parent(buttonId, model);
|
||||
},
|
||||
|
||||
buildPanel: function() {
|
||||
|
||||
var content = new Element("div", {'class':'toolbarPanel','id':'topicShapePanel'});
|
||||
content.innerHTML = '' +
|
||||
'<div id="rectagle" model="rectagle"><img src="../images/shape-rectangle.png" alt="Rectangle" width="40" height="25"></div>' +
|
||||
'<div id="rounded_rectagle" model="rounded rectagle" ><img src="../images/shape-rectangle-rounded.png"alt="Rounded Rectangle" width="40" height="25"></div>' +
|
||||
'<div id="line" model="line"><img src="../images/shape-line.png" alt="Line" width="40" height="7"></div>' +
|
||||
'<div id="elipse" model="elipse" class="toolbarPanelLink"><img src="../images/shape-elipse.png" alt="Elipse" width="40" height="25"></div>';
|
||||
|
||||
return content;
|
||||
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user