mirror of
https://gitee.com/jmix/cuba.git
synced 2024-12-04 20:28:00 +08:00
XSD for screen inheritance elements #PL-1882
This commit is contained in:
parent
43da60bfb2
commit
b275140229
12
modules/gui/src/com/haulmont/cuba/gui/window-ext.xsd
Normal file
12
modules/gui/src/com/haulmont/cuba/gui/window-ext.xsd
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<xs:schema
|
||||||
|
targetNamespace="http://schemas.haulmont.com/cuba/4.0/window-ext.xsd"
|
||||||
|
xmlns:xs="http://www.w3.org/2001/XMLSchema"
|
||||||
|
xmlns="http://schemas.haulmont.com/cuba/4.0/window-ext.xsd"
|
||||||
|
elementFormDefault="qualified"
|
||||||
|
attributeFormDefault="unqualified"
|
||||||
|
>
|
||||||
|
|
||||||
|
<xs:attribute name="index" type="xs:int"/>
|
||||||
|
|
||||||
|
</xs:schema>
|
@ -153,10 +153,12 @@
|
|||||||
|
|
||||||
<xs:attributeGroup name="hasId">
|
<xs:attributeGroup name="hasId">
|
||||||
<xs:attribute name="id" type="xs:string" use="optional"/>
|
<xs:attribute name="id" type="xs:string" use="optional"/>
|
||||||
|
<xs:anyAttribute namespace="##other" processContents="lax"/>
|
||||||
</xs:attributeGroup>
|
</xs:attributeGroup>
|
||||||
|
|
||||||
<xs:attributeGroup name="requiresId">
|
<xs:attributeGroup name="requiresId">
|
||||||
<xs:attribute name="id" type="xs:string" use="required"/>
|
<xs:attribute name="id" type="xs:string" use="required"/>
|
||||||
|
<xs:anyAttribute namespace="##other" processContents="lax"/>
|
||||||
</xs:attributeGroup>
|
</xs:attributeGroup>
|
||||||
|
|
||||||
<xs:attributeGroup name="hasSize">
|
<xs:attributeGroup name="hasSize">
|
||||||
@ -847,6 +849,7 @@
|
|||||||
<xs:sequence>
|
<xs:sequence>
|
||||||
<xs:element name="field" minOccurs="1" maxOccurs="unbounded" type="fieldGroupField"/>
|
<xs:element name="field" minOccurs="1" maxOccurs="unbounded" type="fieldGroupField"/>
|
||||||
</xs:sequence>
|
</xs:sequence>
|
||||||
|
<xs:attributeGroup ref="hasId"/>
|
||||||
<xs:attribute name="width" type="xs:string" use="optional"/>
|
<xs:attribute name="width" type="xs:string" use="optional"/>
|
||||||
<xs:attribute name="flex" type="xs:string" use="optional"/>
|
<xs:attribute name="flex" type="xs:string" use="optional"/>
|
||||||
</xs:complexType>
|
</xs:complexType>
|
||||||
|
@ -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.
|
* Haulmont Technology proprietary and confidential.
|
||||||
* Use is subject to license terms.
|
* Use is subject to license terms.
|
||||||
|
|
||||||
* Author: Konstantin Krivopustov
|
|
||||||
* Created: 04.03.2010 11:11:58
|
|
||||||
*
|
|
||||||
* $Id$
|
|
||||||
*/
|
*/
|
||||||
package com.haulmont.cuba.gui.xml;
|
package com.haulmont.cuba.gui.xml;
|
||||||
|
|
||||||
import com.haulmont.bali.util.Dom4j;
|
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 com.haulmont.cuba.gui.xml.layout.LayoutLoader;
|
||||||
import org.apache.commons.io.IOUtils;
|
import org.apache.commons.io.IOUtils;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
@ -23,6 +19,12 @@ import java.io.InputStream;
|
|||||||
import java.io.StringWriter;
|
import java.io.StringWriter;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides inheritance of screen XML descriptors.
|
||||||
|
*
|
||||||
|
* @author krivopustov
|
||||||
|
* @version $Id$
|
||||||
|
*/
|
||||||
public class XmlInheritanceProcessor {
|
public class XmlInheritanceProcessor {
|
||||||
|
|
||||||
private static Log log = LogFactory.getLog(XmlInheritanceProcessor.class);
|
private static Log log = LogFactory.getLog(XmlInheritanceProcessor.class);
|
||||||
@ -31,13 +33,15 @@ public class XmlInheritanceProcessor {
|
|||||||
private Namespace extNs;
|
private Namespace extNs;
|
||||||
private Map<String, Object> params;
|
private Map<String, Object> params;
|
||||||
|
|
||||||
private List<ElementTargetLocator> targetLocators = new ArrayList<ElementTargetLocator>();
|
private List<ElementTargetLocator> targetLocators = new ArrayList<>();
|
||||||
|
|
||||||
|
protected Resources resources = AppBeans.get(Resources.class);
|
||||||
|
|
||||||
public XmlInheritanceProcessor(Document document, Map<String, Object> params) {
|
public XmlInheritanceProcessor(Document document, Map<String, Object> params) {
|
||||||
this.document = document;
|
this.document = document;
|
||||||
this.params = params;
|
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 ViewPropertyElementTargetLocator());
|
||||||
targetLocators.add(new ViewElementTargetLocator());
|
targetLocators.add(new ViewElementTargetLocator());
|
||||||
@ -51,7 +55,7 @@ public class XmlInheritanceProcessor {
|
|||||||
Element root = document.getRootElement();
|
Element root = document.getRootElement();
|
||||||
String ancestorTemplate = root.attributeValue("extends");
|
String ancestorTemplate = root.attributeValue("extends");
|
||||||
if (!StringUtils.isBlank(ancestorTemplate)) {
|
if (!StringUtils.isBlank(ancestorTemplate)) {
|
||||||
InputStream ancestorStream = ScriptingProvider.getResourceAsStream(ancestorTemplate);
|
InputStream ancestorStream = resources.getResourceAsStream(ancestorTemplate);
|
||||||
if (ancestorStream == null) {
|
if (ancestorStream == null) {
|
||||||
ancestorStream = getClass().getResourceAsStream(ancestorTemplate);
|
ancestorStream = getClass().getResourceAsStream(ancestorTemplate);
|
||||||
if (ancestorStream == null) {
|
if (ancestorStream == null) {
|
||||||
|
Loading…
Reference in New Issue
Block a user