use of io.jmix.ui.GuiDevelopmentException in project jmix by jmix-framework.
the class AbstractPaginationLoader method loadDataSourceProvider.
protected void loadDataSourceProvider(Element element) {
Element loaderProvider = element.element("loaderProvider");
Element containerProvider = element.element("containerProvider");
if (loaderProvider != null && containerProvider != null) {
throw new GuiDevelopmentException("Pagination must have only one provider: 'loaderProvider' or 'containerProvider'", getContext());
}
if (loaderProvider != null) {
loadString(loaderProvider, "loaderId", id -> {
ScreenData screenData = UiControllerUtils.getScreenData(getComponentContext().getFrame().getFrameOwner());
DataLoader loader = screenData.getLoader(id);
if (loader instanceof BaseCollectionLoader) {
PaginationDataBinder dataSourceProvider = applicationContext.getBean(PaginationLoaderBinder.class, loader);
resultComponent.setDataBinder(dataSourceProvider);
} else {
throw new GuiDevelopmentException(String.format("PaginationDataSourceProvider does not support %s loader type", loader.getClass().getCanonicalName()), getContext());
}
});
if (resultComponent.getDataBinder() == null) {
throw new GuiDevelopmentException("Specify 'loaderId' attribute of `loaderProvider` element", getContext());
}
}
if (containerProvider != null) {
loadString(containerProvider, "dataContainer", containerId -> {
ScreenData screenData = UiControllerUtils.getScreenData(getComponentContext().getFrame().getFrameOwner());
InstanceContainer container = screenData.getContainer(containerId);
if (container instanceof CollectionContainer) {
PaginationDataBinder dataSourceProvider = applicationContext.getBean(PaginationContainerBinder.class, container);
resultComponent.setDataBinder(dataSourceProvider);
} else {
throw new GuiDevelopmentException(String.format("PaginationDataSourceProvider does not support %s container type", container.getClass().getCanonicalName()), getContext());
}
});
if (resultComponent.getDataBinder() == null) {
throw new GuiDevelopmentException("Specify 'dataContainer' attribute of `containerProvider` element", getContext());
}
}
}
use of io.jmix.ui.GuiDevelopmentException in project jmix by jmix-framework.
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);
}
UrlResource resource = applicationContext.getBean(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);
}
}
use of io.jmix.ui.GuiDevelopmentException in project jmix by jmix-framework.
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);
}
resultComponent.setSource(ThemeResource.class).setPath(themePath);
return true;
}
use of io.jmix.ui.GuiDevelopmentException in project jmix by jmix-framework.
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);
}
RelativePathResource resource = applicationContext.getBean(RelativePathResource.class);
resource.setPath(path);
loadMimeType(resource, relativePath);
resultComponent.setSource(resource);
return true;
}
use of io.jmix.ui.GuiDevelopmentException in project jmix by jmix-framework.
the class AbstractSingleFilterComponentLoader method loadValueComponent.
@SuppressWarnings("unchecked")
protected void loadValueComponent(C resultComponent, Element element) {
Component valueComponent;
if (!element.elements().isEmpty()) {
valueComponent = createValueComponent(element.elements());
} else {
valueComponent = generateValueComponent();
}
if (!(valueComponent instanceof HasValue)) {
throw new GuiDevelopmentException("Value component of the PropertyFilter must implement HasValue", getComponentContext().getCurrentFrameId());
}
resultComponent.setValueComponent((HasValue) valueComponent);
}
Aggregations