qx.Class.define("org.argeo.jcr.ria.views.PlainXmlViewer", { extend : qx.ui.container.Composite, implement : [org.argeo.ria.components.IView], properties : { /** * The commands definition Map that will be automatically added and wired to the menubar and toolbar. * See {@link org.argeo.ria.event.CommandsManager#definitions} for the keys to use for defining commands. */ commands : { init : {} }, viewSelection : { nullable:false, check:"org.argeo.ria.components.ViewSelection" }, instanceId : { init:"XmlEditor", event : "changeInstanceId" }, instanceLabel : { init:"Xml Editor", event : "changeInstanceLabel" }, dataModel : { } }, construct : function(){ this.base(arguments); }, members : { /** * The implementation should contain the GUI initialisation. * This is the role of the manager to actually add the graphical component to the pane, * so it's not necessary to do it here. * @param viewPane {org.argeo.ria.components.ViewPane} The pane manager * @param data {Mixed} Any object or data passed by the initiator of the view * @return {Boolean} */ init : function(viewPane, dataModel){ this.setViewSelection(new org.argeo.ria.components.ViewSelection(viewPane.getViewId())); this.setLayout(new qx.ui.layout.VBox()); this.setDataModel(dataModel); this.input = new qx.ui.form.TextField(); this.add(this.input); this._attachInputToDM(); this.htmlPane = new qx.ui.embed.Html(); this.htmlPane.setOverflow("auto", "auto"); this.add(this.htmlPane, {flex:1}); }, /** * The implementation should contain the real data loading (i.o. query...) * @return {Boolean} */ load : function(){ var dataModel = this.getDataModel(); dataModel.addListener("changeContextNode", function(event){ var xmlString = event.getData().toXmlString(true); var TAG_START_PATTERN = new RegExp("<([0-9a-zA-Z\.]+)([^>]*)>", "gi"); var TAG_END_PATTERN = new RegExp("", "gi"); var TAG_CLOSE_PATTERN = new RegExp("(/?>)", "gi"); var TAG_ATTRIBUTE = new RegExp("\\s([0-9a-zA-Z:]+)\\=\"([^\"]*)\"", "gi"); // Not implemented yet var TAG_COMMENT = new RegExp("()", "gi"); var TAG_CDATA_START = new RegExp("(\\)", "gi"); xmlString = xmlString.replace(TAG_START_PATTERN, 'xml_div_begin<xml_tagname_begin$1xml_tagname_end$2>'); xmlString = xmlString.replace(TAG_END_PATTERN, '</xml_tagname_begin$1xml_tagname_end>xml_div_end'); xmlString = xmlString.replace(TAG_CLOSE_PATTERN, '>'); xmlString = xmlString.replace(TAG_ATTRIBUTE, ' xml_attname_begin$1xml_attname_end="xml_attvalue_begin$2xml_attvalue_end"'); //xmlString = qx.xml.String.escape(xmlString); xmlString = xmlString.replace(new RegExp("(xml_div_begin)", "g"), '
'); xmlString = xmlString.replace(new RegExp("(xml_div_end)", "g"), '
'); xmlString = xmlString.replace(new RegExp("(xml_tagname_begin)", "g"), ''); xmlString = xmlString.replace(new RegExp("(xml_tagname_end)", "g"), ''); xmlString = xmlString.replace(new RegExp("(xml_attname_begin)", "g"), ''); xmlString = xmlString.replace(new RegExp("(xml_attname_end)", "g"), ''); xmlString = xmlString.replace(new RegExp("(xml_attvalue_begin)", "g"), ''); xmlString = xmlString.replace(new RegExp("(xml_attvalue_end)", "g"), ''); xmlString = '
' + xmlString + '
'; this.htmlPane.setHtml(xmlString); /* var call = new qx.util.DeferredCall(function(){ var htmlDom = this.htmlPane.getContentElement().getDomElement(); var spans = qx.bom.Selector.query("span", htmlDom); for(var i=0;i