From 67c4968aca516667bd960a1cf7efccb061442958 Mon Sep 17 00:00:00 2001 From: Pablo Luna Date: Mon, 13 Dec 2010 11:07:20 -0300 Subject: [PATCH] Adding model update, model migrator, curved line support, relationship lines, remove of web-services classes --- README.markup | 51 --- README.md | 51 --- core-js/src/main/javascript/Point.js | 45 +- core-js/src/main/javascript/Utils.js | 54 ++- mindplot/pom.xml | 24 +- .../src/main/javascript/Beta2PelaMigrator.js | 17 + mindplot/src/main/javascript/CentralTopic.js | 62 ++- .../src/main/javascript/ConnectionLine.js | 141 +++++-- mindplot/src/main/javascript/ControlPoint.js | 155 +++++++ .../main/javascript/DesignerActionRunner.js | 8 + mindplot/src/main/javascript/MainTopic.js | 95 ++--- mindplot/src/main/javascript/Mindmap.js | 73 +++- .../src/main/javascript/MindmapDesigner.js | 153 ++++++- mindplot/src/main/javascript/ModelCodeName.js | 4 + mindplot/src/main/javascript/NodeModel.js | 38 +- .../src/main/javascript/PersistanceManager.js | 20 +- .../src/main/javascript/RelationshipModel.js | 88 ++++ mindplot/src/main/javascript/Topic.js | 148 +++++-- mindplot/src/main/javascript/Workspace.js | 12 + .../javascript/XMLMindmapSerializerFactory.js | 46 ++ ...alizer.js => XMLMindmapSerializer_Beta.js} | 47 +-- .../javascript/XMLMindmapSerializer_Pela.js | 397 ++++++++++++++++++ .../commands/AddRelationshipCommand.js | 19 + .../javascript/commands/DeleteTopicCommand.js | 19 +- .../commands/MoveControlPointCommand.js | 59 +++ web2d/pom.xml | 2 + web2d/src/main/javascript/CurvedLine.js | 112 +++++ web2d/src/main/javascript/Line.js | 48 ++- web2d/src/main/javascript/Toolkit.js | 12 +- .../javascript/peer/svg/CurvedLinePeer.js | 223 ++++++++++ .../src/main/javascript/peer/svg/LinePeer.js | 51 ++- .../main/javascript/peer/svg/PolyLinePeer.js | 40 +- .../test/javascript/render/curvedLine.html | 116 +++++ wise-webapp/pom.xml | 4 +- .../java/com/wisemapping/mail/Mailer.java | 2 +- .../wisemapping/service/UserServiceImpl.java | 41 +- .../com/wisemapping/ws/WiseWsEndpoint.java | 160 ------- wise-webapp/src/main/resources/mindmap.xsd | 15 +- wise-webapp/src/main/webapp/css/editor.css | 10 +- wise-webapp/src/main/webapp/js/editor.js | 15 +- wise-webapp/src/main/webapp/js/embedded.js | 3 +- wise-webapp/src/main/webapp/jsp/footer.jsp | 3 +- wise-webapp/src/main/webapp/jsp/header.jsp | 1 + .../src/main/webapp/jsp/mindmapEditor.jsp | 7 +- wise-webapp/src/main/webapp/jsp/template.jsp | 1 + .../ws/test/WiseWebServicesTest.java | 100 ----- 46 files changed, 2074 insertions(+), 718 deletions(-) delete mode 100644 README.markup delete mode 100644 README.md create mode 100644 mindplot/src/main/javascript/Beta2PelaMigrator.js create mode 100644 mindplot/src/main/javascript/ControlPoint.js create mode 100644 mindplot/src/main/javascript/ModelCodeName.js create mode 100644 mindplot/src/main/javascript/RelationshipModel.js rename mindplot/src/main/javascript/{XMLMindmapSerializer.js => XMLMindmapSerializer_Beta.js} (79%) create mode 100644 mindplot/src/main/javascript/XMLMindmapSerializer_Pela.js create mode 100644 mindplot/src/main/javascript/commands/AddRelationshipCommand.js create mode 100644 mindplot/src/main/javascript/commands/MoveControlPointCommand.js create mode 100644 web2d/src/main/javascript/CurvedLine.js create mode 100644 web2d/src/main/javascript/peer/svg/CurvedLinePeer.js create mode 100644 web2d/src/test/javascript/render/curvedLine.html delete mode 100644 wise-webapp/src/main/java/com/wisemapping/ws/WiseWsEndpoint.java delete mode 100644 wise-webapp/src/test/java/com/wisemapping/ws/test/WiseWebServicesTest.java diff --git a/README.markup b/README.markup deleted file mode 100644 index 1db54c98..00000000 --- a/README.markup +++ /dev/null @@ -1,51 +0,0 @@ -# WiseMapping: a Web based mindmapping application - -## Project Information - -The goal of this project is to provide a high quality product that can be deployed by educational and academic institutions, private and public companies and anyone who needs to have a mindmapping application. WiseMapping is based on the same code source supporting WiseMapping.com. - -## Compiling and Running - -### Prerequisites - -The following products must be installed: - - * Java Development Kit 6 or higher (http://java.sun.com/javase/downloads/index.jsp) - * Maven 2.2.1 or higher (http://maven.apache.org/) - -### Compiling - -WiseMapping uses Maven as packaging and project management. The project is composed of 4 maven sub-modules: - - * core-js: Utilities JavaScript libraries - * web2d: JavaScript 2D VML/SVG abstraction library used by the mind map editor - * mindplot: JavaScript mind map designer core - * wise-webapp: J2EE web application - -Full compilation of the project can be done executing within : - -`mvn install` - -Once this command is execute, the file /wise-webapp/target/wisemapping.war will be generated. - -### Testing -The previously generated war can be deployed locally executing within the directory /wise-webapp the following command: - -`mvn jetty:run-war` - -This will start the application on the URL: http://localhost:8080/wise-webapp/. Additionally, a file based database is automatically populated with a test user. - -User: test@wisemapping.org -Password: test - -## Author - -Pablo Luna -Paulo Veiga -Ignacio Manzano -Nicolas Damonte - -## License - -The source code is Licensed under the Apache License, Version 2.0 (the “License”); -You may obtain a copy of the License at: http://www.apache.org/licenses/LICENSE-2.0 \ No newline at end of file diff --git a/README.md b/README.md deleted file mode 100644 index 024cbef8..00000000 --- a/README.md +++ /dev/null @@ -1,51 +0,0 @@ -# WiseMapping: a Web based mindmapping application - -## Project Information - -The goal of this project is to provide a high quality product that can be deployed by educational and academic institutions, private and public companies and anyone who needs to have a mindmapping application. WiseMapping is based on the same code source supporting WiseMapping.com. - -## Compiling and Running - -### Prerequisites - -The following products must be installed: - - * Java Development Kit 6 or higher (http://java.sun.com/javase/downloads/index.jsp) - * Maven 2.2.1 or higher (http://maven.apache.org/) - -### Compiling - -WiseMapping uses Maven as packaging and project management. The project is composed of 4 maven sub-modules: - - * core-js: Utilities JavaScript libraries - * web2d: JavaScript 2D VML/SVG abstraction library used by the mind map editor - * mindplot: JavaScript mind map designer core - * wise-webapp: J2EE web application - -Full compilation of the project can be done executing within : - -`mvn install` - -Once this command is execute, the file /wise-webapp/target/wisemapping.war will be generated. - -### Testing -The previously generated war can be deployed locally executing within the directory /wise-webapp the following command: - -`mvn jetty:run-war` - -This will start the application on the URL: http://localhost:8080/wise-webapp/. Additionally, a file based database is automatically populated with a test user. - -User: test@wisemapping.org -Password: test - -## Author - - * Pablo Luna - * Paulo Veiga - * Ignacio Manzano - * Nicolas Damonte - -## License - -The source code is Licensed under the Apache License, Version 2.0 (the “License”); -You may obtain a copy of the License at: http://www.apache.org/licenses/LICENSE-2.0 diff --git a/core-js/src/main/javascript/Point.js b/core-js/src/main/javascript/Point.js index 3eec455b..892d647b 100644 --- a/core-js/src/main/javascript/Point.js +++ b/core-js/src/main/javascript/Point.js @@ -1,22 +1,22 @@ -/* -* Licensed to the Apache Software Foundation (ASF) under one or more -* contributor license agreements. See the NOTICE file distributed with -* this work for additional information regarding copyright ownership. -* The ASF licenses this file to You under the Apache License, Version 2.0 -* (the "License"); you may not use this file except in compliance with -* the License. You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* 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. -* -* $Id: file 64488 2006-03-10 17:32:09Z paulo $ -*/ - +/* +* Licensed to the Apache Software Foundation (ASF) under one or more +* contributor license agreements. See the NOTICE file distributed with +* this work for additional information regarding copyright ownership. +* The ASF licenses this file to You under the Apache License, Version 2.0 +* (the "License"); you may not use this file except in compliance with +* the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* 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. +* +* $Id: file 64488 2006-03-10 17:32:09Z paulo $ +*/ + core.Point = function(x, y) { this.x = x; @@ -37,4 +37,9 @@ core.Point.prototype.inspect = function() core.Point.prototype.clone = function() { return new core.Point(this.x, this.y); -}; \ No newline at end of file +}; + +core.Point.fromString = function(point) { + var values = point.split(','); + return new core.Point(values[0], values[1]); +}; diff --git a/core-js/src/main/javascript/Utils.js b/core-js/src/main/javascript/Utils.js index e61fa982..33223333 100644 --- a/core-js/src/main/javascript/Utils.js +++ b/core-js/src/main/javascript/Utils.js @@ -64,7 +64,8 @@ core.assert = function(assert, message) { stack = e; } - core.Logger.logError(message + "," + stack); + wLogger.error(message + "," + stack); +// core.Logger.logError(message + "," + stack); } }; @@ -220,3 +221,54 @@ core.Utils.createDocumentFromText = function(/*string*/str, /*string?*/mimetype) } return null; }; + +core.Utils.calculateRelationShipPointCoordinates = function(topic,controlPoint){ + var size = topic.getSize(); + var position = topic.getPosition(); + var m = (position.y-controlPoint.y)/(position.x-controlPoint.x); + var y,x; + var gap = 5; + if(controlPoint.y>position.y+(size.height/2)){ + y = position.y+(size.height/2)+gap; + x = position.x-((position.y-y)/m); + if(x>position.x+(size.width/2)){ + x=position.x+(size.width/2); + }else if(xposition.x+(size.width/2)){ + x=position.x+(size.width/2); + }else if(xtarPos.x){ + fix=-1; + } + + var x1 = srcPos.x + Math.sqrt(l*l/(1+(m*m)))*fix; + var y1 = m*(x1-srcPos.x)+srcPos.y; + 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(x1,y1),new core.Point(x2,y2)]; +}; \ No newline at end of file diff --git a/mindplot/pom.xml b/mindplot/pom.xml index 3d1645c9..724e9205 100644 --- a/mindplot/pom.xml +++ b/mindplot/pom.xml @@ -40,6 +40,7 @@ + @@ -62,7 +63,11 @@ - + + + + + @@ -75,11 +80,10 @@ - - + - + + @@ -144,6 +151,7 @@ header-min.js Mindmap-min.js NodeModel-min.js + RelationshipModel-min.js MindmapDesigner-min.js ScreenManager-min.js Workspace-min.js @@ -166,7 +174,11 @@ util/Shape-min.js FixedDistanceBoard-min.js BoardEntry-min.js - XMLMindmapSerializer-min.js + ModelCodeName-min.js + XMLMindmapSerializer_Beta-min.js + XMLMindmapSerializer_Pela-min.js + Beta2PelaMigrator-min.js + XMLMindmapSerializerFactory-min.js PersistanceManager-min.js EditorProperties-min.js IconGroup-min.js @@ -194,6 +206,8 @@ commands/RemoveIconFromTopicCommand-min.js commands/AddNoteToTopicCommand-min.js commands/RemoveNoteFromTopicCommand-min.js + commands/AddRelationshipCommand-min.js + commands/MoveControlPointCommand-min.js footer-min.js diff --git a/mindplot/src/main/javascript/Beta2PelaMigrator.js b/mindplot/src/main/javascript/Beta2PelaMigrator.js new file mode 100644 index 00000000..a27513b1 --- /dev/null +++ b/mindplot/src/main/javascript/Beta2PelaMigrator.js @@ -0,0 +1,17 @@ +mindplot.Beta2PelaMigrator = function(betaSerializer){ + this._betaSerializer=betaSerializer; + this._pelaSerializer = new mindplot.XMLMindmapSerializer_Pela(); +}; + +mindplot.Beta2PelaMigrator.prototype.toXML = function(mindmap) +{ + return this._pelaSerializer.toXML(mindmap); +}; + + +mindplot.Beta2PelaMigrator.prototype.loadFromDom = function(dom) +{ + var mindmap = this._betaSerializer.loadFromDom(dom); + mindmap.setVersion(mindplot.ModelCodeName.PELA); + return mindmap; +}; diff --git a/mindplot/src/main/javascript/CentralTopic.js b/mindplot/src/main/javascript/CentralTopic.js index 38c9ce0a..da627bad 100644 --- a/mindplot/src/main/javascript/CentralTopic.js +++ b/mindplot/src/main/javascript/CentralTopic.js @@ -1,22 +1,22 @@ -/* -* Licensed to the Apache Software Foundation (ASF) under one or more -* contributor license agreements. See the NOTICE file distributed with -* this work for additional information regarding copyright ownership. -* The ASF licenses this file to You under the Apache License, Version 2.0 -* (the "License"); you may not use this file except in compliance with -* the License. You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* 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. -* -* $Id: file 64488 2006-03-10 17:32:09Z paulo $ -*/ - +/* +* Licensed to the Apache Software Foundation (ASF) under one or more +* contributor license agreements. See the NOTICE file distributed with +* this work for additional information regarding copyright ownership. +* The ASF licenses this file to You under the Apache License, Version 2.0 +* (the "License"); you may not use this file except in compliance with +* the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* 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. +* +* $Id: file 64488 2006-03-10 17:32:09Z paulo $ +*/ + mindplot.CentralTopic = function(model) { core.assert(model, "Model can not be null"); @@ -29,9 +29,29 @@ mindplot.CentralTopic = function(model) objects.extend(mindplot.CentralTopic, mindplot.Topic); -mindplot.CentralTopic.prototype.workoutIncomingConnectionPoint = function(sourcePosition) +mindplot.CentralTopic.prototype.workoutIncomingConnectionPoint = function(sourcePosition, onBoundingBox) { - return this.getPosition(); + if(!core.Utils.isDefined(onBoundingBox)){ + onBoundingBox=false; + } + var pos = this.getPosition(); + var size = this.getSize(); + var isAtRight = mindplot.util.Shape.isAtRight(sourcePosition, pos); + var result = null; + if(onBoundingBox){ + result = new core.Point(); + if(isAtRight){ + console.log("incomming at right"); + result.x = pos.x - (size.width/2)-20; + result.y = pos.y; + } else { + result.x = pos.x; + result.y = pos.y; + } + }else{ + result = pos; + } + return result; }; mindplot.CentralTopic.prototype.getTopicType = function() diff --git a/mindplot/src/main/javascript/ConnectionLine.js b/mindplot/src/main/javascript/ConnectionLine.js index 11bf0282..0e959471 100644 --- a/mindplot/src/main/javascript/ConnectionLine.js +++ b/mindplot/src/main/javascript/ConnectionLine.js @@ -1,23 +1,23 @@ -/* -* Licensed to the Apache Software Foundation (ASF) under one or more -* contributor license agreements. See the NOTICE file distributed with -* this work for additional information regarding copyright ownership. -* The ASF licenses this file to You under the Apache License, Version 2.0 -* (the "License"); you may not use this file except in compliance with -* the License. You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* 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. -* -* $Id: file 64488 2006-03-10 17:32:09Z paulo $ -*/ - -mindplot.ConnectionLine = function(sourceNode, targetNode) +/* +* Licensed to the Apache Software Foundation (ASF) under one or more +* contributor license agreements. See the NOTICE file distributed with +* this work for additional information regarding copyright ownership. +* The ASF licenses this file to You under the Apache License, Version 2.0 +* (the "License"); you may not use this file except in compliance with +* the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* 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. +* +* $Id: file 64488 2006-03-10 17:32:09Z paulo $ +*/ + +mindplot.ConnectionLine = function(sourceNode, targetNode, lineType) { core.assert(targetNode, 'parentNode node can not be null'); core.assert(sourceNode, 'childNode node can not be null'); @@ -25,22 +25,50 @@ mindplot.ConnectionLine = function(sourceNode, targetNode) this._targetTopic = targetNode; this._sourceTopic = sourceNode; + this._isRelationship=false; var strokeColor = mindplot.ConnectionLine.getStrokeColor(); var line; if (targetNode.getType() == mindplot.NodeModel.CENTRAL_TOPIC_TYPE) { - line = new web2d.Line(); + line = this._createLine(lineType,mindplot.ConnectionLine.SIMPLE); +// line = new web2d.Line(); line.setStroke(1, 'solid', strokeColor); } else { - line = new web2d.PolyLine(); + line = this._createLine(lineType,mindplot.ConnectionLine.POLYLINE); +// line = new web2d.PolyLine(); line.setStroke(1, 'solid', strokeColor); } this._line2d = line; }; +mindplot.ConnectionLine.prototype._createLine = function(lineType, defaultStyle){ + if(!core.Utils.isDefined(lineType)){ + lineType = defaultStyle; + } + lineType = parseInt(lineType); + this._lineType = lineType; + var line = null; + switch(lineType){ + case mindplot.ConnectionLine.POLYLINE: + line = new web2d.PolyLine(); + break; + case mindplot.ConnectionLine.CURVED: + line = new web2d.CurvedLine(); + break; + case mindplot.ConnectionLine.SIMPLE_CURVED: + line = new web2d.CurvedLine(); + line.setStyle(web2d.CurvedLine.SIMPLE_LINE); + break; + default: + line = new web2d.Line(); + break; + } + return line; +} + mindplot.ConnectionLine.getStrokeColor = function() { return '#495879'; @@ -61,11 +89,28 @@ mindplot.ConnectionLine.prototype.redraw = function() var targetTopic = this._targetTopic; var targetPosition = targetTopic.getPosition(); - var sPos = sourceTopic.workoutOutgoingConnectionPoint(targetPosition); - line2d.setTo(sPos.x, sPos.y); + var sPos,tPos; + if(this._isRelationship){ + this._line2d.setStroke(2); + var ctrlPoints = this._line2d.getControlPoints(); + if(!core.Utils.isDefined(ctrlPoints[0].x) || !core.Utils.isDefined(ctrlPoints[1].x)){ + var defaultPoints = core.Utils.calculateDefaultControlPoints(sourceTopic.getPosition(), targetTopic.getPosition()); + ctrlPoints[0].x=defaultPoints[0].x; + ctrlPoints[0].y=defaultPoints[0].y; + ctrlPoints[1].x=defaultPoints[1].x; + ctrlPoints[1].y=defaultPoints[1].y; + } + sPos = core.Utils.calculateRelationShipPointCoordinates(sourceTopic,ctrlPoints[0]); + tPos = core.Utils.calculateRelationShipPointCoordinates(targetTopic,ctrlPoints[1]); + }else{ + sPos = sourceTopic.workoutOutgoingConnectionPoint(targetPosition, false); + tPos = targetTopic.workoutIncomingConnectionPoint(sourcePosition, false); + } + // console.log("source:"+sPos.x+":"+sPos.y); - var tPos = targetTopic.workoutIncomingConnectionPoint(sourcePosition); - line2d.setFrom(tPos.x, tPos.y); + line2d.setFrom(sPos.x, sPos.y); +// console.log("target:"+tPos.x+":"+tPos.y); + line2d.setTo(tPos.x, tPos.y); line2d.moveToBack(); @@ -111,6 +156,14 @@ mindplot.ConnectionLine.prototype.setStroke = function(color, style, opacity) mindplot.ConnectionLine.prototype.addToWorkspace = function(workspace) { + if(this._line2d.getType() == "CurvedLine"){ + this._line2d.addEventListener('click',function(event){ + var controlPoints = workspace.getLineControlPoints(); + controlPoints.setLine(this); + controlPoints.setVisibility(true); + event.stopPropagation(); + }.bind(this)); + } workspace.appendChild(this._line2d); }; @@ -122,4 +175,38 @@ mindplot.ConnectionLine.prototype.removeFromWorkspace = function(workspace) mindplot.ConnectionLine.prototype.getTargetTopic = function() { return this._targetTopic; -}; \ No newline at end of file +}; + +mindplot.ConnectionLine.prototype.getSourceTopic = function() +{ + return this._sourceTopic; +}; + +mindplot.ConnectionLine.prototype.getLineType = function(){ + return this._lineType; +}; + +mindplot.ConnectionLine.prototype.getLine = function(){ + return this._line2d; +}; + +mindplot.ConnectionLine.prototype.getModel = function(){ + return this._model; +}; + +mindplot.ConnectionLine.prototype.setModel = function(model){ + this._model = model; +}; + +mindplot.ConnectionLine.prototype.setIsRelationship = function(isRelationship){ + this._isRelationship=isRelationship; +}; + +mindplot.ConnectionLine.prototype.isRelationship = function(){ + return this._isRelationship; +}; + +mindplot.ConnectionLine.SIMPLE=0; +mindplot.ConnectionLine.POLYLINE=1; +mindplot.ConnectionLine.CURVED=2; +mindplot.ConnectionLine.SIMPLE_CURVED=3; \ No newline at end of file diff --git a/mindplot/src/main/javascript/ControlPoint.js b/mindplot/src/main/javascript/ControlPoint.js new file mode 100644 index 00000000..d3551046 --- /dev/null +++ b/mindplot/src/main/javascript/ControlPoint.js @@ -0,0 +1,155 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * 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. + * + * $Id: file 64488 2006-03-10 17:32:09Z paulo $ + */ + +mindplot.ControlPoint = function() +{ + this._controlPoints= [new web2d.Elipse({width:6, height:6, stroke:'1 solid #6589de',fillColor:'gray', visibility:false}), + new web2d.Elipse({width:6, height:6, stroke:'1 solid #6589de',fillColor:'gray', visibility:false})]; + this._controlLines=[new web2d.Line({strokeColor:"#6589de", strokeWidth:1, opacity:0.3}), + new web2d.Line({strokeColor:"#6589de", strokeWidth:1, opacity:0.3})]; + this._isBinded=false; + this._controlPoints[0].addEventListener('mousedown',this._mouseDown.bindWithEvent(this, mindplot.ControlPoint.FROM)); + this._controlPoints[0].addEventListener('click',this._mouseClick.bindWithEvent(this)); + this._controlPoints[0].addEventListener('dblclick',this._mouseClick.bindWithEvent(this)); + this._controlPoints[1].addEventListener('mousedown',this._mouseDown.bindWithEvent(this,mindplot.ControlPoint.TO)); + this._controlPoints[1].addEventListener('click',this._mouseClick.bindWithEvent(this)); + this._controlPoints[1].addEventListener('dblclick',this._mouseClick.bindWithEvent(this)); + this._mouseClickOnBackgroundFunction = this._mouseClickOnBackground.bind(this); +}; + +mindplot.ControlPoint.prototype.setSide= function(side) { + this._side = side; +}; + +mindplot.ControlPoint.prototype.setLine= function(line) { + if(core.Utils.isDefined(this._line)){ + this._removeLine(); + } + this._line= line; + this._createControlPoint(); +}; + +mindplot.ControlPoint.prototype._createControlPoint = function() { + this._controls= this._line.getLine().getControlPoints(); + this._controlPoints[0].setPosition(this._controls[mindplot.ControlPoint.FROM].x, this._controls[mindplot.ControlPoint.FROM].y-3); + this._controlPoints[1].setPosition(this._controls[mindplot.ControlPoint.TO].x, this._controls[mindplot.ControlPoint.TO].y-3); + var pos = this._line.getLine().getFrom(); + this._controlLines[0].setFrom(pos.x, pos.y); + this._controlLines[0].setTo(this._controls[mindplot.ControlPoint.FROM].x+3, this._controls[mindplot.ControlPoint.FROM].y); + pos = this._line.getLine().getTo(); + this._controlLines[1].setFrom(pos.x, pos.y); + this._controlLines[1].setTo(this._controls[mindplot.ControlPoint.TO].x+3, this._controls[mindplot.ControlPoint.TO].y); + +}; + +mindplot.ControlPoint.prototype._removeLine= function() { + +}; + +mindplot.ControlPoint.prototype._mouseDown = function(event, point) { + if(!this._isBinded){ + this._isBinded=true; + this._mouseMoveFunction = this._mouseMove.bindWithEvent(this,point); + this._workspace.getScreenManager().addEventListener('mousemove',this._mouseMoveFunction); + this._mouseUpFunction = this._mouseUp.bindWithEvent(this,point); + this._workspace.getScreenManager().addEventListener('mouseup',this._mouseUpFunction); + } + event.preventDefault(); + event.stop(); + return false; +}; + +mindplot.ControlPoint.prototype._mouseMove = function(event, point) { + var screen = this._workspace.getScreenManager(); + var pos = screen.getWorkspaceMousePosition(event); + var topic = null; + if(point==0){ + var cords = core.Utils.calculateRelationShipPointCoordinates(this._line.getSourceTopic(),pos); + this._line.getLine().setFrom(cords.x, cords.y); + }else{ + var cords = core.Utils.calculateRelationShipPointCoordinates(this._line.getTargetTopic(),pos); + this._line.getLine().setTo(cords.x, cords.y); + } + this._controls[point].x=pos.x; + this._controls[point].y=pos.y; + this._controlPoints[point].setPosition(pos.x-5,pos.y-3); + this._controlLines[point].setFrom(cords.x, cords.y); + this._controlLines[point].setTo(pos.x-2,pos.y); + this._line.getLine().updateLine(point); + /*event.preventDefault(); + event.stop(); + return false;*/ +}; + +mindplot.ControlPoint.prototype._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!! + this._isBinded=false; + /*event.preventDefault(); + event.stop(); + return false;*/ +}; + +mindplot.ControlPoint.prototype._mouseClick = function(event){ + event.preventDefault(); + event.stop(); + return false; +}; + +mindplot.ControlPoint.prototype._mouseClickOnBackground = function(event){ + this.setVisibility(false); +}; + +mindplot.ControlPoint.prototype.setVisibility = function(visible){ + if(visible){ + this._workspace.getScreenManager().addEventListener('mousedown',this._mouseClickOnBackgroundFunction); + this._controlLines[0].moveToFront(); + this._controlLines[1].moveToFront(); + this._controlPoints[0].moveToFront(); + this._controlPoints[1].moveToFront(); + } + else{ + this._workspace.getScreenManager().removeEventListener('mousedown',this._mouseClickOnBackgroundFunction); + } + this._controlPoints[0].setVisibility(visible); + this._controlPoints[1].setVisibility(visible); + this._controlLines[0].setVisibility(visible); + this._controlLines[1].setVisibility(visible); +}; + +mindplot.ControlPoint.prototype.addToWorkspace = function(workspace){ + this._workspace = workspace; + workspace.appendChild(this._controlPoints[0]); + workspace.appendChild(this._controlPoints[1]); + workspace.appendChild(this._controlLines[0]); + workspace.appendChild(this._controlLines[1]); +}; + +mindplot.ControlPoint.prototype.removeFromWorkspace = function(workspace){ + this._workspace = null; + workspace.removeChild(this._controlPoints[0]); + workspace.removeChild(this._controlPoints[1]); + workspace.removeChild(this._controlLines[0]); + workspace.removeChild(this._controlLines[1]); +}; + +mindplot.ControlPoint.FROM = 0; +mindplot.ControlPoint.TO = 1; diff --git a/mindplot/src/main/javascript/DesignerActionRunner.js b/mindplot/src/main/javascript/DesignerActionRunner.js index 05d6f45a..ed2781c0 100644 --- a/mindplot/src/main/javascript/DesignerActionRunner.js +++ b/mindplot/src/main/javascript/DesignerActionRunner.js @@ -117,6 +117,14 @@ mindplot.CommandContext = new Class({ disconnect:function(topic) { topic.disconnect(this._designer._workspace); + }, + createRelationship:function(model){ + core.assert(model, "model cannot be null"); + var relationship = this._designer.createRelationship(model); + return relationship; + }, + removeRelationship:function(model) { + this._designer.removeRelationship(model); } }); diff --git a/mindplot/src/main/javascript/MainTopic.js b/mindplot/src/main/javascript/MainTopic.js index 69279bb6..8fd3bcaf 100644 --- a/mindplot/src/main/javascript/MainTopic.js +++ b/mindplot/src/main/javascript/MainTopic.js @@ -1,22 +1,22 @@ -/* -* Licensed to the Apache Software Foundation (ASF) under one or more -* contributor license agreements. See the NOTICE file distributed with -* this work for additional information regarding copyright ownership. -* The ASF licenses this file to You under the Apache License, Version 2.0 -* (the "License"); you may not use this file except in compliance with -* the License. You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* 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. -* -* $Id: file 64488 2006-03-10 17:32:09Z paulo $ -*/ - +/* +* Licensed to the Apache Software Foundation (ASF) under one or more +* contributor license agreements. See the NOTICE file distributed with +* this work for additional information regarding copyright ownership. +* The ASF licenses this file to You under the Apache License, Version 2.0 +* (the "License"); you may not use this file except in compliance with +* the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* 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. +* +* $Id: file 64488 2006-03-10 17:32:09Z paulo $ +*/ + mindplot.MainTopic = function(model) { core.assert(model, "Model can not be null"); @@ -201,13 +201,18 @@ mindplot.MainTopic.prototype.setPosition = function(point) topicBoard.updateChildrenPosition(this); }; -mindplot.MainTopic.prototype.workoutIncomingConnectionPoint = function(sourcePosition) +mindplot.MainTopic.prototype.workoutIncomingConnectionPoint = function(sourcePosition, onBoundingBox) { + if(!core.Utils.isDefined(onBoundingBox)){ + onBoundingBox=false; + } + core.assert(sourcePosition, 'sourcePoint can not be null'); var pos = this.getPosition(); var size = this.getSize(); var isAtRight = mindplot.util.Shape.isAtRight(sourcePosition, pos); + var result = mindplot.util.Shape.calculateRectConnectionPoint(pos, size, isAtRight); if (this.getShapeType() == mindplot.NodeModel.SHAPE_TYPE_LINE) { @@ -223,54 +228,16 @@ mindplot.MainTopic.prototype.workoutIncomingConnectionPoint = function(sourcePos { result.x = result.x - offset; } - return result; - -}; - -mindplot.MainTopic.prototype.workoutOutgoingConnectionPoint = function(targetPosition) -{ - core.assert(targetPosition, 'targetPoint can not be null'); - var pos = this.getPosition(); - var size = this.getSize(); - - var isAtRight = mindplot.util.Shape.isAtRight(targetPosition, pos); - var result; - if (this.getShapeType() == mindplot.NodeModel.SHAPE_TYPE_LINE) - { - if (!this.isConnectedToCentralTopic()) - { - result = new core.Point(); - if (!isAtRight) - { - result.x = pos.x - (size.width / 2); - } else - { - result.x = pos.x + (size.width / 2); - } - result.y = pos.y + (size.height / 2); - } else - { - // In this case, connetion line is not used as shape figure. - result = mindplot.util.Shape.calculateRectConnectionPoint(pos, size, isAtRight, true); - result.y = pos.y + (size.height / 2); - - // Correction factor ... - if (!isAtRight) - { - result.x = result.x + 2; - } else - { - result.x = result.x - 2; - } - + if(onBoundingBox){ + if(isAtRight){ + result.x -= 10; + } else{ + result.x += 10; } - } else - { - result = mindplot.util.Shape.calculateRectConnectionPoint(pos, size, isAtRight, true); } return result; -}; +}; mindplot.MainTopic.prototype.isConnectedToCentralTopic = function() { diff --git a/mindplot/src/main/javascript/Mindmap.js b/mindplot/src/main/javascript/Mindmap.js index f268b3a1..5537b3ab 100644 --- a/mindplot/src/main/javascript/Mindmap.js +++ b/mindplot/src/main/javascript/Mindmap.js @@ -1,27 +1,29 @@ -/* -* Licensed to the Apache Software Foundation (ASF) under one or more -* contributor license agreements. See the NOTICE file distributed with -* this work for additional information regarding copyright ownership. -* The ASF licenses this file to You under the Apache License, Version 2.0 -* (the "License"); you may not use this file except in compliance with -* the License. You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* 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. -* -* $Id: file 64488 2006-03-10 17:32:09Z paulo $ -*/ - +/* +* Licensed to the Apache Software Foundation (ASF) under one or more +* contributor license agreements. See the NOTICE file distributed with +* this work for additional information regarding copyright ownership. +* The ASF licenses this file to You under the Apache License, Version 2.0 +* (the "License"); you may not use this file except in compliance with +* the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* 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. +* +* $Id: file 64488 2006-03-10 17:32:09Z paulo $ +*/ + mindplot.Mindmap = function() { this._branches = []; this._name = null; this._description = null; + this._version=null; + this._relationships=[]; }; mindplot.Mindmap.prototype.getCentralTopic = function() @@ -45,6 +47,20 @@ mindplot.Mindmap.prototype.setId = function(id) this._iconType = id; }; + +mindplot.Mindmap.prototype.getVersion = function() +{ + return this._version; +}; + + +mindplot.Mindmap.prototype.setVersion = function(version) +{ + this._version = version; +}; + + + mindplot.Mindmap.prototype.addBranch = function(nodeModel) { core.assert(nodeModel && nodeModel.isNodeModel(), 'Add node must be invoked with model objects'); @@ -65,6 +81,10 @@ mindplot.Mindmap.prototype.getBranches = function() return this._branches; }; +mindplot.Mindmap.prototype.getRelationships = function() { + return this._relationships; +}; + mindplot.Mindmap.prototype.connect = function(parent, child) { // Child already has a parent ? @@ -120,6 +140,21 @@ mindplot.Mindmap.prototype._createNode = function(type) return result; }; +mindplot.Mindmap.prototype.createRelationship = function(fromNode, toNode){ + core.assert(fromNode, 'from node cannot be null'); + core.assert(toNode, 'to node cannot be null'); + + return new mindplot.RelationshipModel(fromNode, toNode); +}; + +mindplot.Mindmap.prototype.addRelationship = function(relationship) { + this._relationships.push(relationship); +}; + +mindplot.Mindmap.prototype.removeRelationship = function(relationship) { + this._relationships.remove(relationship); +}; + mindplot.Mindmap.prototype.inspect = function() { var result = ''; diff --git a/mindplot/src/main/javascript/MindmapDesigner.js b/mindplot/src/main/javascript/MindmapDesigner.js index 2f074a88..a11d8985 100644 --- a/mindplot/src/main/javascript/MindmapDesigner.js +++ b/mindplot/src/main/javascript/MindmapDesigner.js @@ -17,9 +17,8 @@ * $Id: file 64488 2006-03-10 17:32:09Z paulo $ */ -mindplot.MindmapDesigner = function(profile, divElement, persistanManager) +mindplot.MindmapDesigner = function(profile, divElement) { - core.assert(persistanManager, "Persistant manager must be defined"); core.assert(core.Utils.isDefined(profile.zoom), "zoom must be defined"); // Undo manager ... @@ -53,11 +52,11 @@ mindplot.MindmapDesigner = function(profile, divElement, persistanManager) // Init dragger manager. this._dragger = this._buildDragManager(workspace); - this._persistantManager = persistanManager; - // Add shapes to speed up the loading process ... mindplot.DragTopic.initialize(workspace); + this._relationships={}; + this._events = {}; }; @@ -368,6 +367,62 @@ mindplot.MindmapDesigner.prototype.createSiblingForSelectedNode = function() } }; +mindplot.MindmapDesigner.prototype.addRelationShip2SelectedNode = function(event) +{ + var screen = this._workspace.getScreenManager(); + var pos = screen.getWorkspaceMousePosition(event); + var selectedTopics = this.getSelectedNodes(); + if(selectedTopics.length >0){ + var fromNodePosition = selectedTopics[0].getPosition(); + this._relationship = new web2d.CurvedLine(); + this._relationship.setStyle(web2d.CurvedLine.SIMPLE_LINE); + this._relationship.setDashed(2,2); + this._relationship.setFrom(fromNodePosition.x, fromNodePosition.y); + this._relationship.setTo(pos.x, pos.y); + this._workspace.appendChild(this._relationship); + this._relationshipMouseMoveFunction = this._relationshipMouseMove.bindWithEvent(this); + this._relationshipMouseClickFunction = this._relationshipMouseClick.bindWithEvent(this, selectedTopics[0]); + this._workspace.getScreenManager().addEventListener('mousemove',this._relationshipMouseMoveFunction); + this._workspace.getScreenManager().addEventListener('click',this._relationshipMouseClickFunction); + } +}; + +mindplot.MindmapDesigner.prototype._relationshipMouseMove = function(event){ + var screen = this._workspace.getScreenManager(); + var pos = screen.getWorkspaceMousePosition(event); + this._relationship.setTo(pos.x-1, pos.y-1); //to prevent click event target to be the line itself + event.preventDefault(); + event.stop(); + return false; +}; + +mindplot.MindmapDesigner.prototype._relationshipMouseClick = function (event, fromNode) { + var target = event.target; + while(target.tagName != "g" && core.Utils.isDefined(target.parentNode)){ + target=target.parentNode; + } + if(core.Utils.isDefined(target.virtualRef)){ + var targetNode = target.virtualRef; + this.addRelationship(fromNode, targetNode); + } + this._workspace.removeChild(this._relationship); + this._relationship = null; + this._workspace.getScreenManager().removeEventListener('mousemove',this._relationshipMouseMoveFunction); + this._workspace.getScreenManager().removeEventListener('click',this._relationshipMouseClickFunction); + event.preventDefault(); + event.stop(); + return false; +}; + +mindplot.MindmapDesigner.prototype.addRelationship= function(fromNode, toNode){ + // Create a new topic model ... + 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); +}; + mindplot.MindmapDesigner.prototype.needsSave = function() { return this._actionRunner.hasBeenChanged(); @@ -390,7 +445,7 @@ mindplot.MindmapDesigner.prototype.autoSaveEnabled = function(value) mindplot.MindmapDesigner.prototype.save = function(onSavedHandler, saveHistory) { - var persistantManager = this._persistantManager; + var persistantManager = mindplot.PersistanceManager; var mindmap = this._mindmap; var xmlChart = this._workspace.dumpNativeChart(); @@ -417,7 +472,7 @@ mindplot.MindmapDesigner.prototype.loadFromXML = function(mapId, xmlContent) // Explorer Hack with local files ... var domDocument = core.Utils.createDocumentFromText(xmlContent); - var serializer = new mindplot.XMLMindmapSerializer(); + var serializer = mindplot.XMLMindmapSerializerFactory.getSerializerFromDocument(domDocument); var mindmap = serializer.loadFromDom(domDocument); this._loadMap(mapId, mindmap); @@ -435,7 +490,7 @@ mindplot.MindmapDesigner.prototype.load = function(mapId) core.assert(mapId, 'mapName can not be null'); // Build load function ... - var persistantManager = this._persistantManager; + var persistantManager = mindplot.PersistanceManager; // Loading mindmap ... var mindmap = persistantManager.load(mapId); @@ -469,6 +524,10 @@ mindplot.MindmapDesigner.prototype._loadMap = function(mapId, mindmapModel) // Update shrink render state... nodeGraph.setBranchVisibility(true); } + var relationships = mindmapModel.getRelationships(); + for (var j=0; j0){ +// var relationshipDom=document.createElement("relationships"); +// mapElem.appendChild(relationshipDom); + for (var j = 0; j0){ + var relationship = relationships[0]; + this._deletedRelationships.push(relationship.getModel().clone()); + commandContext.removeRelationship(relationship.getModel()); + } + this._deletedTopicModels.push(model); // Is connected?. @@ -49,7 +59,7 @@ mindplot.commands.DeleteTopicCommand = mindplot.Command.extend( commandContext.deleteTopic(topic); }.bind(this) - ) + ); }, undoExecute: function(commandContext) { @@ -70,9 +80,14 @@ mindplot.commands.DeleteTopicCommand = mindplot.Command.extend( } }.bind(this) - ) + ); + this._deletedRelationships.forEach( + function(relationship, index){ + commandContext.createRelationship(relationship); + }.bind(this)); this._deletedTopicModels = []; this._parentTopicIds = []; + this._deletedRelationships = []; } }); \ No newline at end of file diff --git a/mindplot/src/main/javascript/commands/MoveControlPointCommand.js b/mindplot/src/main/javascript/commands/MoveControlPointCommand.js new file mode 100644 index 00000000..7242562e --- /dev/null +++ b/mindplot/src/main/javascript/commands/MoveControlPointCommand.js @@ -0,0 +1,59 @@ +mindplot.commands.MoveControlPointCommand = mindplot.Command.extend( +{ + initialize: function(ctrlPointControler, point) + { + core.assert(ctrlPointControler, 'line can not be null'); + this._ctrlPointControler = ctrlPointControler; + this._id = mindplot.Command._nextUUID(); + this._wasCustom=false; + this._point = point; + this._controlPoint = null; + }, + execute: function(commandContext) + { + var line = this._ctrlPointControler._line; + var ctrlPoints = line.getLine().getControlPoints(); + var model = line.getModel(); + var point = null; + switch (this._point){ + case 0: + if(core.Utils.isDefined(model.getSrcCtrlPoint())){ + this._controlPoint= model.getSrcCtrlPoint().clone(); + } + model.setSrcCtrlPoint(ctrlPoints[0].clone()); + this._wasCustom = line.getLine().isSrcControlPointCustom(); + line.getLine().setIsSrcControlPointCustom(true); + break; + case 1: + if(core.Utils.isDefined(model.getDestCtrlPoint())){ + this._controlPoint = model.getDestCtrlPoint().clone(); + } + model.setDestCtrlPoint(ctrlPoints[1].clone()); + this._wasCustom = line.getLine().isDestControlPointCustom(); + line.getLine().setIsDestControlPointCustom(true); + break; + } + }, + undoExecute: function(commandContext) + { + var line = this._ctrlPointControler._line; + var model = line.getModel(); + switch (this._point){ + case 0: + if(core.Utils.isDefined(this._controlPoint)){ + model.setSrcCtrlPoint(this._controlPoint.clone()); + line.getLine().setSrcControlPoint(this._controlPoint.clone()); + line.getLine().setIsSrcControlPointCustom(this._wasCustom); + } + break; + case 1: + if(core.Utils.isDefined(this._controlPoint)){ + model.setDestCtrlPoint(this._controlPoint.clone()); + line.getLine().setDestControlPoint(this._controlPoint.clone()); + line.getLine().setIsDestControlPointCustom(this._wasCustom); + } + break; + } + this._ctrlPointControler.setLine(line); + } +}); \ No newline at end of file diff --git a/web2d/pom.xml b/web2d/pom.xml index 11ea03e4..e50c0b21 100644 --- a/web2d/pom.xml +++ b/web2d/pom.xml @@ -91,6 +91,7 @@ ${basedir}/target/tmp/peer/svg/Font-min.js ${basedir}/target/tmp/peer/svg/ArialFont-min.js ${basedir}/target/tmp/peer/svg/PolyLinePeer-min.js + ${basedir}/target/tmp/peer/svg/CurvedLinePeer-min.js ${basedir}/target/tmp/peer/svg/TextPeer-min.js ${basedir}/target/tmp/peer/svg/WorkspacePeer-min.js ${basedir}/target/tmp/peer/svg/GroupPeer-min.js @@ -109,6 +110,7 @@ ${basedir}/target/tmp/Image-min.js ${basedir}/target/tmp/Line-min.js ${basedir}/target/tmp/PolyLine-min.js + ${basedir}/target/tmp/CurvedLine-min.js ${basedir}/target/tmp/Rect-min.js ${basedir}/target/tmp/Text-min.js ${basedir}/target/tmp/Toolkit-min.js diff --git a/web2d/src/main/javascript/CurvedLine.js b/web2d/src/main/javascript/CurvedLine.js new file mode 100644 index 00000000..0111ce74 --- /dev/null +++ b/web2d/src/main/javascript/CurvedLine.js @@ -0,0 +1,112 @@ +/* +* Licensed to the Apache Software Foundation (ASF) under one or more +* contributor license agreements. See the NOTICE file distributed with +* this work for additional information regarding copyright ownership. +* The ASF licenses this file to You under the Apache License, Version 2.0 +* (the "License"); you may not use this file except in compliance with +* the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* 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. +* +* $Id: file 64488 2006-03-10 17:32:09Z paulo $ +*/ + +web2d.CurvedLine = function(attributes) +{ + var peer = web2d.peer.Toolkit.createCurvedLine(); + var defaultAttributes = {strokeColor:'blue',strokeWidth:1,strokeStyle:'solid',strokeOpacity:1}; + for (var key in attributes) + { + defaultAttributes[key] = attributes[key]; + } + web2d.Element.call(this, peer, defaultAttributes); +}; +objects.extend(web2d.CurvedLine, web2d.Element); + +web2d.CurvedLine.prototype.getType = function() +{ + return "CurvedLine"; +}; + +web2d.CurvedLine.prototype.setFrom = function(x, y) +{ + this._peer.setFrom(x, y); +}; + +web2d.CurvedLine.prototype.setTo = function(x, y) +{ + this._peer.setTo(x, y); +}; + +web2d.CurvedLine.prototype.getFrom = function() +{ + return this._peer.getFrom(); +}; + +web2d.CurvedLine.prototype.getTo = function() +{ + return this._peer.getTo(); +}; + +web2d.CurvedLine.prototype.setShowArrow = function(visible){ + this._peer.setShowArrow(visible); +}; + +web2d.CurvedLine.prototype.isShowArrow = function(){ + return this._peer.isShowArrow(); +}; + +web2d.CurvedLine.prototype.setSrcControlPoint = function(control){ + this._peer.setSrcControlPoint(control); +}; + +web2d.CurvedLine.prototype.setDestControlPoint = function(control){ + this._peer.setDestControlPoint(control); +}; + +web2d.CurvedLine.prototype.getControlPoints = function(){ + return this._peer.getControlPoints(); +}; + +web2d.CurvedLine.prototype.isSrcControlPointCustom = function(){ + return this._peer.isSrcControlPointCustom(); +}; + +web2d.CurvedLine.prototype.isDestControlPointCustom = function(){ + return this._peer.isDestControlPointCustom(); +}; + +web2d.CurvedLine.prototype.setIsSrcControlPointCustom = function(isCustom){ + this._peer.setIsSrcControlPointCustom(isCustom); +}; + +web2d.CurvedLine.prototype.setIsDestControlPointCustom = function(isCustom){ + this._peer.setIsDestControlPointCustom(isCustom); +}; + +web2d.CurvedLine.prototype.updateLine= function(avoidControlPointFix){ + return this._peer.updateLine(avoidControlPointFix); +}; + +web2d.CurvedLine.prototype.setStyle = function(style){ + this._peer.setLineStyle(style); + +}; + +web2d.CurvedLine.prototype.getStyle = function(){ + return this._peer.getLineStyle(); +}; + +web2d.CurvedLine.prototype.setDashed = function(length,spacing){ + this._peer.setDashed(length, spacing); +}; + +web2d.CurvedLine.SIMPLE_LINE = false; +web2d.CurvedLine.NICE_LINE = true; + diff --git a/web2d/src/main/javascript/Line.js b/web2d/src/main/javascript/Line.js index 8ee996e4..47df7faa 100644 --- a/web2d/src/main/javascript/Line.js +++ b/web2d/src/main/javascript/Line.js @@ -1,22 +1,22 @@ -/* -* Licensed to the Apache Software Foundation (ASF) under one or more -* contributor license agreements. See the NOTICE file distributed with -* this work for additional information regarding copyright ownership. -* The ASF licenses this file to You under the Apache License, Version 2.0 -* (the "License"); you may not use this file except in compliance with -* the License. You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* 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. -* -* $Id: file 64488 2006-03-10 17:32:09Z paulo $ -*/ - +/* +* Licensed to the Apache Software Foundation (ASF) under one or more +* contributor license agreements. See the NOTICE file distributed with +* this work for additional information regarding copyright ownership. +* The ASF licenses this file to You under the Apache License, Version 2.0 +* (the "License"); you may not use this file except in compliance with +* the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* 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. +* +* $Id: file 64488 2006-03-10 17:32:09Z paulo $ +*/ + web2d.Line = function(attributes) { var peer = web2d.peer.Toolkit.createLine(); @@ -44,6 +44,16 @@ web2d.Line.prototype.setTo = function(x, y) this._peer.setTo(x, y); }; +web2d.Line.prototype.getFrom = function() +{ + return this._peer.getFrom(); +}; + +web2d.Line.prototype.getTo = function() +{ + return this._peer.getTo(); +}; + /** * Defines the start and the end line arrow style. * Can have values "none | block | classic | diamond | oval | open | chevron | doublechevron" diff --git a/web2d/src/main/javascript/Toolkit.js b/web2d/src/main/javascript/Toolkit.js index 7ff3dd06..db36e004 100644 --- a/web2d/src/main/javascript/Toolkit.js +++ b/web2d/src/main/javascript/Toolkit.js @@ -74,9 +74,13 @@ web2d.peer.ToolkitVML = { return new web2d.peer.vml.LinePeer(); }, - createPolyLine: function() + createCurvedLine: function() { - return new web2d.peer.vml.PolyLinePeer(); + return new web2d.peer.vml.CurvedLinePeer(); + }, + createCurvedLine: function() + { + return new web2d.peer.vml.CurvedLinePeer(); }, createImage: function () { @@ -135,6 +139,10 @@ web2d.peer.ToolkitSVG = { return new web2d.peer.svg.PolyLinePeer(); }, + createCurvedLine: function() + { + return new web2d.peer.svg.CurvedLinePeer(); + }, createText: function () { return new web2d.peer.svg.TextPeer(); diff --git a/web2d/src/main/javascript/peer/svg/CurvedLinePeer.js b/web2d/src/main/javascript/peer/svg/CurvedLinePeer.js new file mode 100644 index 00000000..66286ca4 --- /dev/null +++ b/web2d/src/main/javascript/peer/svg/CurvedLinePeer.js @@ -0,0 +1,223 @@ +/* +* Licensed to the Apache Software Foundation (ASF) under one or more +* contributor license agreements. See the NOTICE file distributed with +* this work for additional information regarding copyright ownership. +* The ASF licenses this file to You under the Apache License, Version 2.0 +* (the "License"); you may not use this file except in compliance with +* the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* 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. +* +* $Id: file 64488 2006-03-10 17:32:09Z paulo $ +*/ + +web2d.peer.svg.CurvedLinePeer = function() +{ + var svgElement = window.document.createElementNS(this.svgNamespace, 'path'); + web2d.peer.svg.ElementPeer.call(this, svgElement); + this._style={fill:'gray'}; + this._updateStyle(); + this._customControlPoint_1 = false; + this._customControlPoint_2 = false; + this._control1=new core.Point(); + this._control2=new core.Point(); + this._lineStyle=true; +}; + +objects.extend(web2d.peer.svg.CurvedLinePeer, web2d.peer.svg.ElementPeer); + +web2d.peer.svg.CurvedLinePeer.prototype.setSrcControlPoint = function(control){ + this._customControlPoint_1 = true; + if(core.Utils.isDefined(control.x)){ + this._control1 = control; + } + this._updatePath(); +}; + +web2d.peer.svg.CurvedLinePeer.prototype.setDestControlPoint = function(control){ + this._customControlPoint_2 = true; + if(core.Utils.isDefined(control.x)){ + this._control2 = control; + } + this._updatePath(); +}; + +web2d.peer.svg.CurvedLinePeer.prototype.isSrcControlPointCustom = function() { + return this._customControlPoint_1; +}; + +web2d.peer.svg.CurvedLinePeer.prototype.isDestControlPointCustom = function() { + return this._customControlPoint_2; +}; + +web2d.peer.svg.CurvedLinePeer.prototype.setIsSrcControlPointCustom = function(isCustom) { + this._customControlPoint_1 = isCustom; +}; + +web2d.peer.svg.CurvedLinePeer.prototype.setIsDestControlPointCustom = function(isCustom) { + this._customControlPoint_2 = isCustom; +}; + + + +web2d.peer.svg.CurvedLinePeer.prototype.getControlPoints = function(){ + return [this._control1, this._control2]; +}; + +web2d.peer.svg.CurvedLinePeer.prototype.setFrom = function(x1, y1) +{ + if(this._customControlPoint_1 && core.Utils.isDefined(this._x1)){ + this._control1.x-=this._x1-x1; + this._control1.y-=this._y1-y1; + } + this._x1 = x1; + this._y1 = y1; + this._updatePath(); +}; + +web2d.peer.svg.CurvedLinePeer.prototype.setTo = function(x2, y2) +{ + if(this._customControlPoint_2 && core.Utils.isDefined(this._x2)){ + this._control2.x-=this._x2-x2; + this._control2.y-=this._y2-y2; + } + this._x2 = x2; + this._y2 = y2; + this._updatePath(); +}; + +web2d.peer.svg.CurvedLinePeer.prototype.getFrom = function() +{ + return new core.Point(this._x1,this._y1); +}; + +web2d.peer.svg.CurvedLinePeer.prototype.getTo = function() +{ + return new core.Point(this._x2,this._y2); +}; + +web2d.peer.svg.CurvedLinePeer.prototype.setStrokeWidth = function(width) +{ + this._style['stroke-width']= width; + this._updateStyle(); +}; + +web2d.peer.svg.CurvedLinePeer.prototype.setColor = function(color) +{ + this._style['stroke']= color; + this._style['fill']=color; + this._updateStyle(); +}; + +web2d.peer.svg.CurvedLinePeer.prototype.updateLine = function(avoidControlPointFix){ + this._updatePath(avoidControlPointFix); +}; + +web2d.peer.svg.CurvedLinePeer.prototype.setLineStyle = function (style){ + this._lineStyle=style; + if(this._lineStyle){ + this._style['fill']=this._fill; + } else { + this._fill = this._style['fill']; + this._style['fill']='none'; + } + this._updateStyle(); + this.updateLine(); +}; + +web2d.peer.svg.CurvedLinePeer.prototype.getLineStyle = function (){ + return this._lineStyle; +}; + + +web2d.peer.svg.CurvedLinePeer.prototype.setShowArrow = function(visible){ + this._showArrow =visible; + this.updateLine(); +}; + +web2d.peer.svg.CurvedLinePeer.prototype.isShowArrow = function(){ + return this._showArrow; +}; + + +web2d.peer.svg.CurvedLinePeer.prototype._updatePath = function(avoidControlPointFix) +{ + this._calculateAutoControlPoints(avoidControlPointFix); + var x,y, xp, yp; + if(this._showArrow){ + if(this._control2.y == 0) + this._control2.y=1; + var y0 = parseInt(this._control2.y) - this._y2; + var x0 = parseInt(this._control2.x) - this._x2; + var x2=x0+y0; + var y2 = y0-x0; + var x3 = x0-y0; + var y3 = y0+x0; + var m = y2/x2; + var mp = y3/x3; + var l = 6; + var pow = Math.pow; + x = (x2==0?0:Math.sqrt(pow(l,2)/(1+pow(m,2)))); + x *=Math.sign(x2); + y = (x2==0?l*Math.sign(y2):m*x); + xp = (x3==0?0:Math.sqrt(pow(l,2)/(1+pow(mp,2)))); + xp *=Math.sign(x3); + yp = (x3==0?l*Math.sign(y3):mp*xp); + } + var path = "M"+this._x1+","+this._y1 + +" C"+this._control1.x+","+this._control1.y+" " + +this._control2.x+","+this._control2.y+" " + +this._x2+","+this._y2+ + (this._lineStyle?" " + +this._control2.x+","+(parseInt(this._control2.y)+3)+" " + +this._control1.x+","+(parseInt(this._control1.y)+3)+" " + +this._x1+","+(parseInt(this._y1)+3)+" Z" + :"" + )+ + (this._showArrow?" " + +"M"+this._x2+","+this._y2+" " + +"L"+(x+this._x2)+","+(y+this._y2) + +"M"+this._x2+","+this._y2+" " + +"L"+(xp+this._x2)+","+(yp+this._y2) + :""); + this._native.setAttribute("d",path); +}; + +web2d.peer.svg.CurvedLinePeer.prototype._updateStyle = function() +{ + var style = ""; + for(var key in this._style){ + style+=key+":"+this._style[key]+" "; + } + this._native.setAttribute("style",style); +}; + +web2d.peer.svg.CurvedLinePeer.prototype._calculateAutoControlPoints = function(avoidControlPointFix){ + if(core.Utils.isDefined(this._x1) && core.Utils.isDefined(this._x2)){ + //Both points available, calculate real points + var defaultpoints = core.Utils.calculateDefaultControlPoints(new core.Point(this._x1, this._y1),new core.Point(this._x2,this._y2)); + if(!this._customControlPoint_1 && !(core.Utils.isDefined(avoidControlPointFix) && avoidControlPointFix==0)){ + this._control1.x = defaultpoints[0].x; + this._control1.y = defaultpoints[0].y; + } + if(!this._customControlPoint_2 && !(core.Utils.isDefined(avoidControlPointFix) && avoidControlPointFix==1)){ + this._control2.x = defaultpoints[1].x; + this._control2.y = defaultpoints[1].y; + } + } +}; + +web2d.peer.svg.CurvedLinePeer.prototype.setDashed = function(length,spacing){ + if(core.Utils.isDefined(length) && core.Utils.isDefined(spacing)){ + this._native.setAttribute("stroke-dasharray",length+","+spacing); + } else { + this._native.setAttribute("stroke-dasharray",""); + } + +}; diff --git a/web2d/src/main/javascript/peer/svg/LinePeer.js b/web2d/src/main/javascript/peer/svg/LinePeer.js index 5e8cef31..c47994eb 100644 --- a/web2d/src/main/javascript/peer/svg/LinePeer.js +++ b/web2d/src/main/javascript/peer/svg/LinePeer.js @@ -1,22 +1,22 @@ -/* -* Licensed to the Apache Software Foundation (ASF) under one or more -* contributor license agreements. See the NOTICE file distributed with -* this work for additional information regarding copyright ownership. -* The ASF licenses this file to You under the Apache License, Version 2.0 -* (the "License"); you may not use this file except in compliance with -* the License. You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* 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. -* -* $Id: file 64488 2006-03-10 17:32:09Z paulo $ -*/ - +/* +* Licensed to the Apache Software Foundation (ASF) under one or more +* contributor license agreements. See the NOTICE file distributed with +* this work for additional information regarding copyright ownership. +* The ASF licenses this file to You under the Apache License, Version 2.0 +* (the "License"); you may not use this file except in compliance with +* the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* 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. +* +* $Id: file 64488 2006-03-10 17:32:09Z paulo $ +*/ + web2d.peer.svg.LinePeer = function() { var svgElement = window.document.createElementNS(this.svgNamespace, 'line'); @@ -28,16 +28,29 @@ objects.extend(web2d.peer.svg.LinePeer, web2d.peer.svg.ElementPeer); web2d.peer.svg.LinePeer.prototype.setFrom = function(x1, y1) { + this._x1=x1; + this._y1=y1; this._native.setAttribute('x1', x1); this._native.setAttribute('y1', y1); }; web2d.peer.svg.LinePeer.prototype.setTo = function(x2, y2) { + this._x2=x2; + this._y2=y2; this._native.setAttribute('x2', x2); this._native.setAttribute('y2', y2); }; +web2d.peer.svg.LinePeer.prototype.getFrom = function(){ + return new core.Point(this._x1,this._y1); +}; + +web2d.peer.svg.LinePeer.prototype.getTo = function(){ + return new core.Point(this._x2,this._y2); +}; + + /* * http://www.zvon.org/HowTo/Output/howto_jj_svg_27.html?at=marker-end */ diff --git a/web2d/src/main/javascript/peer/svg/PolyLinePeer.js b/web2d/src/main/javascript/peer/svg/PolyLinePeer.js index ce619659..a0c9472f 100644 --- a/web2d/src/main/javascript/peer/svg/PolyLinePeer.js +++ b/web2d/src/main/javascript/peer/svg/PolyLinePeer.js @@ -1,22 +1,22 @@ -/* -* Licensed to the Apache Software Foundation (ASF) under one or more -* contributor license agreements. See the NOTICE file distributed with -* this work for additional information regarding copyright ownership. -* The ASF licenses this file to You under the Apache License, Version 2.0 -* (the "License"); you may not use this file except in compliance with -* the License. You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* 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. -* -* $Id: file 64488 2006-03-10 17:32:09Z paulo $ -*/ - +/* +* Licensed to the Apache Software Foundation (ASF) under one or more +* contributor license agreements. See the NOTICE file distributed with +* this work for additional information regarding copyright ownership. +* The ASF licenses this file to You under the Apache License, Version 2.0 +* (the "License"); you may not use this file except in compliance with +* the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* 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. +* +* $Id: file 64488 2006-03-10 17:32:09Z paulo $ +*/ + web2d.peer.svg.PolyLinePeer = function() { var svgElement = window.document.createElementNS(this.svgNamespace, 'polyline'); @@ -82,7 +82,7 @@ web2d.peer.svg.PolyLinePeer.prototype._updateStraightPath = function() { if (core.Utils.isDefined(this._x1) && core.Utils.isDefined(this._x2) && core.Utils.isDefined(this._y1) && core.Utils.isDefined(this._y2)) { - this.buildStraightPath(this.breakDistance, this._x1, this._y1, this._x2, this._y2); + var path = web2d.PolyLine.buildStraightPath(this.breakDistance, this._x1, this._y1, this._x2, this._y2); this._native.setAttribute('points', path); } }; diff --git a/web2d/src/test/javascript/render/curvedLine.html b/web2d/src/test/javascript/render/curvedLine.html new file mode 100644 index 00000000..43d1ae9b --- /dev/null +++ b/web2d/src/test/javascript/render/curvedLine.html @@ -0,0 +1,116 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

