Search in sources :

Example 1 with Embedded

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);
}
Also used : MalformedURLException(java.net.MalformedURLException) GuiDevelopmentException(com.haulmont.cuba.gui.GuiDevelopmentException) Embedded(com.haulmont.cuba.gui.components.Embedded) URL(java.net.URL)

Aggregations

GuiDevelopmentException (com.haulmont.cuba.gui.GuiDevelopmentException)1 Embedded (com.haulmont.cuba.gui.components.Embedded)1 MalformedURLException (java.net.MalformedURLException)1 URL (java.net.URL)1