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;
}
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);
}
Aggregations