Search in sources :

Example 6 with GuiDevelopmentException

use of com.haulmont.cuba.gui.GuiDevelopmentException in project cuba by cuba-platform.

the class AbstractResourceViewLoader method loadRelativePathResource.

protected boolean loadRelativePathResource(ResourceView resultComponent, Element element) {
    Element relativePath = element.element("relativePath");
    if (relativePath == null)
        return false;
    String path = relativePath.attributeValue("path");
    if (StringUtils.isEmpty(path)) {
        throw new GuiDevelopmentException("No path provided for the RelativePathResource", context.getFullFrameId());
    }
    RelativePathResource resource = resultComponent.createResource(RelativePathResource.class);
    resource.setPath(path);
    loadMimeType(resource, relativePath);
    resultComponent.setSource(resource);
    return true;
}
Also used : Element(org.dom4j.Element) GuiDevelopmentException(com.haulmont.cuba.gui.GuiDevelopmentException)

Example 7 with GuiDevelopmentException

use of com.haulmont.cuba.gui.GuiDevelopmentException in project cuba by cuba-platform.

the class AbstractResourceViewLoader method loadClasspathResource.

protected boolean loadClasspathResource(ResourceView resultComponent, Element element) {
    Element classpathResource = element.element("classpath");
    if (classpathResource == null)
        return false;
    String classpathPath = classpathResource.attributeValue("path");
    if (StringUtils.isEmpty(classpathPath)) {
        throw new GuiDevelopmentException("No path provided for the ClasspathResource", context.getFullFrameId());
    }
    ClasspathResource resource = resultComponent.createResource(ClasspathResource.class);
    resource.setPath(classpathPath);
    loadMimeType(resource, classpathResource);
    loadStreamSettings(resource, classpathResource);
    resultComponent.setSource(resource);
    return true;
}
Also used : Element(org.dom4j.Element) GuiDevelopmentException(com.haulmont.cuba.gui.GuiDevelopmentException)

Example 8 with GuiDevelopmentException

use of com.haulmont.cuba.gui.GuiDevelopmentException in project cuba by cuba-platform.

the class AbstractResourceViewLoader method loadThemeResource.

protected boolean loadThemeResource(ResourceView resultComponent, Element element) {
    Element themeResource = element.element("theme");
    if (themeResource == null)
        return false;
    String themePath = themeResource.attributeValue("path");
    if (StringUtils.isEmpty(themePath)) {
        throw new GuiDevelopmentException("No path provided for the ThemeResource", context.getFullFrameId());
    }
    resultComponent.setSource(ThemeResource.class).setPath(themePath);
    return true;
}
Also used : Element(org.dom4j.Element) GuiDevelopmentException(com.haulmont.cuba.gui.GuiDevelopmentException)

Example 9 with GuiDevelopmentException

use of com.haulmont.cuba.gui.GuiDevelopmentException in project cuba by cuba-platform.

the class AbstractResourceViewLoader method loadUrlResource.

protected void loadUrlResource(ResourceView resultComponent, Element element) {
    Element urlResource = element.element("url");
    if (urlResource == null)
        return;
    String url = urlResource.attributeValue("url");
    if (StringUtils.isEmpty(url)) {
        throw new GuiDevelopmentException("No url provided for the UrlResource", context.getFullFrameId());
    }
    UrlResource resource = resultComponent.createResource(UrlResource.class);
    try {
        resource.setUrl(new URL(url));
        loadMimeType(resource, urlResource);
        resultComponent.setSource(resource);
    } catch (MalformedURLException e) {
        String msg = String.format("An error occurred while creating UrlResource with the given url: %s", url);
        throw new GuiDevelopmentException(msg, context.getFullFrameId());
    }
}
Also used : MalformedURLException(java.net.MalformedURLException) Element(org.dom4j.Element) GuiDevelopmentException(com.haulmont.cuba.gui.GuiDevelopmentException) URL(java.net.URL)

Example 10 with GuiDevelopmentException

