use of com.haulmont.cuba.gui.config.WindowConfig in project cuba by cuba-platform.
the class FrameComponentLoader method createComponent.
@Override
public void createComponent() {
String src = element.attributeValue("src");
String screenId = element.attributeValue("screen");
if (src == null && screenId == null) {
throw new GuiDevelopmentException("Either 'src' or 'screen' must be specified for 'frame'", context.getFullFrameId());
}
if (src == null) {
WindowConfig windowConfig = AppBeans.get(WindowConfig.NAME);
WindowInfo windowInfo = windowConfig.getWindowInfo(screenId);
src = windowInfo.getTemplate();
if (src == null) {
throw new GuiDevelopmentException("Screen " + screenId + " doesn't have template path configured", context.getFullFrameId());
}
}
if (element.attributeValue("id") != null) {
frameId = element.attributeValue("id");
}
LayoutLoader layoutLoader = new LayoutLoader(context, factory, LayoutLoaderConfig.getFrameLoaders());
layoutLoader.setLocale(getLocale());
layoutLoader.setMessagesPack(getMessagesPack());
String currentFrameId = context.getCurrentFrameId();
context.setCurrentFrameId(frameId);
try {
Pair<ComponentLoader, Element> loaderElementPair = layoutLoader.createFrameComponent(src, frameId, context.getParams());
frameLoader = loaderElementPair.getFirst();
resultComponent = (Frame) frameLoader.getResultComponent();
} finally {
context.setCurrentFrameId(currentFrameId);
}
}
use of com.haulmont.cuba.gui.config.WindowConfig in project cuba by cuba-platform.
the class RelatedEntitiesLoader method loadComponent.
@Override
public void loadComponent() {
assignFrame(resultComponent);
loadCaption(resultComponent, element);
loadIcon(resultComponent, element);
loadWidth(resultComponent, element);
loadStyleName(resultComponent, element);
loadEnable(resultComponent, element);
loadVisible(resultComponent, element);
loadAlign(resultComponent, element);
String openType = element.attributeValue("openType");
if (StringUtils.isNotEmpty(openType)) {
resultComponent.setOpenType(OpenType.valueOf(openType));
}
String exclude = element.attributeValue("exclude");
if (StringUtils.isNotBlank(exclude)) {
resultComponent.setExcludePropertiesRegex(exclude);
}
for (Object routeObject : element.elements("property")) {
Element routeElement = (Element) routeObject;
String property = routeElement.attributeValue("name");
if (StringUtils.isEmpty(property)) {
throw new GuiDevelopmentException("Name attribute for related entities property is not specified", context.getFullFrameId(), "componentId", resultComponent.getId());
}
String caption = loadResourceString(routeElement.attributeValue("caption"));
String filterCaption = loadResourceString(routeElement.attributeValue("filterCaption"));
String screen = routeElement.attributeValue("screen");
if (StringUtils.isNotEmpty(screen)) {
WindowConfig windowConfig = AppBeans.get(WindowConfig.NAME);
if (windowConfig.findWindowInfo(screen) == null) {
throw new GuiDevelopmentException("Screen for custom route in related entities not found", context.getFullFrameId(), "componentId", resultComponent.getId());
}
}
resultComponent.addPropertyOption(property, screen, caption, filterCaption);
}
String listComponent = element.attributeValue("for");
if (StringUtils.isEmpty(listComponent)) {
throw new GuiDevelopmentException("'for' attribute of related entities is not specified", context.getFullFrameId(), "componentId", resultComponent.getId());
}
context.addPostInitTask((context1, window) -> {
if (resultComponent.getListComponent() == null) {
Component bindComponent = resultComponent.getFrame().getComponent(listComponent);
if (!(bindComponent instanceof ListComponent)) {
throw new GuiDevelopmentException("Specify 'for' attribute: id of table or tree", context1.getFullFrameId(), "componentId", resultComponent.getId());
}
resultComponent.setListComponent((ListComponent) bindComponent);
}
});
loadFocusable(resultComponent, element);
loadTabIndex(resultComponent, element);
}
Aggregations