Search in sources :

Example 26 with WindowConfig

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);
    }
}
Also used : WindowConfig(com.haulmont.cuba.gui.config.WindowConfig) LayoutLoader(com.haulmont.cuba.gui.xml.layout.LayoutLoader) Element(org.dom4j.Element) GuiDevelopmentException(com.haulmont.cuba.gui.GuiDevelopmentException) WindowInfo(com.haulmont.cuba.gui.config.WindowInfo) ComponentLoader(com.haulmont.cuba.gui.xml.layout.ComponentLoader)

Example 27 with WindowConfig

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);
}
Also used : WindowConfig(com.haulmont.cuba.gui.config.WindowConfig) Element(org.dom4j.Element) GuiDevelopmentException(com.haulmont.cuba.gui.GuiDevelopmentException) ListComponent(com.haulmont.cuba.gui.components.ListComponent) ListComponent(com.haulmont.cuba.gui.components.ListComponent) Component(com.haulmont.cuba.gui.components.Component)

Aggregations

WindowConfig (com.haulmont.cuba.gui.config.WindowConfig)27 WindowInfo (com.haulmont.cuba.gui.config.WindowInfo)20 WebWindowManager (com.haulmont.cuba.web.WebWindowManager)15 MetaClass (com.haulmont.chile.core.model.MetaClass)3 GuiDevelopmentException (com.haulmont.cuba.gui.GuiDevelopmentException)3 WindowManager (com.haulmont.cuba.gui.WindowManager)2 Window (com.haulmont.cuba.gui.components.Window)2 Element (org.dom4j.Element)2 ErrorInfo (org.jdesktop.swingx.error.ErrorInfo)2 ParamsMap (com.haulmont.bali.util.ParamsMap)1 AbstractSearchFolder (com.haulmont.cuba.core.entity.AbstractSearchFolder)1 Entity (com.haulmont.cuba.core.entity.Entity)1 SoftDelete (com.haulmont.cuba.core.entity.SoftDelete)1 Messages (com.haulmont.cuba.core.global.Messages)1 UiPermissionTarget (com.haulmont.cuba.gui.app.security.entity.UiPermissionTarget)1 Component (com.haulmont.cuba.gui.components.Component)1 Filter (com.haulmont.cuba.gui.components.Filter)1 ListComponent (com.haulmont.cuba.gui.components.ListComponent)1 RemoveAction (com.haulmont.cuba.gui.components.actions.RemoveAction)1 DataSupplier (com.haulmont.cuba.gui.data.DataSupplier)1