use of com.haulmont.cuba.gui.GuiDevelopmentException in project cuba by cuba-platform.

the class CalendarLoader method loadDatasource.

protected void loadDatasource(Calendar component, Element element) {
    final String datasource = element.attributeValue("datasource");
    if (!StringUtils.isEmpty(datasource)) {
        CollectionDatasource ds = (CollectionDatasource) context.getDsContext().get(datasource);
        if (ds == null) {
            throw new GuiDevelopmentException(String.format("Datasource '%s' is not defined", datasource), getContext().getFullFrameId(), "Component ID", component.getId());
        }
        component.setDatasource(ds);
        if (component.getEventProvider() instanceof EntityCalendarEventProvider) {
            EntityCalendarEventProvider eventProvider = (EntityCalendarEventProvider) component.getEventProvider();
            String startDateProperty = element.attributeValue("startDateProperty");
            if (StringUtils.isNotEmpty(startDateProperty)) {
                eventProvider.setStartDateProperty(startDateProperty);
            }
            String endDateProperty = element.attributeValue("endDateProperty");
            if (StringUtils.isNotEmpty(endDateProperty)) {
                eventProvider.setEndDateProperty(endDateProperty);
            }
            String captionProperty = element.attributeValue("captionProperty");
            if (StringUtils.isNotEmpty(captionProperty)) {
                eventProvider.setCaptionProperty(captionProperty);
            }
            String descriptionProperty = element.attributeValue("descriptionProperty");
            if (StringUtils.isNotEmpty(descriptionProperty)) {
                eventProvider.setDescriptionProperty(descriptionProperty);
            }
            String styleNameProperty = element.attributeValue("stylenameProperty");
            if (StringUtils.isNotEmpty(styleNameProperty)) {
                eventProvider.setStyleNameProperty(styleNameProperty);
            }
            String allDayProperty = element.attributeValue("isAllDayProperty");
            if (StringUtils.isNotEmpty(allDayProperty)) {
                eventProvider.setAllDayProperty(allDayProperty);
            }
        }
    }
}
Also used : CollectionDatasource(com.haulmont.cuba.gui.data.CollectionDatasource) GuiDevelopmentException(com.haulmont.cuba.gui.GuiDevelopmentException) EntityCalendarEventProvider(com.haulmont.cuba.gui.components.calendar.EntityCalendarEventProvider)

Aggregations

GuiDevelopmentException (com.haulmont.cuba.gui.GuiDevelopmentException)55 Element (org.dom4j.Element)23 CollectionDatasource (com.haulmont.cuba.gui.data.CollectionDatasource)8 Component (com.haulmont.cuba.gui.components.Component)7 Datasource (com.haulmont.cuba.gui.data.Datasource)7 InvocationTargetException (java.lang.reflect.InvocationTargetException)6 MetaClass (com.haulmont.chile.core.model.MetaClass)5 ComponentLoader (com.haulmont.cuba.gui.xml.layout.ComponentLoader)4 MetaProperty (com.haulmont.chile.core.model.MetaProperty)3 MetaPropertyPath (com.haulmont.chile.core.model.MetaPropertyPath)3 CategoryAttribute (com.haulmont.cuba.core.entity.CategoryAttribute)3 MetadataTools (com.haulmont.cuba.core.global.MetadataTools)3 WindowConfig (com.haulmont.cuba.gui.config.WindowConfig)3 LayoutLoader (com.haulmont.cuba.gui.xml.layout.LayoutLoader)3 FileDescriptor (com.haulmont.cuba.core.entity.FileDescriptor)2 WindowManager (com.haulmont.cuba.gui.WindowManager)2 Column (com.haulmont.cuba.gui.components.DataGrid.Column)2 ListComponent (com.haulmont.cuba.gui.components.ListComponent)2 DsContext (com.haulmont.cuba.gui.data.DsContext)2 ByteArrayDataProvider (com.haulmont.cuba.gui.export.ByteArrayDataProvider)2