Search in sources :

Example 6 with DsContext

use of com.haulmont.cuba.gui.data.DsContext in project cuba by cuba-platform.

the class WindowManager method createWindow.

protected Window createWindow(WindowInfo windowInfo, OpenType openType, Map<String, Object> params, LayoutLoaderConfig layoutConfig, boolean topLevel) {
    if (!topLevel) {
        checkPermission(windowInfo);
    }
    StopWatch loadDescriptorWatch = new Slf4JStopWatch(windowInfo.getId() + "#" + LifeCycle.LOAD, LoggerFactory.getLogger(UIPerformanceLogger.class));
    Element element = screenXmlLoader.load(windowInfo.getTemplate(), windowInfo.getId(), params);
    // try to load main screen class to resolve dynamic compilation dependencies issues
    preloadMainScreenClass(element);
    ComponentLoaderContext componentLoaderContext = new ComponentLoaderContext(params);
    componentLoaderContext.setFullFrameId(windowInfo.getId());
    componentLoaderContext.setCurrentFrameId(windowInfo.getId());
    ComponentLoader windowLoader = createLayout(windowInfo, element, componentLoaderContext, layoutConfig);
    Window clientSpecificWindow = (Window) windowLoader.getResultComponent();
    Window windowWrapper = wrapByCustomClass(clientSpecificWindow, element);
    screenViewsLoader.deployViews(element);
    DsContext dsContext = loadDsContext(element);
    initDatasources(clientSpecificWindow, dsContext, params);
    componentLoaderContext.setDsContext(dsContext);
    WindowContext windowContext = new WindowContextImpl(clientSpecificWindow, openType, params);
    clientSpecificWindow.setContext(windowContext);
    dsContext.setFrameContext(windowContext);
    // noinspection unchecked
    windowLoader.loadComponent();
    clientSpecificWindow.setWindowManager(this);
    loadDescriptorWatch.stop();
    initWrapperFrame(windowWrapper, componentLoaderContext, element, params);
    componentLoaderContext.setFrame(windowWrapper);
    componentLoaderContext.executePostInitTasks();
    if (configuration.getConfig(GlobalConfig.class).getTestMode()) {
        initDebugIds(clientSpecificWindow);
    }
    StopWatch uiPermissionsWatch = new Slf4JStopWatch(windowInfo.getId() + "#" + LifeCycle.UI_PERMISSIONS, LoggerFactory.getLogger(UIPerformanceLogger.class));
    // apply ui permissions
    WindowCreationHelper.applyUiPermissions(clientSpecificWindow);
    uiPermissionsWatch.stop();
    return windowWrapper;
}
Also used : Slf4JStopWatch(org.perf4j.slf4j.Slf4JStopWatch) UIPerformanceLogger(com.haulmont.cuba.gui.logging.UIPerformanceLogger) DsContext(com.haulmont.cuba.gui.data.DsContext) Element(org.dom4j.Element) ComponentLoaderContext(com.haulmont.cuba.gui.xml.layout.loaders.ComponentLoaderContext) Slf4JStopWatch(org.perf4j.slf4j.Slf4JStopWatch) StopWatch(org.perf4j.StopWatch) ComponentLoader(com.haulmont.cuba.gui.xml.layout.ComponentLoader)

Example 7 with DsContext

use of com.haulmont.cuba.gui.data.DsContext in project cuba by cuba-platform.

the class FrameLoader method loadComponent.

@Override
public void loadComponent() {
    screenViewsLoader.deployViews(element);
    Element dsContextElement = element.element("dsContext");
    DsContextLoader contextLoader = new DsContextLoader(context.getDsContext().getDataSupplier());
    DsContext dsContext = contextLoader.loadDatasources(dsContextElement, context.getDsContext());
    assignXmlDescriptor(resultComponent, element);
    loadVisible(resultComponent, layoutElement);
    loadActions(resultComponent, element);
    loadSpacing(resultComponent, layoutElement);
    loadMargin(resultComponent, layoutElement);
    loadWidth(resultComponent, layoutElement);
    loadHeight(resultComponent, layoutElement);
    loadStyleName(resultComponent, layoutElement);
    loadResponsive(resultComponent, layoutElement);
    ComponentLoaderContext parentContext = (ComponentLoaderContext) getContext();
    setContext(innerContext);
    FrameContext frameContext = new FrameContextImpl(resultComponent, context.getParams());
    resultComponent.setContext(frameContext);
    if (dsContext != null) {
        resultComponent.setDsContext(dsContext);
        for (Datasource ds : dsContext.getAll()) {
            if (ds instanceof DatasourceImplementation) {
                ((DatasourceImplementation) ds).initialized();
            }
        }
        dsContext.setFrameContext(frameContext);
    }
    innerContext.setDsContext(dsContext);
    loadSubComponentsAndExpand(resultComponent, layoutElement);
    initWrapperFrame(resultComponent, element, parentContext.getParams(), parentContext);
    parentContext.getInjectTasks().addAll(innerContext.getInjectTasks());
    parentContext.getInitTasks().addAll(innerContext.getInitTasks());
    parentContext.getPostInitTasks().addAll(innerContext.getPostInitTasks());
    parentContext.getPostWrapTasks().addAll(innerContext.getPostWrapTasks());
    setContext(parentContext);
}
Also used : Datasource(com.haulmont.cuba.gui.data.Datasource) DsContextLoader(com.haulmont.cuba.gui.xml.data.DsContextLoader) DsContext(com.haulmont.cuba.gui.data.DsContext) Element(org.dom4j.Element) DatasourceImplementation(com.haulmont.cuba.gui.data.impl.DatasourceImplementation)

Aggregations

DsContext (com.haulmont.cuba.gui.data.DsContext)7 Element (org.dom4j.Element)5 Datasource (com.haulmont.cuba.gui.data.Datasource)3 Dom4j (com.haulmont.bali.util.Dom4j)2 MetaClass (com.haulmont.chile.core.model.MetaClass)2 MetaProperty (com.haulmont.chile.core.model.MetaProperty)2 MessageTools (com.haulmont.cuba.core.global.MessageTools)2 MetadataTools (com.haulmont.cuba.core.global.MetadataTools)2 GuiDevelopmentException (com.haulmont.cuba.gui.GuiDevelopmentException)2 com.haulmont.cuba.gui.components (com.haulmont.cuba.gui.components)2 java.util (java.util)2 StringUtils (org.apache.commons.lang.StringUtils)2 Strings (com.google.common.base.Strings)1 Iterables (com.google.common.collect.Iterables)1 Preconditions.checkNotNullArgument (com.haulmont.bali.util.Preconditions.checkNotNullArgument)1 MetaPropertyPath (com.haulmont.chile.core.model.MetaPropertyPath)1 Range (com.haulmont.chile.core.model.Range)1 ClientConfiguration (com.haulmont.cuba.client.ClientConfiguration)1 EntityRestoreService (com.haulmont.cuba.core.app.EntityRestoreService)1 DynamicAttributesUtils (com.haulmont.cuba.core.app.dynamicattributes.DynamicAttributesUtils)1