use of com.haulmont.cuba.desktop.theme.ComponentDecorator in project cuba by cuba-platform.
the class CustomDecorator method decorate.
@Override
public void decorate(Object component, Set<String> state) {
try {
ComponentDecorator delegate = (ComponentDecorator) decoratorClass.newInstance();
delegate.decorate(component, state);
} catch (InstantiationException | IllegalAccessException e) {
throw new RuntimeException(e);
}
}
use of com.haulmont.cuba.desktop.theme.ComponentDecorator in project cuba by cuba-platform.
the class DesktopThemeLoaderImpl method loadStyle.
private DesktopStyle loadStyle(Element element) {
final String componentsSubTag = "components";
String styleName = element.attributeValue("name");
List<Class> components = null;
if (element.attributeValue("component") != null) {
String className = element.attributeValue("component");
try {
components = Collections.singletonList((Class) Class.forName(className));
} catch (ClassNotFoundException e) {
log.error("Unknown component class: " + className);
}
} else {
Element componentsElement = element.element(componentsSubTag);
if (componentsElement != null) {
String componentsStr = componentsElement.getTextTrim();
StrTokenizer tokenizer = new StrTokenizer(componentsStr);
components = new ArrayList<>();
for (String className : tokenizer.getTokenArray()) {
try {
components.add(Class.forName(className));
} catch (ClassNotFoundException e) {
log.error("Unknown component class: " + className);
}
}
}
}
List<ComponentDecorator> decorators = new ArrayList<>();
for (Element childElement : (List<Element>) element.elements()) {
if (!componentsSubTag.equals(childElement.getName())) {
ComponentDecorator decorator = loadDecorator(childElement);
if (decorator != null) {
decorators.add(decorator);
}
}
}
return new DesktopStyle(styleName, decorators, components);
}
Aggregations