From 7dfb044ae4108de3a6ed7e27e7e8a064ec800d34 Mon Sep 17 00:00:00 2001 From: Paulo Gustavo Veiga Date: Sat, 1 Sep 2012 11:09:47 -0300 Subject: [PATCH] Bug Uncaught text can not be null fixed. --- .../src/main/javascript/model/NoteModel.js | 4 +- .../persistence/XMLSerializer_Pela.js | 51 ++-- .../src/main/webapp/samples/emptyNodes.xml | 239 ++++++++++++++++++ 3 files changed, 267 insertions(+), 27 deletions(-) create mode 100644 wise-editor/src/main/webapp/samples/emptyNodes.xml diff --git a/mindplot/src/main/javascript/model/NoteModel.js b/mindplot/src/main/javascript/model/NoteModel.js index 8b3de968..27b320fe 100644 --- a/mindplot/src/main/javascript/model/NoteModel.js +++ b/mindplot/src/main/javascript/model/NoteModel.js @@ -20,8 +20,8 @@ mindplot.model.NoteModel = new Class({ Extends:mindplot.model.FeatureModel, initialize:function (attributes) { this.parent(mindplot.model.NoteModel.FEATURE_TYPE); - if (attributes.text) - this.setText(attributes.text); + var noteText = attributes.text ? attributes.text : " "; + this.setText(noteText); }, getText:function () { diff --git a/mindplot/src/main/javascript/persistence/XMLSerializer_Pela.js b/mindplot/src/main/javascript/persistence/XMLSerializer_Pela.js index 4870f2a8..a40b2e65 100644 --- a/mindplot/src/main/javascript/persistence/XMLSerializer_Pela.js +++ b/mindplot/src/main/javascript/persistence/XMLSerializer_Pela.js @@ -170,7 +170,7 @@ mindplot.persistence.XMLSerializer_Pela = new Class({ }, _noteTextToXML:function (document, elem, text) { - if (text.indexOf('\n') == -1 && text.indexOf("&") == -1 && text.indexOf("<") == -1 && text.indexOf("\"") == -1) { + if (text.indexOf('\n') == -1) { elem.setAttribute('text', text); } else { var textDom = document.createElement("text"); @@ -258,6 +258,31 @@ mindplot.persistence.XMLSerializer_Pela = new Class({ var text = domElem.getAttribute('text'); if ($defined(text) && text) { topic.setText(text); + + var fontStyle = domElem.getAttribute('fontStyle'); + if ($defined(fontStyle)) { + var font = fontStyle.split(';'); + + if (font[0]) { + topic.setFontFamily(font[0]); + } + + if (font[1]) { + topic.setFontSize(font[1]); + } + + if (font[2]) { + topic.setFontColor(font[2]); + } + + if (font[3]) { + topic.setFontWeight(font[3]); + } + + if (font[4]) { + topic.setFontStyle(font[4]); + } + } } var shape = domElem.getAttribute('shape'); @@ -275,30 +300,6 @@ mindplot.persistence.XMLSerializer_Pela = new Class({ } } - var fontStyle = domElem.getAttribute('fontStyle'); - if ($defined(fontStyle)) { - var font = fontStyle.split(';'); - - if (font[0]) { - topic.setFontFamily(font[0]); - } - - if (font[1]) { - topic.setFontSize(font[1]); - } - - if (font[2]) { - topic.setFontColor(font[2]); - } - - if (font[3]) { - topic.setFontWeight(font[3]); - } - - if (font[4]) { - topic.setFontStyle(font[4]); - } - } var bgColor = domElem.getAttribute('bgColor'); if ($defined(bgColor)) { diff --git a/wise-editor/src/main/webapp/samples/emptyNodes.xml b/wise-editor/src/main/webapp/samples/emptyNodes.xml new file mode 100644 index 00000000..9c08eb07 --- /dev/null +++ b/wise-editor/src/main/webapp/samples/emptyNodes.xml @@ -0,0 +1,239 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +