use of io.jmix.ui.GuiDevelopmentException in project jmix by jmix-framework.
the class AbstractDataGridLoader method initDataGridDataHolder.
protected DataGridDataHolder initDataGridDataHolder() {
DataGridDataHolder holder = new DataGridDataHolder();
String containerId = element.attributeValue("dataContainer");
if (Strings.isNullOrEmpty(containerId)) {
loadMetaClass(element, holder::setMetaClass);
return holder;
}
FrameOwner frameOwner = getComponentContext().getFrame().getFrameOwner();
ScreenData screenData = UiControllerUtils.getScreenData(frameOwner);
InstanceContainer container = screenData.getContainer(containerId);
CollectionContainer collectionContainer;
if (container instanceof CollectionContainer) {
collectionContainer = (CollectionContainer) container;
} else {
throw new GuiDevelopmentException("Not a CollectionContainer: " + containerId, context);
}
if (collectionContainer instanceof CollectionPropertyContainer) {
initMasterDataLoaderListener((CollectionPropertyContainer) collectionContainer);
}
if (collectionContainer instanceof HasLoader) {
holder.setDataLoader(((HasLoader) collectionContainer).getLoader());
}
holder.setMetaClass(collectionContainer.getEntityMetaClass());
holder.setContainer(collectionContainer);
holder.setFetchPlan(collectionContainer.getFetchPlan());
return holder;
}
use of io.jmix.ui.GuiDevelopmentException in project jmix by jmix-framework.
the class RelatedEntitiesLoader method loadPropertyOption.
protected void loadPropertyOption(Element routeElement) {
String property = loadString(routeElement, "name").orElseThrow(() -> new GuiDevelopmentException("Name attribute for related entities property is not specified", context, "componentId", resultComponent.getId()));
String caption = loadResourceString(routeElement.attributeValue("caption"));
String configurationName = loadResourceString(routeElement.attributeValue("configurationName"));
String screen = routeElement.attributeValue("screen");
if (StringUtils.isNotEmpty(screen)) {
if (getWindowConfig().findWindowInfo(screen) == null) {
throw new GuiDevelopmentException("Screen for custom route in related entities not found", context, "componentId", resultComponent.getId());
}
}
resultComponent.addPropertyOption(new PropertyOption(property, caption, configurationName, screen));
}
use of io.jmix.ui.GuiDevelopmentException in project jmix by jmix-framework.
the class SideMenuLoader method loadSidePanel.
protected void loadSidePanel(SideMenu component, Element element) {
String sidePanelId = element.attributeValue("sidePanel");
if (StringUtils.isNotEmpty(sidePanelId)) {
Component sidePanel = resultComponent.getFrame().getComponent(sidePanelId);
if (sidePanel == null) {
throw new GuiDevelopmentException("Unable to find sidePanel component for SideMenu", context, "sidePanel", sidePanelId);
}
component.setSidePanel(sidePanel);
}
}
use of io.jmix.ui.GuiDevelopmentException in project jmix by jmix-framework.
the class JavaScriptComponentLoader method loadDependencies.
protected void loadDependencies(JavaScriptComponent component, Element element) {
Element dependenciesElement = element.element("dependencies");
if (dependenciesElement == null) {
return;
}
List<JavaScriptComponent.ClientDependency> dependencies = new ArrayList<>();
for (Element dependency : dependenciesElement.elements("dependency")) {
String path = dependency.attributeValue("path");
if (Strings.isNullOrEmpty(path)) {
throw new GuiDevelopmentException("No path provided for a JavaScriptComponent dependency", context);
}
String type = dependency.attributeValue("type");
JavaScriptComponent.DependencyType dependencyType = !Strings.isNullOrEmpty(type) ? JavaScriptComponent.DependencyType.valueOf(type) : null;
dependencies.add(new JavaScriptComponent.ClientDependency(path, dependencyType));
}
component.setDependencies(dependencies);
}
use of io.jmix.ui.GuiDevelopmentException in project jmix by jmix-framework.
the class SplitPanelLoader method loadMinSplitPosition.
protected void loadMinSplitPosition(SplitPanel resultComponent, Element element) {
String minSplitPosition = element.attributeValue("minSplitPosition");
if (!StringUtils.isEmpty(minSplitPosition)) {
int position;
SizeUnit unit;
if (minSplitPosition.endsWith("px")) {
position = Integer.parseInt(minSplitPosition.substring(0, minSplitPosition.indexOf("px")));
unit = SizeUnit.PIXELS;
} else if (minSplitPosition.endsWith("%")) {
position = Integer.parseInt(minSplitPosition.substring(0, minSplitPosition.indexOf("%")));
unit = SizeUnit.PERCENTAGE;
} else {
throw new GuiDevelopmentException("Unit of minSplitPosition is not set", context);
}
resultComponent.setMinSplitPosition(position, unit);
}
}
Aggregations