PolyLines Render Tests

+ + ++ + + + + + + + + + + + + +
+ Different types of PolyLines that can be used. + +
+
+ This is how multiple childs will look in each style line + +
+
+ + diff --git a/wise-webapp/pom.xml b/wise-webapp/pom.xml index 56ca8712..fda01c4b 100644 --- a/wise-webapp/pom.xml +++ b/wise-webapp/pom.xml @@ -417,7 +417,7 @@ - + org.apache.maven.plugins diff --git a/wise-webapp/src/main/java/com/wisemapping/mail/Mailer.java b/wise-webapp/src/main/java/com/wisemapping/mail/Mailer.java index a17f2322..5ff94c97 100644 --- a/wise-webapp/src/main/java/com/wisemapping/mail/Mailer.java +++ b/wise-webapp/src/main/java/com/wisemapping/mail/Mailer.java @@ -83,7 +83,7 @@ public final class Mailer { } }; - this.mailSender.send(preparator); + //this.mailSender.send(preparator); } public void setMailSender(JavaMailSender mailer) { diff --git a/wise-webapp/src/main/java/com/wisemapping/service/UserServiceImpl.java b/wise-webapp/src/main/java/com/wisemapping/service/UserServiceImpl.java index 87d6ee0b..61db1e7e 100755 --- a/wise-webapp/src/main/java/com/wisemapping/service/UserServiceImpl.java +++ b/wise-webapp/src/main/java/com/wisemapping/service/UserServiceImpl.java @@ -1,22 +1,22 @@ -/* -* Licensed to the Apache Software Foundation (ASF) under one or more -* contributor license agreements. See the NOTICE file distributed with -* this work for additional information regarding copyright ownership. -* The ASF licenses this file to You under the Apache License, Version 2.0 -* (the "License"); you may not use this file except in compliance with -* the License. You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* 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. -* -* $Id: file 64488 2006-03-10 17:32:09Z paulo $ -*/ - +/* +* Licensed to the Apache Software Foundation (ASF) under one or more +* contributor license agreements. See the NOTICE file distributed with +* this work for additional information regarding copyright ownership. +* The ASF licenses this file to You under the Apache License, Version 2.0 +* (the "License"); you may not use this file except in compliance with +* the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* 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. +* +* $Id: file 64488 2006-03-10 17:32:09Z paulo $ +*/ + package com.wisemapping.service; import com.wisemapping.dao.UserManager; @@ -24,6 +24,7 @@ import com.wisemapping.exceptions.WiseMappingException; import com.wisemapping.mail.Mailer; import com.wisemapping.model.User; import com.wisemapping.model.Colaborator; +import org.apache.log4j.Logger; import java.util.Calendar; import java.util.HashMap; @@ -35,6 +36,7 @@ public class UserServiceImpl private UserManager userManager; private MindmapService mindmapService; private Mailer mailer; + final static Logger logger = Logger.getLogger("org.wisemapping.service"); public void activateAcount(long code) throws InvalidActivationCodeException @@ -113,6 +115,7 @@ public class UserServiceImpl model.put("user", user); // TODO: ver como no hacer hardcode el url final String activationUrl = "http://wisemapping.com/c/activation.htm?code=" + user.getActivationCode(); + logger.info("create User - acrivationUrl: "+activationUrl); model.put("emailcheck", activationUrl); mailer.sendEmail(mailer.getRegistrationEmail(), user.getEmail(), "Welcome to Wisemapping!", model, "confirmationMail.vm"); diff --git a/wise-webapp/src/main/java/com/wisemapping/ws/WiseWsEndpoint.java b/wise-webapp/src/main/java/com/wisemapping/ws/WiseWsEndpoint.java deleted file mode 100644 index 117966b4..00000000 --- a/wise-webapp/src/main/java/com/wisemapping/ws/WiseWsEndpoint.java +++ /dev/null @@ -1,160 +0,0 @@ -/* -* Licensed to the Apache Software Foundation (ASF) under one or more -* contributor license agreements. See the NOTICE file distributed with -* this work for additional information regarding copyright ownership. -* The ASF licenses this file to You under the Apache License, Version 2.0 -* (the "License"); you may not use this file except in compliance with -* the License. You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* 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. -* -* $Id: file 64488 2006-03-10 17:32:09Z paulo $ -*/ - -package com.wisemapping.ws; - -import org.springframework.ws.server.endpoint.annotation.Endpoint; -import org.springframework.ws.server.endpoint.annotation.PayloadRoot; -import org.apache.log4j.Logger; -import com.wisemapping.service.MindmapService; -import com.wisemapping.service.UserService; -import com.wisemapping.model.MindMap; -import com.wisemapping.model.User; -import com.wisemapping.exceptions.NoMapFoundException; - -import javax.xml.bind.*; -import javax.xml.transform.stream.StreamSource; -import java.io.StringReader; -import java.io.StringWriter; -import java.util.Calendar; - -/** - * WiseMapping Web Services API - */ -@Endpoint -public class WiseWsEndpoint { - - MindmapService mindmapService; - private UserService userService; - final static Logger logger = Logger.getLogger("org.wisemapping.ws"); - private JAXBContext jaxbContext; - - - public WiseWsEndpoint(MindmapService mindmapService, UserService userService) throws JAXBException { - this.mindmapService = mindmapService; - this.userService = userService; - jaxbContext = JAXBContext.newInstance("com.wisemapping.ws"); - } - - @PayloadRoot(localPart = "loadMindmapRequest", namespace = "http://www.wisemapping.org/ws") - public LoadMindmapResponse loadMindmap(final LoadMindmapRequest request) throws Throwable { - - logger.debug("Invoking loadMindmap"); - final LoadMindmapResponse result = new LoadMindmapResponse(); - - try { - final MindMap mindmap = mindmapService.getMindmapById((int) request.getMapdId()); - if(mindmap==null) - { - throw new NoMapFoundException(request.getMapdId()); - } - - String xml = mindmap.getNativeXml(); - - // Hack, we need to unify to only one XSD schema definitions per map ... - xml = " mapElement = unmarshaller.unmarshal(streamSource,MapType.class); - - // Load map data ... - result.creator = mindmap.getCreator(); - result.setMap(mapElement.getValue()); - } catch (Throwable e) { - logger.fatal("Unexpexted Exception", e); - throw e; - } - - return result; - } - - @PayloadRoot(localPart = "addMindmapRequest", namespace = "http://www.wisemapping.org/ws") - public AddMindmapResponse createMindmap(final AddMindmapRequest request) throws Throwable { - - logger.debug("Invoking createMindmap"); - final AddMindmapResponse response = new AddMindmapResponse(); - try { - - final String creator = request.getCreator(); - final User user = userService.getUserBy(creator); - if(user==null) - { - throw new IllegalArgumentException("Invalid addMindmapRequest.' " + creator+"' is not valid wisemapping user."); - } - - - final MindMap mindmap = new MindMap(); - mindmap.setCreationTime(Calendar.getInstance()); - - // Set title ... - final String title = request.getTitle(); - if(title==null) - { - throw new IllegalArgumentException("Invalid addMindmapRequest. Title element can not be null."); - } - mindmap.setTitle(title); - - // Set description ... - final String description = request.getDescription(); - if(description==null) - { - throw new IllegalArgumentException("Invalid addMindmapRequest. Description element can not be null."); - } - mindmap.setDescription(description); - - // Convert Map to XML - final MapType mapType = request.getMap(); - if(mapType==null) - { - throw new IllegalArgumentException("Invalid addMindmapRequest. Map element can not be null."); - } - - ObjectFactory factory = new ObjectFactory(); - final Marshaller marshaller = jaxbContext.createMarshaller(); - StringWriter stringWriter = new StringWriter(); - marshaller.marshal(factory.createMap(mapType),stringWriter); - - mindmap.setNativeXml(stringWriter.toString()); - mindmapService.addMindmap(mindmap,user); - - - // Prepare result ... - response.setMapId(mindmap.getId()); - - } catch (Throwable e) { - logger.fatal("Unexpexted Exception", e); - throw e; - - } - - return response; - } - - - public MindmapService getMindmapService() { - return mindmapService; - } - - public void setMindmapService(MindmapService mindmapService) { - this.mindmapService = mindmapService; - } -} diff --git a/wise-webapp/src/main/resources/mindmap.xsd b/wise-webapp/src/main/resources/mindmap.xsd index de724c11..5d9d49e1 100755 --- a/wise-webapp/src/main/resources/mindmap.xsd +++ b/wise-webapp/src/main/resources/mindmap.xsd @@ -10,11 +10,12 @@ + + - @@ -32,6 +33,7 @@ + @@ -48,4 +50,15 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/wise-webapp/src/main/webapp/css/editor.css b/wise-webapp/src/main/webapp/css/editor.css index 53d3693e..9c61d304 100644 --- a/wise-webapp/src/main/webapp/css/editor.css +++ b/wise-webapp/src/main/webapp/css/editor.css @@ -216,11 +216,11 @@ div#node { } div#font { - left: 619px; /*left:581px;*/ + left: 656px; /*left:581px;*/ } div#share { - left: 815px; /*left:777px;*/ + left: 852px; /*left:777px;*/ } div#saveButton { @@ -311,6 +311,12 @@ div#topicLink { z-index: 4; } +div#topicRelation { + background: url(../images/topic_link.png) no-repeat center top; + behavior: url(../css/iepngfix.htc); + z-index: 4; +} + div#topicNote { background-image: url(../images/note.png); behavior: url(../css/iepngfix.htc); diff --git a/wise-webapp/src/main/webapp/js/editor.js b/wise-webapp/src/main/webapp/js/editor.js index 36320de8..83f021b6 100644 --- a/wise-webapp/src/main/webapp/js/editor.js +++ b/wise-webapp/src/main/webapp/js/editor.js @@ -269,7 +269,7 @@ function afterMindpotLibraryLoading() designer.deleteCurrentNode(); }); var context = this; - var colorPicker1 = new MooRainbow('topicColor', { + /*var colorPicker1 = new MooRainbow('topicColor', { id: 'topicColor', imgPath: '../images/', startColor: [255, 255, 255], @@ -298,12 +298,16 @@ function afterMindpotLibraryLoading() onComplete: function(color) { removeCurrentColorPicker.attempt(colorPicker2, context); } - }); + });*/ $('topicLink').addEvent('click', function(event) { designer.addLink2SelectedNode(); }); + $('topicRelation').addEvent('click', function(event) { + designer.addRelationShip2SelectedNode(event); + }); + $('topicNote').addEvent('click', function(event) { designer.addNote2SelectedNode(); @@ -318,7 +322,7 @@ function afterMindpotLibraryLoading() designer.setStyle2SelectedNode(); }); - var colorPicker3 = new MooRainbow('fontColor', { + /*var colorPicker3 = new MooRainbow('fontColor', { id: 'fontColor', imgPath: '../images/', startColor: [255, 255, 255], @@ -332,7 +336,7 @@ function afterMindpotLibraryLoading() onComplete: function(color) { removeCurrentColorPicker.attempt(colorPicker3, context); } - }); + });*/ // Save event handler .... var saveButton = $('saveButton'); @@ -520,7 +524,6 @@ function buildMindmapDesigner() var container = $('mindplot'); // Initialize Editor ... - var persistantManager = new mindplot.PersistanceManager(window.MapEditorService); var screenWidth = window.getWidth(); var screenHeight = window.getHeight(); @@ -533,7 +536,7 @@ function buildMindmapDesigner() editorProperties.width = screenWidth; editorProperties.height = screenHeight; - designer = new mindplot.MindmapDesigner(editorProperties, container, persistantManager); + designer = new mindplot.MindmapDesigner(editorProperties, container); designer.loadFromXML(mapId, mapXml); // If a node has focus, focus can be move to another node using the keys. diff --git a/wise-webapp/src/main/webapp/js/embedded.js b/wise-webapp/src/main/webapp/js/embedded.js index b66d61ae..6480ee15 100644 --- a/wise-webapp/src/main/webapp/js/embedded.js +++ b/wise-webapp/src/main/webapp/js/embedded.js @@ -67,7 +67,6 @@ function buildMindmapDesigner() var container = $('mindplot'); // Initialize Editor ... - var persistantManager = new mindplot.PersistanceManager(window.MapEditorService); var screenWidth = window.getWidth(); var screenHeight = window.getHeight(); @@ -77,7 +76,7 @@ function buildMindmapDesigner() editorProperties.height = screenHeight; editorProperties.viewMode = true; - designer = new mindplot.MindmapDesigner(editorProperties, container, persistantManager); + designer = new mindplot.MindmapDesigner(editorProperties, container); designer.loadFromXML(mapId, mapXml); // If a node has focus, focus can be move to another node using the keys. diff --git a/wise-webapp/src/main/webapp/jsp/footer.jsp b/wise-webapp/src/main/webapp/jsp/footer.jsp index 916f21de..b2eef037 100644 --- a/wise-webapp/src/main/webapp/jsp/footer.jsp +++ b/wise-webapp/src/main/webapp/jsp/footer.jsp @@ -15,9 +15,10 @@ +<%-- \ No newline at end of file +--%> diff --git a/wise-webapp/src/main/webapp/jsp/header.jsp b/wise-webapp/src/main/webapp/jsp/header.jsp index 4bf7daa7..0e15b768 100644 --- a/wise-webapp/src/main/webapp/jsp/header.jsp +++ b/wise-webapp/src/main/webapp/jsp/header.jsp @@ -1,3 +1,4 @@ +<%@page pageEncoding="UTF-8"%> <%@ taglib prefix="c" uri="http://java.sun.com/jstl/core_rt" %> <%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %> <%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %> diff --git a/wise-webapp/src/main/webapp/jsp/mindmapEditor.jsp b/wise-webapp/src/main/webapp/jsp/mindmapEditor.jsp index 7a755918..5fc27160 100644 --- a/wise-webapp/src/main/webapp/jsp/mindmapEditor.jsp +++ b/wise-webapp/src/main/webapp/jsp/mindmapEditor.jsp @@ -192,6 +192,9 @@ +
"> +

