From b2751402296a81dc1dd309cade865e744653d54f Mon Sep 17 00:00:00 2001 From: Konstantin Krivopustov Date: Thu, 21 Feb 2013 11:01:28 +0000 Subject: [PATCH] XSD for screen inheritance elements #PL-1882 --- .../src/com/haulmont/cuba/gui/window-ext.xsd | 12 ++++++++++ .../gui/src/com/haulmont/cuba/gui/window.xsd | 3 +++ .../cuba/gui/xml/XmlInheritanceProcessor.java | 24 +++++++++++-------- 3 files changed, 29 insertions(+), 10 deletions(-) create mode 100644 modules/gui/src/com/haulmont/cuba/gui/window-ext.xsd diff --git a/modules/gui/src/com/haulmont/cuba/gui/window-ext.xsd b/modules/gui/src/com/haulmont/cuba/gui/window-ext.xsd new file mode 100644 index 0000000000..677cef0ac0 --- /dev/null +++ b/modules/gui/src/com/haulmont/cuba/gui/window-ext.xsd @@ -0,0 +1,12 @@ + + + + + + \ No newline at end of file diff --git a/modules/gui/src/com/haulmont/cuba/gui/window.xsd b/modules/gui/src/com/haulmont/cuba/gui/window.xsd index 4b67a351b8..70b4ea701e 100644 --- a/modules/gui/src/com/haulmont/cuba/gui/window.xsd +++ b/modules/gui/src/com/haulmont/cuba/gui/window.xsd @@ -153,10 +153,12 @@ + + @@ -847,6 +849,7 @@ + diff --git a/modules/gui/src/com/haulmont/cuba/gui/xml/XmlInheritanceProcessor.java b/modules/gui/src/com/haulmont/cuba/gui/xml/XmlInheritanceProcessor.java index e8a7461420..b6c507c57a 100644 --- a/modules/gui/src/com/haulmont/cuba/gui/xml/XmlInheritanceProcessor.java +++ b/modules/gui/src/com/haulmont/cuba/gui/xml/XmlInheritanceProcessor.java @@ -1,17 +1,13 @@ /* - * Copyright (c) 2010 Haulmont Technology Ltd. All Rights Reserved. + * Copyright (c) 2013 Haulmont Technology Ltd. All Rights Reserved. * Haulmont Technology proprietary and confidential. * Use is subject to license terms. - - * Author: Konstantin Krivopustov - * Created: 04.03.2010 11:11:58 - * - * $Id$ */ package com.haulmont.cuba.gui.xml; import com.haulmont.bali.util.Dom4j; -import com.haulmont.cuba.core.global.ScriptingProvider; +import com.haulmont.cuba.core.global.AppBeans; +import com.haulmont.cuba.core.global.Resources; import com.haulmont.cuba.gui.xml.layout.LayoutLoader; import org.apache.commons.io.IOUtils; import org.apache.commons.lang.StringUtils; @@ -23,6 +19,12 @@ import java.io.InputStream; import java.io.StringWriter; import java.util.*; +/** + * Provides inheritance of screen XML descriptors. + * + * @author krivopustov + * @version $Id$ + */ public class XmlInheritanceProcessor { private static Log log = LogFactory.getLog(XmlInheritanceProcessor.class); @@ -31,13 +33,15 @@ public class XmlInheritanceProcessor { private Namespace extNs; private Map params; - private List targetLocators = new ArrayList(); + private List targetLocators = new ArrayList<>(); + + protected Resources resources = AppBeans.get(Resources.class); public XmlInheritanceProcessor(Document document, Map params) { this.document = document; this.params = params; - extNs = new Namespace("ext", "http://www.haulmont.com/schema/cuba/gui/window-ext.xsd"); + extNs = document.getRootElement().getNamespaceForPrefix("ext"); targetLocators.add(new ViewPropertyElementTargetLocator()); targetLocators.add(new ViewElementTargetLocator()); @@ -51,7 +55,7 @@ public class XmlInheritanceProcessor { Element root = document.getRootElement(); String ancestorTemplate = root.attributeValue("extends"); if (!StringUtils.isBlank(ancestorTemplate)) { - InputStream ancestorStream = ScriptingProvider.getResourceAsStream(ancestorTemplate); + InputStream ancestorStream = resources.getResourceAsStream(ancestorTemplate); if (ancestorStream == null) { ancestorStream = getClass().getResourceAsStream(ancestorTemplate); if (ancestorStream == null) {