use of com.haulmont.cuba.gui.components.Embedded in project cuba by cuba-platform.
the class EmbeddedLoader method loadComponent.
@Override
public void loadComponent() {
assignFrame(resultComponent);
String relativeSrc = element.attributeValue("relativeSrc");
if (StringUtils.isNotEmpty(relativeSrc)) {
resultComponent.setRelativeSource(relativeSrc);
}
String srcAttr = element.attributeValue("src");
if (srcAttr != null) {
if (srcAttr.startsWith(URL_PREFIX)) {
String src = srcAttr.substring(URL_PREFIX.length());
URL targetUrl;
try {
targetUrl = new URL(src);
} catch (MalformedURLException e) {
throw new GuiDevelopmentException("Incorrect URL in Embedded src attribute", context.getFullFrameId(), "src", srcAttr);
}
resultComponent.setType(Embedded.Type.BROWSER);
resultComponent.setSource(targetUrl);
} else if (srcAttr.startsWith(THEME_PREFIX)) {
resultComponent.setSource(srcAttr);
} else if (srcAttr.startsWith(FILE_PREFIX)) {
String src = srcAttr.substring(FILE_PREFIX.length());
resultComponent.setType(Embedded.Type.OBJECT);
resultComponent.setSource(src);
} else {
throw new GuiDevelopmentException("Illegal src attribute value. 'url://' or 'file://' or theme:// prefix expected", context.getFullFrameId(), "src", srcAttr);
}
}
String typeAttribute = element.attributeValue("type");
if (StringUtils.isNotEmpty(typeAttribute)) {
Embedded.Type type = Embedded.Type.valueOf(typeAttribute);
resultComponent.setType(type);
}
loadVisible(resultComponent, element);
loadEnable(resultComponent, element);
loadStyleName(resultComponent, element);
loadHeight(resultComponent, element);
loadWidth(resultComponent, element);
loadAlign(resultComponent, element);
loadCaption(resultComponent, element);
loadDescription(resultComponent, element);
loadIcon(resultComponent, element);
}
Aggregations