+
@@ -332,11 +335,11 @@ - +--%> diff --git a/wise-webapp/src/main/webapp/jsp/template.jsp b/wise-webapp/src/main/webapp/jsp/template.jsp index cf874685..3461b907 100644 --- a/wise-webapp/src/main/webapp/jsp/template.jsp +++ b/wise-webapp/src/main/webapp/jsp/template.jsp @@ -1,4 +1,5 @@ +<%@page pageEncoding="UTF-8"%> <%@ taglib prefix="tiles" uri="http://struts.apache.org/tags-tiles" %> <%@ include file="/jsp/init.jsp" %> diff --git a/wise-webapp/src/test/java/com/wisemapping/ws/test/WiseWebServicesTest.java b/wise-webapp/src/test/java/com/wisemapping/ws/test/WiseWebServicesTest.java deleted file mode 100644 index fe10f07f..00000000 --- a/wise-webapp/src/test/java/com/wisemapping/ws/test/WiseWebServicesTest.java +++ /dev/null @@ -1,100 +0,0 @@ -/* -* Licensed to the Apache Software Foundation (ASF) under one or more -* contributor license agreements. See the NOTICE file distributed with -* this work for additional information regarding copyright ownership. -* The ASF licenses this file to You under the Apache License, Version 2.0 -* (the "License"); you may not use this file except in compliance with -* the License. You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* 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. -* -* $Id: file 64488 2006-03-10 17:32:09Z paulo $ -*/ - -package com.wisemapping.ws.test; - -import org.testng.annotations.Test; - -import javax.xml.bind.JAXBContext; -import javax.xml.bind.JAXBException; -import javax.xml.bind.Marshaller; -import java.net.MalformedURLException; -import java.io.StringWriter; -import java.util.List; - -import com.wisemapping.ws.*; - - -@Test(groups = {"wsintegration"}) -public class WiseWebServicesTest { - - - @Test(dependsOnMethods = "addMapTest") - public void loadMapTest() throws MalformedURLException, JAXBException { - - final WiseServicesPortTypeService portTypeService = new WiseServicesPortTypeService(); - final WiseServicesPortType servicesPortType = portTypeService.getWiseServicesPortTypeSoap11(); - - final LoadMindmapRequest request = new LoadMindmapRequest(); - request.setMapdId(1); - LoadMindmapResponse response = servicesPortType.loadMindmap(request); - - JAXBContext jc = JAXBContext.newInstance("com.wisemapping.ws.test"); - Marshaller marshaller = jc.createMarshaller(); - - final StringWriter xmlContext = new StringWriter(); - marshaller.marshal(response,xmlContext); - System.out.println("Response:"+xmlContext); - - } - - public void addMapTest() throws MalformedURLException, JAXBException { - - final WiseServicesPortTypeService portTypeService = new WiseServicesPortTypeService(); - final WiseServicesPortType servicesPortType = portTypeService.getWiseServicesPortTypeSoap11(); - - final AddMindmapRequest request = new AddMindmapRequest(); - - request.setCreator("test@wisemapping.org"); - - request.setTitle("MyFirstMap"); - request.setDescription("My First Map Description"); - - // Set Map ... - MapType sampleMap = createMockMap(); - request.setMap(sampleMap); - - - AddMindmapResponse response = servicesPortType.addMindmap(request); - - JAXBContext jc = JAXBContext.newInstance("com.wisemapping.ws.test"); - Marshaller marshaller = jc.createMarshaller(); - - final StringWriter xmlContext = new StringWriter(); - marshaller.marshal(response,xmlContext); - System.out.println("Response:"+xmlContext); - - } - - private MapType createMockMap() { - ObjectFactory factory = new ObjectFactory(); - MapType mapType = factory.createMapType(); - mapType.setName("map name"); - - TopicType topicType = factory.createTopicType(); - topicType.setCentral(true); - topicType.setText("Central topic value"); - - List topics = mapType.getTopic(); - topics.add(topicType); - - return mapType; - } - -}