From f73737ed0b0c0172be36164a537a5602293e25c2 Mon Sep 17 00:00:00 2001 From: Pablo Luna Date: Sat, 16 Apr 2011 21:41:06 +0100 Subject: [PATCH] fixing bugs --- core-js/src/main/javascript/Utils.js | 41 +++++----- core-js/src/main/javascript/footer.js | 2 +- mindplot/src/main/javascript/BoardEntry.js | 8 +- mindplot/src/main/javascript/BubbleTip.js | 2 +- mindplot/src/main/javascript/Command.js | 2 +- mindplot/src/main/javascript/ControlPoint.js | 2 +- mindplot/src/main/javascript/DragManager.js | 2 +- mindplot/src/main/javascript/DragPivot.js | 14 ++-- mindplot/src/main/javascript/DragTopic.js | 6 +- .../main/javascript/DragTopicPositioner.js | 6 +- mindplot/src/main/javascript/IconGroup.js | 4 +- mindplot/src/main/javascript/IconModel.js | 2 +- mindplot/src/main/javascript/ImageIcon.js | 2 +- mindplot/src/main/javascript/LinkIcon.js | 2 +- mindplot/src/main/javascript/MainTopic.js | 13 +++- .../src/main/javascript/MainTopicBoard.js | 2 +- .../src/main/javascript/MindmapDesigner.js | 19 +++-- mindplot/src/main/javascript/NodeModel.js | 6 +- mindplot/src/main/javascript/Note.js | 2 +- .../src/main/javascript/PersistanceManager.js | 2 +- .../src/main/javascript/RelationshipLine.js | 2 + .../src/main/javascript/RelationshipModel.js | 2 +- mindplot/src/main/javascript/TextEditor.js | 6 +- mindplot/src/main/javascript/Tip.js | 2 +- mindplot/src/main/javascript/Topic.js | 77 +++++++++++-------- .../main/javascript/VariableDistanceBoard.js | 10 +-- mindplot/src/main/javascript/Workspace.js | 6 +- .../javascript/XMLMindmapSerializer_Beta.js | 29 +++---- .../javascript/XMLMindmapSerializer_Pela.js | 33 ++++---- .../javascript/commands/AddTopicCommand.js | 2 +- .../javascript/commands/DragTopicCommand.js | 6 +- mindplot/src/main/javascript/footer.js | 2 +- .../layoutManagers/BaseLayoutManager.js | 2 +- .../layoutManagers/FreeMindLayoutManager.js | 18 ++--- .../layoutManagers/LayoutManagerFactory.js | 2 +- .../layoutManagers/OriginalLayoutManager.js | 2 +- .../boards/freeMindBoards/Board.js | 8 +- .../freeMindBoards/CentralTopicBoard.js | 2 +- .../boards/freeMindBoards/Entry.js | 4 +- mindplot/src/main/javascript/util/Shape.js | 2 +- web2d/src/main/javascript/Element.js | 10 +-- web2d/src/main/javascript/EventDispatcher.js | 4 +- web2d/src/main/javascript/Group.js | 6 +- web2d/src/main/javascript/Workspace.js | 8 +- .../main/javascript/peer/svg/ElementPeer.js | 6 +- .../src/main/javascript/peer/svg/RectPeer.js | 2 +- .../src/main/javascript/peer/svg/TextPeer.js | 4 +- .../main/javascript/peer/utils/EventUtils.js | 2 +- .../importer/freemind/FreemindImporter.java | 2 +- 49 files changed, 214 insertions(+), 186 deletions(-) diff --git a/core-js/src/main/javascript/Utils.js b/core-js/src/main/javascript/Utils.js index 5c20f702..b102d195 100644 --- a/core-js/src/main/javascript/Utils.js +++ b/core-js/src/main/javascript/Utils.js @@ -92,8 +92,8 @@ core.Utils.getMousePosition = function(event) var xcoord = -1; var ycoord = -1; - if (!event) { - if (window.event) { + if (!core.Utils.isDefined(event)) { + if (core.Utils.isDefined(window.event)) { //Internet Explorer event = window.event; } else { @@ -143,7 +143,7 @@ core.Utils.workOutDivElementPosition = function(divElement) { var curleft = 0; var curtop = 0; - if (divElement.offsetParent) { + if (core.Utils.isDefined(divElement.offsetParent)) { curleft = divElement.offsetLeft; curtop = divElement.offsetTop; while (divElement = divElement.offsetParent) { @@ -158,13 +158,13 @@ core.Utils.workOutDivElementPosition = function(divElement) core.Utils.innerXML = function(/*Node*/node) { // summary: // Implementation of MS's innerXML function. - if (node.innerXML) { + if (core.Utils.isDefined(node.innerXML)) { return node.innerXML; // string - } else if (node.xml) { + } else if (core.Utils.isDefined(node.xml)) { return node.xml; // string - } else if (typeof XMLSerializer != "undefined") { + } else if (core.Utils.isDefined(XMLSerializer)) { return (new XMLSerializer()).serializeToString(node); // string } @@ -175,7 +175,7 @@ core.Utils.createDocument = function() { // cross-browser implementation of creating an XML document object. var doc = null; var _document = window.document; - if (window.ActiveXObject) { + if (core.Utils.isDefined(window.ActiveXObject)) { var prefixes = [ "MSXML2", "Microsoft", "MSXML", "MSXML3" ]; for (var i = 0; i < prefixes.length; i++) { try { @@ -184,7 +184,7 @@ core.Utils.createDocument = function() { } ; - if (doc) { + if (core.Utils.isDefined(doc)) { break; } } @@ -201,17 +201,17 @@ core.Utils.createDocumentFromText = function(/*string*/str, /*string?*/mimetype) // summary: // attempts to create a Document object based on optional mime-type, // using str as the contents of the document - if (!mimetype) { + if (!core.Utils.isDefined(mimetype)) { mimetype = "text/xml"; } - if (window.DOMParser) + if (core.Utils.isDefined(window.DOMParser)) { var parser = new DOMParser(); return parser.parseFromString(str, mimetype); // DOMDocument - } else if (window.ActiveXObject) { + } else if (core.Utils.isDefined(window.ActiveXObject)) { var domDoc = core.Utils.createDocument(); - if (domDoc) { + if (core.Utils.isDefined(domDoc)) { domDoc.async = false; domDoc.loadXML(str); return domDoc; @@ -269,7 +269,7 @@ core.Utils.calculateDefaultControlPoints = function(srcPos, tarPos){ var x2 = tarPos.x + Math.sqrt(l*l/(1+(m*m)))*fix*-1; var y2= m*(x2-tarPos.x)+tarPos.y; - return [new core.Point(-srcPos.x + x1,-srcPos.y + y1),new core.Point(-tarPos.x + x2,-tarPos.y + y2)]; + return [new core.Point(srcPos.x - x1,srcPos.y - y1),new core.Point(tarPos.x - x2,tarPos.y - y2)]; }; core.Utils.setVisibilityAnimated = function(elems, isVisible, doneFn){ @@ -285,8 +285,10 @@ core.Utils.animateVisibility = function (elems, isVisible, doneFn){ var _opacity = (isVisible?0:1); if(isVisible){ elems.forEach(function(child, index){ - child.setOpacity(_opacity); - child.setVisibility(isVisible); + if(core.Utils.isDefined(child)){ + child.setOpacity(_opacity); + child.setVisibility(isVisible); + } }); } var fadeEffect = function(index) @@ -296,8 +298,9 @@ core.Utils.animateVisibility = function (elems, isVisible, doneFn){ $clear(_fadeEffect); _fadeEffect = null; elems.forEach(function(child, index){ - - child.setVisibility(isVisible); + if(core.Utils.isDefined(child)){ + child.setVisibility(isVisible); + } }); if(core.Utils.isDefined(doneFn)) @@ -310,7 +313,9 @@ core.Utils.animateVisibility = function (elems, isVisible, doneFn){ } _opacity-=(1/step)*fix; elems.forEach(function(child, index){ - child.setOpacity(_opacity); + if(core.Utils.isDefined(child)){ + child.setOpacity(_opacity); + } }); } diff --git a/core-js/src/main/javascript/footer.js b/core-js/src/main/javascript/footer.js index aa66c714..f2c7b8e3 100644 --- a/core-js/src/main/javascript/footer.js +++ b/core-js/src/main/javascript/footer.js @@ -22,7 +22,7 @@ wLogger.setLevel(Log4js.Level.ALL); //wLogger.addAppender(new Log4js.BrowserConsoleAppender()); // Is logger service available ? -if (window.LoggerService) +if (core.Utils.isDefined(window.LoggerService)) { Log4js.WiseServerAppender = function() { diff --git a/mindplot/src/main/javascript/BoardEntry.js b/mindplot/src/main/javascript/BoardEntry.js index 3a61f6f7..406592e6 100644 --- a/mindplot/src/main/javascript/BoardEntry.js +++ b/mindplot/src/main/javascript/BoardEntry.js @@ -18,7 +18,7 @@ mindplot.BoardEntry = function(lowerLimit, upperLimit, order) { - if (lowerLimit && upperLimit) + if (core.Utils.isDefined(lowerLimit) && core.Utils.isDefined(upperLimit)) { core.assert(lowerLimit < upperLimit, 'lowerLimit can not be greater that upperLimit'); } @@ -102,20 +102,20 @@ mindplot.BoardEntry.prototype.update = function() mindplot.BoardEntry.prototype.setTopic = function(topic, updatePosition) { - if (!core.Utils.isDefined(updatePosition)) + if (!core.Utils.isDefined(updatePosition) || (core.Utils.isDefined(updatePosition) && !updatePosition)) { updatePosition = true; } this._topic = topic; - if (topic) + if (core.Utils.isDefined(topic)) { // Fixed positioning. Only for main topic ... var position = null; var topicPosition = topic.getPosition(); // Must update position base on the border limits? - if (this._xPos) + if (core.Utils.isDefined(this._xPos)) { position = new core.Point(); diff --git a/mindplot/src/main/javascript/BubbleTip.js b/mindplot/src/main/javascript/BubbleTip.js index b4fdad2c..0dd75d3c 100644 --- a/mindplot/src/main/javascript/BubbleTip.js +++ b/mindplot/src/main/javascript/BubbleTip.js @@ -148,7 +148,7 @@ mindplot.BubbleTip.prototype.moveTopic=function(offset, panelHeight, panelWidth, mindplot.BubbleTip.getInstance = function(divContainer) { var result = mindplot.BubbleTip.instance; - if(!result) + if(!core.Utils.isDefined(result)) { mindplot.BubbleTip.instance = new mindplot.BubbleTip(divContainer); result = mindplot.BubbleTip.instance; diff --git a/mindplot/src/main/javascript/Command.js b/mindplot/src/main/javascript/Command.js index 34c3f56f..4707823b 100644 --- a/mindplot/src/main/javascript/Command.js +++ b/mindplot/src/main/javascript/Command.js @@ -38,7 +38,7 @@ mindplot.Command = new Class( mindplot.Command._nextUUID = function() { - if (!mindplot.Command._uuid) + if (!core.Utils.isDefined(mindplot.Command._uuid)) { mindplot.Command._uuid = 1; } diff --git a/mindplot/src/main/javascript/ControlPoint.js b/mindplot/src/main/javascript/ControlPoint.js index 1032213a..86ce5f57 100644 --- a/mindplot/src/main/javascript/ControlPoint.js +++ b/mindplot/src/main/javascript/ControlPoint.js @@ -50,7 +50,7 @@ mindplot.ControlPoint.prototype.setLine= function(line) { }; mindplot.ControlPoint.prototype.redraw = function(){ - if(this._line) + if(core.Utils.isDefined(this._line)) this._createControlPoint(); }; diff --git a/mindplot/src/main/javascript/DragManager.js b/mindplot/src/main/javascript/DragManager.js index 380edc57..a56f4fc7 100644 --- a/mindplot/src/main/javascript/DragManager.js +++ b/mindplot/src/main/javascript/DragManager.js @@ -97,7 +97,7 @@ mindplot.DragManager.prototype._buildMouseMoveListener = function(workspace, dra // Call mouse move listeners ... var dragListener = dragManager._listeners['dragging']; - if (dragListener) + if (core.Utils.isDefined(dragListener)) { dragListener(event, dragNode); } diff --git a/mindplot/src/main/javascript/DragPivot.js b/mindplot/src/main/javascript/DragPivot.js index 320eaf3d..14eecb08 100644 --- a/mindplot/src/main/javascript/DragPivot.js +++ b/mindplot/src/main/javascript/DragPivot.js @@ -152,7 +152,7 @@ mindplot.DragPivot.prototype.setVisibility = function(value) var connectRect = this._connectRect; connectRect.setVisibility(value); - if (this._line) + if (core.Utils.isDefined(this._line)) { this._line.setVisibility(value); } @@ -193,12 +193,12 @@ mindplot.DragPivot.prototype.removeFromWorkspace = function(workspace) var connectToRect = this._connectRect; workspace.removeChild(connectToRect); - if (this._straightLine) + if (core.Utils.isDefined(this._straightLine)) { workspace.removeChild(this._straightLine); } - if (this._curvedLine) + if (core.Utils.isDefined(this._curvedLine)) { workspace.removeChild(this._curvedLine); } @@ -225,13 +225,13 @@ mindplot.DragPivot.prototype.connectTo = function(targetTopic) // Connected to Rect ... var connectRect = this._connectRect; var targetSize = targetTopic.getSize(); - var width = targetSize.width + 6; - var height = targetSize.height + 6; + var width = targetSize.width; + var height = targetSize.height; connectRect.setSize(width, height); var targetPosition = targetTopic.getPosition(); - var cx = Math.round(targetPosition.x - (width / 2)); - var cy = Math.round(targetPosition.y - (height / 2)); + var cx = Math.ceil(targetPosition.x - (width / 2)); + var cy = Math.ceil(targetPosition.y - (height / 2)); connectRect.setPosition(cx, cy); // Change elements position ... diff --git a/mindplot/src/main/javascript/DragTopic.js b/mindplot/src/main/javascript/DragTopic.js index b0ab32e2..18f0639f 100644 --- a/mindplot/src/main/javascript/DragTopic.js +++ b/mindplot/src/main/javascript/DragTopic.js @@ -47,8 +47,8 @@ mindplot.DragTopic.prototype.setPosition = function(x, y) var draggedNode = this._draggedNode; var size = draggedNode.getSize(); - var cx = x - (size.width / 2); - var cy = y - (size.height / 2); + var cx = Math.ceil(x - (size.width / 2)); + var cy = Math.ceil(y - (size.height / 2)); // Update visual position. this._elem2d.setPosition(cx, cy); @@ -135,7 +135,7 @@ mindplot.DragTopic.prototype._getDragPivot = function() mindplot.DragTopic.__getDragPivot = function() { var result = mindplot.DragTopic._dragPivot; - if (!result) + if (!core.Utils.isDefined(result)) { result = new mindplot.DragPivot(); mindplot.DragTopic._dragPivot = result; diff --git a/mindplot/src/main/javascript/DragTopicPositioner.js b/mindplot/src/main/javascript/DragTopicPositioner.js index 44cf0da8..a5fcb31b 100644 --- a/mindplot/src/main/javascript/DragTopicPositioner.js +++ b/mindplot/src/main/javascript/DragTopicPositioner.js @@ -51,7 +51,7 @@ mindplot.DragTopicPositioner.prototype._checkDragTopicConnection = function(drag // Must be disconnected from their current connection ?. var mainTopicToMainTopicConnection = this._lookUpForMainTopicToMainTopicConnection(dragTopic); var currentConnection = dragTopic.getConnectedToTopic(); - if (currentConnection) + if (core.Utils.isDefined(currentConnection)) { // MainTopic->MainTopicConnection. if (currentConnection.getType()==mindplot.NodeModel.MAIN_TOPIC_TYPE) @@ -67,7 +67,7 @@ mindplot.DragTopicPositioner.prototype._checkDragTopicConnection = function(drag var dragXPosition = dragTopic.getPosition().x; var currentXPosition = currentConnection.getPosition().x; - if(mainTopicToMainTopicConnection) + if(core.Utils.isDefined(mainTopicToMainTopicConnection)) { // I have to change the current connection to a main topic. dragTopic.disconnect(this._workspace); @@ -83,7 +83,7 @@ mindplot.DragTopicPositioner.prototype._checkDragTopicConnection = function(drag if (!dragTopic.isConnected()) { var centalTopic = topics[0]; - if (mainTopicToMainTopicConnection) + if (core.Utils.isDefined(mainTopicToMainTopicConnection)) { dragTopic.connectTo(mainTopicToMainTopicConnection); } else if (Math.abs(dragTopic.getPosition().x - centalTopic.getPosition().x) <= mindplot.DragTopicPositioner.CENTRAL_TO_MAINTOPIC_MAX_HORIZONTAL_DISTANCE) diff --git a/mindplot/src/main/javascript/IconGroup.js b/mindplot/src/main/javascript/IconGroup.js index fdb1ee29..9629a59f 100644 --- a/mindplot/src/main/javascript/IconGroup.js +++ b/mindplot/src/main/javascript/IconGroup.js @@ -156,7 +156,7 @@ mindplot.IconGroup.prototype.moveToFront = function() { mindplot.IconGroup.prototype.registerListeners = function() { this.options.nativeElem.addEventListener('click', function(event) { // Avoid node creation ... - if (event.stopPropagation) + if (core.Utils.isDefined(event.stopPropagation)) { event.stopPropagation(true); } else @@ -168,7 +168,7 @@ mindplot.IconGroup.prototype.registerListeners = function() { this.options.nativeElem.addEventListener('dblclick', function(event) { // Avoid node creation ... - if (event.stopPropagation) + if (core.Utils.isDefined(event.stopPropagation)) { event.stopPropagation(true); } else diff --git a/mindplot/src/main/javascript/IconModel.js b/mindplot/src/main/javascript/IconModel.js index 26a15181..bdd4fd75 100644 --- a/mindplot/src/main/javascript/IconModel.js +++ b/mindplot/src/main/javascript/IconModel.js @@ -57,7 +57,7 @@ mindplot.IconModel.prototype.isIconModel = function() */ mindplot.IconModel._nextUUID = function() { - if (!this._uuid) + if (!core.Utils.isDefined(this._uuid)) { this._uuid = 0; } diff --git a/mindplot/src/main/javascript/ImageIcon.js b/mindplot/src/main/javascript/ImageIcon.js index 463c0b86..aea0ffc6 100644 --- a/mindplot/src/main/javascript/ImageIcon.js +++ b/mindplot/src/main/javascript/ImageIcon.js @@ -39,7 +39,7 @@ mindplot.ImageIcon = function(iconModel, topic, designer) { removeImage.src = "../images/bin.png"; removeImage.inject(container); - if (!designer._viewMode) + if (!core.Utils.isDefined(designer._viewMode)|| (core.Utils.isDefined(designer._viewMode) && !designer._viewMode)) { removeImage.addEvent('click', function(event) { diff --git a/mindplot/src/main/javascript/LinkIcon.js b/mindplot/src/main/javascript/LinkIcon.js index 4cd35d24..f8e62bb8 100644 --- a/mindplot/src/main/javascript/LinkIcon.js +++ b/mindplot/src/main/javascript/LinkIcon.js @@ -72,7 +72,7 @@ mindplot.LinkIcon = function(urlModel, topic, designer) { attribution.inject(element); element.inject(container); - if(!designer._viewMode){ + if(!core.Utils.isDefined(designer._viewMode)|| (core.Utils.isDefined(designer._viewMode) && !designer._viewMode)){ var buttonContainer = new Element('div').setStyles({paddingTop:5, textAlign:'center'}); var editBtn = new Element('input', {type:'button', 'class':'btn-primary', value:'Edit','class':'btn-primary'}).addClass('button').inject(buttonContainer); var removeBtn = new Element('input', {type:'button', value:'Remove','class':'btn-primary'}).addClass('button').inject(buttonContainer); diff --git a/mindplot/src/main/javascript/MainTopic.js b/mindplot/src/main/javascript/MainTopic.js index e07bea1c..55ab63b5 100644 --- a/mindplot/src/main/javascript/MainTopic.js +++ b/mindplot/src/main/javascript/MainTopic.js @@ -120,7 +120,7 @@ mindplot.MainTopic.prototype.updateTopicShape = function(targetTopic, workspace) var shapeType = model.getShapeType(); if (targetTopic.getType() != mindplot.NodeModel.CENTRAL_TOPIC_TYPE) { - if (!shapeType) + if (!core.Utils.isDefined(shapeType)) { // Get the real shape type ... shapeType = this.getShapeType(); @@ -139,7 +139,7 @@ mindplot.MainTopic.prototype.disconnect = function(workspace) var model = this.getModel(); var shapeType = model.getShapeType(); - if (!shapeType) + if (!core.Utils.isDefined(shapeType)) { // Change figure ... shapeType = this.getShapeType(); @@ -208,6 +208,9 @@ mindplot.MainTopic.prototype.workoutIncomingConnectionPoint = function(sourcePos { result.x = result.x - offset; } + + result.x = Math.ceil(result.x); + result.y = Math.ceil(result.y); return result; }; @@ -256,6 +259,8 @@ mindplot.MainTopic.prototype.workoutOutgoingConnectionPoint = function(targetPos { result = mindplot.util.Shape.calculateRectConnectionPoint(pos, size, isAtRight, true); } + result.x = Math.ceil(result.x); + result.y = Math.ceil(result.y); return result; }; @@ -272,7 +277,7 @@ mindplot.MainTopic.prototype._defaultText = function() { var targetTopic = this.getOutgoingConnectedTopic(); var result = ""; - if (targetTopic) + if (core.Utils.isDefined(targetTopic)) { if (targetTopic.getType() == mindplot.NodeModel.CENTRAL_TOPIC_TYPE) { @@ -292,7 +297,7 @@ mindplot.MainTopic.prototype._defaultFontStyle = function() { var targetTopic = this.getOutgoingConnectedTopic(); var result; - if (targetTopic) + if (core.Utils.isDefined(targetTopic)) { if (targetTopic.getType() == mindplot.NodeModel.CENTRAL_TOPIC_TYPE) { diff --git a/mindplot/src/main/javascript/MainTopicBoard.js b/mindplot/src/main/javascript/MainTopicBoard.js index 6d256e64..4975cf15 100644 --- a/mindplot/src/main/javascript/MainTopicBoard.js +++ b/mindplot/src/main/javascript/MainTopicBoard.js @@ -30,7 +30,7 @@ mindplot.MainTopicBoard.DEFAULT_MAIN_TOPIC_HEIGHT = 18; mindplot.MainTopicBoard.prototype._getBoard = function() { - if (!this._board) + if (!core.Utils.isDefined(this._board)) { var topic = this._topic; this._board = new mindplot.FixedDistanceBoard(mindplot.MainTopicBoard.DEFAULT_MAIN_TOPIC_HEIGHT, topic, this._layoutManager); diff --git a/mindplot/src/main/javascript/MindmapDesigner.js b/mindplot/src/main/javascript/MindmapDesigner.js index 0247419e..0a4b262f 100644 --- a/mindplot/src/main/javascript/MindmapDesigner.js +++ b/mindplot/src/main/javascript/MindmapDesigner.js @@ -85,7 +85,7 @@ mindplot.MindmapDesigner.prototype._registerEvents = function() var workspace = this._workspace; var screenManager = workspace.getScreenManager(); - if (!this._viewMode) + if (!core.Utils.isDefined(this._viewMode) || (core.Utils.isDefined(this._viewMode) && !this._viewMode)) { // Initialize workspace event listeners. // Create nodes on double click... @@ -278,7 +278,8 @@ mindplot.MindmapDesigner.prototype.addRelationShip2SelectedNode = function(event var screen = this._workspace.getScreenManager(); var pos = screen.getWorkspaceMousePosition(event); var selectedTopics = this.getSelectedNodes(); - if(selectedTopics.length >0){ + if(selectedTopics.length >0 && + (!core.Utils.isDefined(this._creatingRelationship) || (core.Utils.isDefined(this._creatingRelationship) && !this._creatingRelationship))){ var fromNodePosition = selectedTopics[0].getPosition(); this._relationship = new web2d.CurvedLine(); this._relationship.setStyle(web2d.CurvedLine.SIMPLE_LINE); @@ -286,6 +287,7 @@ mindplot.MindmapDesigner.prototype.addRelationShip2SelectedNode = function(event this._relationship.setFrom(fromNodePosition.x, fromNodePosition.y); this._relationship.setTo(pos.x, pos.y); this._workspace.appendChild(this._relationship); + this._creatingRelationship=true; this._relationshipMouseMoveFunction = this._relationshipMouseMove.bindWithEvent(this); this._relationshipMouseClickFunction = this._relationshipMouseClick.bindWithEvent(this, selectedTopics[0]); this._workspace.getScreenManager().addEventListener('mousemove',this._relationshipMouseMoveFunction); @@ -315,6 +317,7 @@ mindplot.MindmapDesigner.prototype._relationshipMouseClick = function (event, fr this._relationship = null; this._workspace.getScreenManager().removeEventListener('mousemove',this._relationshipMouseMoveFunction); this._workspace.getScreenManager().removeEventListener('click',this._relationshipMouseClickFunction); + this._creatingRelationship=false; event.preventDefault(); event.stop(); return false; @@ -336,7 +339,7 @@ mindplot.MindmapDesigner.prototype.needsSave = function() mindplot.MindmapDesigner.prototype.autoSaveEnabled = function(value) { - if (value) + if (core.Utils.isDefined(value) && value) { var autosave = function() { @@ -587,7 +590,7 @@ mindplot.MindmapDesigner.prototype._removeNode = function(node) var model = node.getModel(); model.deleteNode(); - if (parent) + if (core.Utils.isDefined(parent)) { this._goToNode(parent); } @@ -708,7 +711,7 @@ mindplot.MindmapDesigner.prototype._getValidSelectedObjectsIds = function(valida for (var i = 0; i < selectedNodes.length; i++) { var selectedNode = selectedNodes[i]; - if (validate) + if (core.Utils.isDefined(validate)) { isValid = validate(selectedNode); } @@ -725,7 +728,7 @@ mindplot.MindmapDesigner.prototype._getValidSelectedObjectsIds = function(valida for( var j = 0; j< selectedRelationshipLines.length; j++){ var selectedLine = selectedRelationshipLines[j]; isValid = true; - if(validate){ + if(core.Utils.isDefined(validate)){ isValid = validate(selectedLine); } @@ -1035,9 +1038,9 @@ mindplot.MindmapDesigner.prototype.keyEventHandler = function(event) if (evt.keyCode == 8) { - if (event) + if (core.Utils.isDefined(event)) { - if (event.preventDefault) { + if (core.Utils.isDefined(event.preventDefault)) { event.preventDefault(); } else { event.returnValue = false; diff --git a/mindplot/src/main/javascript/NodeModel.js b/mindplot/src/main/javascript/NodeModel.js index 5091f326..b242c841 100644 --- a/mindplot/src/main/javascript/NodeModel.js +++ b/mindplot/src/main/javascript/NodeModel.js @@ -30,7 +30,7 @@ mindplot.NodeModel = function(type, mindmap, id) this._size = {width:50,height:20}; this._position = null; if(core.Utils.isDefined(id)){ - if(!mindplot.NodeModel._uuid || id>mindplot.NodeModel._uuid){ + if(!core.Utils.isDefined(mindplot.NodeModel._uuid) || id>mindplot.NodeModel._uuid){ mindplot.NodeModel._uuid = id; } this._id = id; @@ -485,7 +485,7 @@ mindplot.NodeModel.prototype.deleteNode = function() } var parent = this._parent; - if (parent) + if (core.Utils.isDefined(parent)) { // if it is connected, I must remove it from the parent.. mindmap.disconnect(this); @@ -502,7 +502,7 @@ mindplot.NodeModel.prototype.deleteNode = function() */ mindplot.NodeModel._nextUUID = function() { - if (!this._uuid) + if (!core.Utils.isDefined(this._uuid)) { this._uuid = 0; } diff --git a/mindplot/src/main/javascript/Note.js b/mindplot/src/main/javascript/Note.js index 52b43d8f..2f93392c 100644 --- a/mindplot/src/main/javascript/Note.js +++ b/mindplot/src/main/javascript/Note.js @@ -39,7 +39,7 @@ mindplot.Note = function(textModel, topic, designer) { imgContainer.inject(container); - if(!designer._viewMode){ + if(!core.Utils.isDefined(designer._viewMode)|| (core.Utils.isDefined(designer._viewMode) && !designer._viewMode)){ var buttonContainer = new Element('div').setStyles({paddingTop:5, textAlign:'center'}); var editBtn = new Element('input', {type:'button', value:'Edit','class':'btn-primary'}).addClass('button').inject(buttonContainer); var removeBtn = new Element('input', {type:'button', value:'Remove','class':'btn-primary'}).addClass('button').inject(buttonContainer); diff --git a/mindplot/src/main/javascript/PersistanceManager.js b/mindplot/src/main/javascript/PersistanceManager.js index eae8c24c..16841c49 100644 --- a/mindplot/src/main/javascript/PersistanceManager.js +++ b/mindplot/src/main/javascript/PersistanceManager.js @@ -41,7 +41,7 @@ mindplot.PersistanceManager.save = function(mindmap, editorProperties, onSavedHa } else { // Execute on success handler ... - if (onSavedHandler) + if (core.Utils.isDefined(onSavedHandler)) { onSavedHandler(); } diff --git a/mindplot/src/main/javascript/RelationshipLine.js b/mindplot/src/main/javascript/RelationshipLine.js index 20d2ac09..6b7a5697 100644 --- a/mindplot/src/main/javascript/RelationshipLine.js +++ b/mindplot/src/main/javascript/RelationshipLine.js @@ -18,6 +18,8 @@ mindplot.RelationshipLine = function(sourceNode, targetNode, lineType) { mindplot.ConnectionLine.call(this,sourceNode, targetNode, lineType); + this._line2d.setIsSrcControlPointCustom(false); + this._line2d.setIsDestControlPointCustom(false); this._isOnfocus = false; this._focusShape = this._createLine(this.getLineType(), mindplot.ConnectionLine.SIMPLE_CURVED); this._focusShape.setStroke(2, "solid", "#3f96ff"); diff --git a/mindplot/src/main/javascript/RelationshipModel.js b/mindplot/src/main/javascript/RelationshipModel.js index face34a6..e3b6c8af 100644 --- a/mindplot/src/main/javascript/RelationshipModel.js +++ b/mindplot/src/main/javascript/RelationshipModel.js @@ -100,7 +100,7 @@ mindplot.RelationshipModel.prototype.clone = function(model){ */ mindplot.RelationshipModel._nextUUID = function() { - if (!this._uuid) + if (!core.Utils.isDefined(this._uuid)) { this._uuid = 0; } diff --git a/mindplot/src/main/javascript/TextEditor.js b/mindplot/src/main/javascript/TextEditor.js index 7d32d9b4..b03ea65a 100644 --- a/mindplot/src/main/javascript/TextEditor.js +++ b/mindplot/src/main/javascript/TextEditor.js @@ -174,7 +174,7 @@ mindplot.TextEditor.prototype.listenEventOnNode = function(topic, eventName, sto if (stopPropagation) { - if (event.stopPropagation) + if (core.Utils.isDefined(event.stopPropagation)) { event.stopPropagation(true); } else @@ -390,7 +390,7 @@ mindplot.TextEditor.prototype.lostFocus = function(bothBrowsers) mindplot.TextEditor.prototype.clickEvent = function(event){ if(this._isVisible()){ - if (event.stopPropagation) + if (core.Utils.isDefined(event.stopPropagation)) { event.stopPropagation(true); } else @@ -403,7 +403,7 @@ mindplot.TextEditor.prototype.clickEvent = function(event){ mindplot.TextEditor.prototype.mouseDownEvent = function(event){ if(this._isVisible()){ - if (event.stopPropagation) + if (core.Utils.isDefined(event.stopPropagation)) { event.stopPropagation(true); } else diff --git a/mindplot/src/main/javascript/Tip.js b/mindplot/src/main/javascript/Tip.js index 8f987f7e..d27067be 100644 --- a/mindplot/src/main/javascript/Tip.js +++ b/mindplot/src/main/javascript/Tip.js @@ -135,7 +135,7 @@ mindplot.Tip.prototype.moveTopic=function(offset, panelHeight){ mindplot.Tip.getInstance = function(divContainer) { var result = mindplot.Tip.instance; - if(!result) + if(!core.Utils.isDefined(result)) { mindplot.Tip.instance = new mindplot.Tip(divContainer); result = mindplot.Tip.instance; diff --git a/mindplot/src/main/javascript/Topic.js b/mindplot/src/main/javascript/Topic.js index d6cac74a..8d14aade 100644 --- a/mindplot/src/main/javascript/Topic.js +++ b/mindplot/src/main/javascript/Topic.js @@ -60,7 +60,7 @@ mindplot.Topic.prototype._setShapeType = function(type, updateModel) { // Remove inner shape figure ... var model = this.getModel(); - if (updateModel) + if (core.Utils.isDefined(updateModel)&& updateModel) { model.setShapeType(type); } @@ -79,7 +79,7 @@ mindplot.Topic.prototype._setShapeType = function(type, updateModel) //this._registerDefaultListenersToElement(innerShape, this); var dispatcher = dispatcherByEventType['mousedown']; - if(dispatcher) + if(core.Utils.isDefined(dispatcher)) { for(var i = 1; i0){ var selectedNode = this._layoutManager.getDesigner().getSelectedNodes()[0]; - if(!pos){ + if(!core.Utils.isDefined(pos)){ if(selectedNode.getParent()!= null && node.getParent().getId() == selectedNode.getParent().getId()){ //creating a sibling - Lets put the new node below the selected node. var parentBoard = this._layoutManager.getTopicBoardForTopic(selectedNode.getParent()); @@ -60,7 +60,7 @@ mindplot.layoutManagers.boards.freeMindBoards.Board = mindplot.layoutManagers.bo } } this._addEntry(entry, result.table, result.index); - if(pos){ + if(core.Utils.isDefined(pos)){ if(result.index>0){ var prevEntry =result.table[result.index-1]; entry.setMarginTop(pos.y-(prevEntry.getPosition() + prevEntry.getTotalMarginBottom())); @@ -183,7 +183,7 @@ mindplot.layoutManagers.boards.freeMindBoards.Board = mindplot.layoutManagers.bo var newPos = new core.Point(pos.x-(delta.x==null?0:delta.x), pos.y-delta.y); entry.setPosition(newPos.x, newPos.y); this._layoutManager._updateChildrenBoards(entry.getNode(), delta, modifiedTopics); - if(modifiedTopics.set){ + if(core.Utils.isDefined(modifiedTopics.set)){ var key = entry.getId(); if(modifiedTopics.hasKey(key)){ pos = modifiedTopics.get(key).originalPos; diff --git a/mindplot/src/main/javascript/layoutManagers/boards/freeMindBoards/CentralTopicBoard.js b/mindplot/src/main/javascript/layoutManagers/boards/freeMindBoards/CentralTopicBoard.js index ca4e11b5..4374538b 100644 --- a/mindplot/src/main/javascript/layoutManagers/boards/freeMindBoards/CentralTopicBoard.js +++ b/mindplot/src/main/javascript/layoutManagers/boards/freeMindBoards/CentralTopicBoard.js @@ -15,7 +15,7 @@ mindplot.layoutManagers.boards.freeMindBoards.CentralTopicBoard = mindplot.layou { position = altPosition; } - if(!position){ + if(!core.Utils.isDefined(position)){ if(Math.sign(node.getParent().getPosition().x) == -1){ i=1; } diff --git a/mindplot/src/main/javascript/layoutManagers/boards/freeMindBoards/Entry.js b/mindplot/src/main/javascript/layoutManagers/boards/freeMindBoards/Entry.js index 3c8b63fa..074c396c 100644 --- a/mindplot/src/main/javascript/layoutManagers/boards/freeMindBoards/Entry.js +++ b/mindplot/src/main/javascript/layoutManagers/boards/freeMindBoards/Entry.js @@ -3,12 +3,12 @@ mindplot.layoutManagers.boards.freeMindBoards.Entry = new Class({ this._node = node; this._DEFAULT_X_GAP = 30; var pos = node.getModel().getFinalPosition(); - if(useFinalPosition && pos){ + if(useFinalPosition && core.Utils.isDefined(pos)){ this.setPosition(pos.x, pos.y); } else{ pos = node.getPosition(); - if(!pos){ + if(!core.Utils.isDefined(pos)){ var parent = node.getParent(); pos = parent.getPosition().clone(); var pwidth = parent.getSize().width; diff --git a/mindplot/src/main/javascript/util/Shape.js b/mindplot/src/main/javascript/util/Shape.js index eb04cc55..83ff7716 100644 --- a/mindplot/src/main/javascript/util/Shape.js +++ b/mindplot/src/main/javascript/util/Shape.js @@ -68,7 +68,7 @@ mindplot.util.Shape = var y = sPos.y - tPos.y; var gradient = 0; - if (x) + if (core.Utils.isDefined(x)) { gradient = y / x; } diff --git a/web2d/src/main/javascript/Element.js b/web2d/src/main/javascript/Element.js index 2b6a2506..fb5e1d5a 100644 --- a/web2d/src/main/javascript/Element.js +++ b/web2d/src/main/javascript/Element.js @@ -42,7 +42,7 @@ web2d.Element.prototype._initialize = function(attributes) { var funcName = this._attributeNameToFuncName(key, 'set'); var funcArgs = batchExecute[funcName]; - if (!funcArgs) + if (!core.Utils.isDefined(funcArgs)) { funcArgs = []; } @@ -63,7 +63,7 @@ web2d.Element.prototype._initialize = function(attributes) for (var key in batchExecute) { var func = this[key]; - if (!func) + if (!core.Utils.isDefined(func)) { throw "Could not find function: " + key; } @@ -223,7 +223,7 @@ web2d.Element.prototype._propertyNameToSignature = web2d.Element.prototype._attributeNameToFuncName = function(attributeKey, prefix) { var signature = this._propertyNameToSignature[attributeKey]; - if (!signature) + if (!core.Utils.isDefined(signature)) { throw "Unsupported attribute: " + attributeKey; } @@ -292,13 +292,13 @@ web2d.Element.prototype.getAttribute = function(key) var getterResult = getter.apply(this, []); var attibuteName = signature[2]; - if (!attibuteName) + if (!core.Utils.isDefined(attibuteName)) { throw "Could not find attribute mapping for:" + key; } var result = getterResult[attibuteName]; - if (!result) + if (!core.Utils.isDefined(result)) { throw "Could not find attribute with name:" + attibuteName; } diff --git a/web2d/src/main/javascript/EventDispatcher.js b/web2d/src/main/javascript/EventDispatcher.js index dd368c97..61b558a3 100644 --- a/web2d/src/main/javascript/EventDispatcher.js +++ b/web2d/src/main/javascript/EventDispatcher.js @@ -35,7 +35,7 @@ web2d.EventDispatcher = function(element) web2d.EventDispatcher.prototype.addListener = function(type, listener) { - if (!listener) + if (!core.Utils.isDefined(listener)) { throw "Listener can not be null."; } @@ -44,7 +44,7 @@ web2d.EventDispatcher.prototype.addListener = function(type, listener) web2d.EventDispatcher.prototype.removeListener = function(type, listener) { - if (!listener) + if (!core.Utils.isDefined(listener)) { throw "Listener can not be null."; } diff --git a/web2d/src/main/javascript/Group.js b/web2d/src/main/javascript/Group.js index f22444f6..d154920c 100644 --- a/web2d/src/main/javascript/Group.js +++ b/web2d/src/main/javascript/Group.js @@ -37,7 +37,7 @@ objects.extend(web2d.Group, web2d.Element); */ web2d.Group.prototype.removeChild = function(element) { - if (!element) + if (!core.Utils.isDefined(element)) { throw "Child element can not be null"; } @@ -61,7 +61,7 @@ web2d.Group.prototype.removeChild = function(element) */ web2d.Group.prototype.appendChild = function(element) { - if (!element) + if (!core.Utils.isDefined(element)) { throw "Child element can not be null"; } @@ -144,7 +144,7 @@ web2d.Group.prototype.getCoordSize = function() web2d.Group.prototype.appendDomChild = function(DomElement) { - if (!DomElement) + if (!core.Utils.isDefined(DomElement)) { throw "Child element can not be null"; } diff --git a/web2d/src/main/javascript/Workspace.js b/web2d/src/main/javascript/Workspace.js index fa97fc87..896266c5 100644 --- a/web2d/src/main/javascript/Workspace.js +++ b/web2d/src/main/javascript/Workspace.js @@ -56,7 +56,7 @@ web2d.Workspace.prototype._disableTextSelection = function() contaier.onselectstart = new Function("return false"); //if the browser is NS6 - if (window.sidebar) + if (core.Utils.isDefined(window.sidebar)) { contaier.onmousedown = disabletext; contaier.onclick = reEnable; @@ -73,7 +73,7 @@ web2d.Workspace.prototype.getType = function() */ web2d.Workspace.prototype.appendChild = function(element) { - if (!element) + if (!core.Utils.isDefined(element)) { throw "Child element can not be null"; } @@ -96,7 +96,7 @@ web2d.Workspace.prototype.appendChild = function(element) */ web2d.Workspace.prototype.addItAsChildTo = function(element) { - if (!element) + if (!core.Utils.isDefined(element)) { throw "Workspace div container can not be null"; } @@ -232,7 +232,7 @@ web2d.Workspace.prototype.getCoordSize = function() */ web2d.Workspace.prototype.removeChild = function(element) { - if (!element) + if (!core.Utils.isDefined(element)) { throw "Child element can not be null"; } diff --git a/web2d/src/main/javascript/peer/svg/ElementPeer.js b/web2d/src/main/javascript/peer/svg/ElementPeer.js index 06e62997..b60a4133 100644 --- a/web2d/src/main/javascript/peer/svg/ElementPeer.js +++ b/web2d/src/main/javascript/peer/svg/ElementPeer.js @@ -36,7 +36,7 @@ web2d.peer.svg.ElementPeer.prototype.setChildren = function(children) web2d.peer.svg.ElementPeer.prototype.getChildren = function() { var result = this._children; - if (!result) + if (!core.Utils.isDefined(result)) { result = []; this._children = result; @@ -270,7 +270,7 @@ web2d.peer.svg.ElementPeer.prototype.updateStrokeStyle = function() web2d.peer.svg.ElementPeer.prototype.attachChangeEventListener = function(type, listener) { var listeners = this.getChangeEventListeners(type); - if (!listener) + if (!core.Utils.isDefined(listener)) { throw "Listener can not be null"; } @@ -280,7 +280,7 @@ web2d.peer.svg.ElementPeer.prototype.attachChangeEventListener = function(type, web2d.peer.svg.ElementPeer.prototype.getChangeEventListeners = function(type) { var listeners = this._changeListeners[type]; - if (!listeners) + if (!core.Utils.isDefined(listeners)) { listeners = []; this._changeListeners[type] = listeners; diff --git a/web2d/src/main/javascript/peer/svg/RectPeer.js b/web2d/src/main/javascript/peer/svg/RectPeer.js index e85af16a..f48188f3 100644 --- a/web2d/src/main/javascript/peer/svg/RectPeer.js +++ b/web2d/src/main/javascript/peer/svg/RectPeer.js @@ -53,7 +53,7 @@ web2d.peer.svg.RectPeer.prototype.setSize = function(width, height) web2d.peer.svg.RectPeer.superClass.setSize.call(this, width, height); var min = width < height?width:height; - if (this._arc) + if (core.Utils.isDefined(this._arc)) { // Transform percentages to SVG format. var arc = (min / 2) * this._arc; diff --git a/web2d/src/main/javascript/peer/svg/TextPeer.js b/web2d/src/main/javascript/peer/svg/TextPeer.js index 4dbea947..270bcb46 100644 --- a/web2d/src/main/javascript/peer/svg/TextPeer.js +++ b/web2d/src/main/javascript/peer/svg/TextPeer.js @@ -45,7 +45,7 @@ web2d.peer.svg.TextPeer.prototype.setText = function(text) { text = core.Utils.escapeInvalidTags(text); var child = this._native.firstChild; - if (child) + if (core.Utils.isDefined(child)) { this._native.removeChild(child); } @@ -63,7 +63,7 @@ web2d.peer.svg.TextPeer.prototype.setPosition = function(x, y) { this._position = {x:x, y:y}; var height = this._font.getSize(); - if(this._parent && this._native.getBBox) + if(core.Utils.isDefined(this._parent) && core.Utils.isDefined(this._native.getBBox)) height = this.getHeight(); var size = parseInt(height); this._native.setAttribute('y', y+size*3/4); diff --git a/web2d/src/main/javascript/peer/utils/EventUtils.js b/web2d/src/main/javascript/peer/utils/EventUtils.js index 71570f07..758d2fde 100644 --- a/web2d/src/main/javascript/peer/utils/EventUtils.js +++ b/web2d/src/main/javascript/peer/utils/EventUtils.js @@ -21,7 +21,7 @@ web2d.peer.utils.EventUtils = broadcastChangeEvent:function (elementPeer, type) { var listeners = elementPeer.getChangeEventListeners(type); - if (listeners) + if (core.Utils.isDefined(listeners)) { for (var i = 0; i < listeners.length; i++) { diff --git a/wise-webapp/src/main/java/com/wisemapping/importer/freemind/FreemindImporter.java b/wise-webapp/src/main/java/com/wisemapping/importer/freemind/FreemindImporter.java index ab21d80c..f0a42ba1 100755 --- a/wise-webapp/src/main/java/com/wisemapping/importer/freemind/FreemindImporter.java +++ b/wise-webapp/src/main/java/com/wisemapping/importer/freemind/FreemindImporter.java @@ -388,7 +388,7 @@ public class FreemindImporter || freeChild.getPOSITION()==null && isOnLeftSide(wiseParent)) fix=BigInteger.valueOf(-1L); BigInteger firstLevelDistance = BigInteger.valueOf(0L); - BigInteger defaultXDistance = BigInteger.valueOf(100L); + BigInteger defaultXDistance = BigInteger.valueOf(200L); if(depth==1){ firstLevelDistance = BigInteger.valueOf(200L); defaultXDistance = BigInteger.valueOf(0L);