mirror of
https://gitee.com/jmix/cuba.git
synced 2024-12-05 04:38:10 +08:00
PL-10274 Make class and componentLoader optional in ui-component.xsd
This commit is contained in:
parent
07d200ab4e
commit
1faca6452e
@ -149,24 +149,42 @@ public class DesktopExternalUIComponentsSource implements ExternalUIComponentsSo
|
|||||||
tag = name;
|
tag = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
Class<?> componentLoaderClass = classLoader.loadClass(componentLoaderClassName);
|
if (StringUtils.isEmpty(name) && StringUtils.isEmpty(tag)) {
|
||||||
Class<?> componentClass = classLoader.loadClass(componentClassName);
|
log.warn("You have to provide name or tag for custom component");
|
||||||
|
// skip this <component> element
|
||||||
if (Component.class.isAssignableFrom(componentClass)) {
|
continue;
|
||||||
log.trace("Register component {} class {}", name, componentClass.getCanonicalName());
|
|
||||||
|
|
||||||
DesktopComponentsFactory.registerComponent(name, (Class<? extends Component>) componentClass);
|
|
||||||
} else {
|
|
||||||
log.warn("Component {} is not a subclass of com.haulmont.cuba.gui.components.Component", componentClassName);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ComponentLoader.class.isAssignableFrom(componentLoaderClass)) {
|
if (StringUtils.isEmpty(componentLoaderClassName) && StringUtils.isEmpty(componentClassName)) {
|
||||||
log.trace("Register tag {} loader {}", tag, componentLoaderClass.getCanonicalName());
|
log.warn("You have to provide at least <class> or <componentLoader> for custom component {} / <{}>",
|
||||||
|
name, tag);
|
||||||
|
// skip this <component> element
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
LayoutLoaderConfig.registerLoader(tag, (Class<? extends ComponentLoader>) componentLoaderClass);
|
if (StringUtils.isNotEmpty(name) && StringUtils.isNotEmpty(componentClassName)) {
|
||||||
} else {
|
Class<?> componentClass = classLoader.loadClass(componentClassName);
|
||||||
log.warn("Component loader {} is not a subclass of com.haulmont.cuba.gui.xml.layout.ComponentLoader",
|
|
||||||
componentLoaderClassName);
|
if (Component.class.isAssignableFrom(componentClass)) {
|
||||||
|
log.trace("Register component {} class {}", name, componentClass.getCanonicalName());
|
||||||
|
|
||||||
|
DesktopComponentsFactory.registerComponent(name, (Class<? extends Component>) componentClass);
|
||||||
|
} else {
|
||||||
|
log.warn("Component {} is not a subclass of com.haulmont.cuba.gui.components.Component", componentClassName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (StringUtils.isNotEmpty(tag) && StringUtils.isNotEmpty(componentLoaderClassName)) {
|
||||||
|
Class<?> componentLoaderClass = classLoader.loadClass(componentLoaderClassName);
|
||||||
|
|
||||||
|
if (ComponentLoader.class.isAssignableFrom(componentLoaderClass)) {
|
||||||
|
log.trace("Register tag {} loader {}", tag, componentLoaderClass.getCanonicalName());
|
||||||
|
|
||||||
|
LayoutLoaderConfig.registerLoader(tag, (Class<? extends ComponentLoader>) componentLoaderClass);
|
||||||
|
} else {
|
||||||
|
log.warn("Component loader {} is not a subclass of com.haulmont.cuba.gui.xml.layout.ComponentLoader",
|
||||||
|
componentLoaderClassName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,6 +26,28 @@
|
|||||||
<xs:element name="component">
|
<xs:element name="component">
|
||||||
<xs:complexType>
|
<xs:complexType>
|
||||||
<xs:all>
|
<xs:all>
|
||||||
|
<!-- ComponentsFactory create component NAME-CLASS -->
|
||||||
|
|
||||||
|
<xs:element name="name" minOccurs="0">
|
||||||
|
<xs:complexType>
|
||||||
|
<xs:simpleContent>
|
||||||
|
<xs:extension base="xs:string">
|
||||||
|
</xs:extension>
|
||||||
|
</xs:simpleContent>
|
||||||
|
</xs:complexType>
|
||||||
|
</xs:element>
|
||||||
|
|
||||||
|
<xs:element name="class" minOccurs="0">
|
||||||
|
<xs:complexType>
|
||||||
|
<xs:simpleContent>
|
||||||
|
<xs:extension base="xs:string">
|
||||||
|
</xs:extension>
|
||||||
|
</xs:simpleContent>
|
||||||
|
</xs:complexType>
|
||||||
|
</xs:element>
|
||||||
|
|
||||||
|
<!-- ComponentsFactory XML loaders TAG-LOADER_CLASS -->
|
||||||
|
|
||||||
<xs:element name="tag" minOccurs="0">
|
<xs:element name="tag" minOccurs="0">
|
||||||
<xs:complexType>
|
<xs:complexType>
|
||||||
<xs:simpleContent>
|
<xs:simpleContent>
|
||||||
@ -35,25 +57,7 @@
|
|||||||
</xs:complexType>
|
</xs:complexType>
|
||||||
</xs:element>
|
</xs:element>
|
||||||
|
|
||||||
<xs:element name="name">
|
<xs:element name="componentLoader" minOccurs="0">
|
||||||
<xs:complexType>
|
|
||||||
<xs:simpleContent>
|
|
||||||
<xs:extension base="xs:string">
|
|
||||||
</xs:extension>
|
|
||||||
</xs:simpleContent>
|
|
||||||
</xs:complexType>
|
|
||||||
</xs:element>
|
|
||||||
|
|
||||||
<xs:element name="class">
|
|
||||||
<xs:complexType>
|
|
||||||
<xs:simpleContent>
|
|
||||||
<xs:extension base="xs:string">
|
|
||||||
</xs:extension>
|
|
||||||
</xs:simpleContent>
|
|
||||||
</xs:complexType>
|
|
||||||
</xs:element>
|
|
||||||
|
|
||||||
<xs:element name="componentLoader">
|
|
||||||
<xs:complexType>
|
<xs:complexType>
|
||||||
<xs:simpleContent>
|
<xs:simpleContent>
|
||||||
<xs:extension base="xs:string">
|
<xs:extension base="xs:string">
|
||||||
|
@ -154,24 +154,42 @@ public class WebExternalUIComponentsSource implements ExternalUIComponentsSource
|
|||||||
tag = name;
|
tag = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
Class<?> componentLoaderClass = classLoader.loadClass(componentLoaderClassName);
|
if (StringUtils.isEmpty(name) && StringUtils.isEmpty(tag)) {
|
||||||
Class<?> componentClass = classLoader.loadClass(componentClassName);
|
log.warn("You have to provide name or tag for custom component");
|
||||||
|
// skip this <component> element
|
||||||
if (Component.class.isAssignableFrom(componentClass)) {
|
continue;
|
||||||
log.trace("Register component {} class {}", name, componentClass.getCanonicalName());
|
|
||||||
|
|
||||||
webComponentsFactory.register(name, (Class<? extends Component>) componentClass);
|
|
||||||
} else {
|
|
||||||
log.warn("Component {} is not a subclass of com.haulmont.cuba.gui.components.Component", componentClassName);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ComponentLoader.class.isAssignableFrom(componentLoaderClass)) {
|
if (StringUtils.isEmpty(componentLoaderClassName) && StringUtils.isEmpty(componentClassName)) {
|
||||||
log.trace("Register tag {} loader {}", tag, componentLoaderClass.getCanonicalName());
|
log.warn("You have to provide at least <class> or <componentLoader> for custom component {} / <{}>",
|
||||||
|
name, tag);
|
||||||
|
// skip this <component> element
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
LayoutLoaderConfig.registerLoader(tag, (Class<? extends ComponentLoader>) componentLoaderClass);
|
if (StringUtils.isNotEmpty(name) && StringUtils.isNotEmpty(componentClassName)) {
|
||||||
} else {
|
Class<?> componentClass = classLoader.loadClass(componentClassName);
|
||||||
log.warn("Component loader {} is not a subclass of com.haulmont.cuba.gui.xml.layout.ComponentLoader",
|
|
||||||
componentLoaderClassName);
|
if (Component.class.isAssignableFrom(componentClass)) {
|
||||||
|
log.trace("Register component {} class {}", name, componentClass.getCanonicalName());
|
||||||
|
|
||||||
|
webComponentsFactory.register(name, (Class<? extends Component>) componentClass);
|
||||||
|
} else {
|
||||||
|
log.warn("Component {} is not a subclass of com.haulmont.cuba.gui.components.Component", componentClassName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (StringUtils.isNotEmpty(tag) && StringUtils.isNotEmpty(componentLoaderClassName)) {
|
||||||
|
Class<?> componentLoaderClass = classLoader.loadClass(componentLoaderClassName);
|
||||||
|
|
||||||
|
if (ComponentLoader.class.isAssignableFrom(componentLoaderClass)) {
|
||||||
|
log.trace("Register tag {} loader {}", tag, componentLoaderClass.getCanonicalName());
|
||||||
|
|
||||||
|
LayoutLoaderConfig.registerLoader(tag, (Class<? extends ComponentLoader>) componentLoaderClass);
|
||||||
|
} else {
|
||||||
|
log.warn("Component loader {} is not a subclass of com.haulmont.cuba.gui.xml.layout.ComponentLoader",
|
||||||
|
componentLoaderClassName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user