Search in sources :

Example 1 with GenericDataSupplier

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

the class FragmentLoader method loadDsContext.

protected void loadDsContext(@Nullable Element dsContextElement) {
    DsContext dsContext = null;
    if (resultComponent.getFrameOwner() instanceof LegacyFrame) {
        DsContextLoader dsContextLoader;
        DsContext parentDsContext = getComponentContext().getParent().getDsContext();
        if (parentDsContext != null) {
            dsContextLoader = new DsContextLoader(parentDsContext.getDataSupplier());
        } else {
            dsContextLoader = new DsContextLoader(new GenericDataSupplier());
        }
        dsContext = dsContextLoader.loadDatasources(dsContextElement, parentDsContext, getComponentContext().getAliasesMap());
        ((ComponentLoaderContext) context).setDsContext(dsContext);
    }
    if (dsContext != null) {
        FrameOwner frameOwner = getComponentContext().getFrame().getFrameOwner();
        if (frameOwner instanceof LegacyFrame) {
            LegacyFrame frame = (LegacyFrame) frameOwner;
            frame.setDsContext(dsContext);
            for (Datasource ds : dsContext.getAll()) {
                if (ds instanceof DatasourceImplementation) {
                    ((DatasourceImplementation) ds).initialized();
                }
            }
            dsContext.setFrameContext(resultComponent.getContext());
        }
    }
}
Also used : Datasource(com.haulmont.cuba.gui.data.Datasource) DsContextLoader(com.haulmont.cuba.gui.xml.data.DsContextLoader) DsContext(com.haulmont.cuba.gui.data.DsContext) FrameOwner(com.haulmont.cuba.gui.screen.FrameOwner) LegacyFrame(com.haulmont.cuba.gui.screen.compatibility.LegacyFrame) GenericDataSupplier(com.haulmont.cuba.gui.data.impl.GenericDataSupplier) DatasourceImplementation(com.haulmont.cuba.gui.data.impl.DatasourceImplementation)

Aggregations

Datasource (com.haulmont.cuba.gui.data.Datasource)1 DsContext (com.haulmont.cuba.gui.data.DsContext)1 DatasourceImplementation (com.haulmont.cuba.gui.data.impl.DatasourceImplementation)1 GenericDataSupplier (com.haulmont.cuba.gui.data.impl.GenericDataSupplier)1 FrameOwner (com.haulmont.cuba.gui.screen.FrameOwner)1 LegacyFrame (com.haulmont.cuba.gui.screen.compatibility.LegacyFrame)1 DsContextLoader (com.haulmont.cuba.gui.xml.data.DsContextLoader)1