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;
}
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;
}
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;
}
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());
}
}
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);
}
}
}
}
Aggregations