Search in sources :

Example 1 with DsContextImpl

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

the class FakeFilterSupport method createFakeFilter.

public Filter createFakeFilter() {
    if (filter != null) {
        return filter;
    }
    final Filter fakeFilter = AppBeans.get(ComponentsFactory.NAME, ComponentsFactory.class).createComponent(Filter.class);
    fakeFilter.setXmlDescriptor(Dom4j.readDocument("<filter/>").getRootElement());
    CollectionDatasourceImpl fakeDatasource = new CollectionDatasourceImpl();
    DsContextImpl fakeDsContext = new DsContextImpl(frame.getDsContext().getDataSupplier());
    FrameContextImpl fakeFrameContext = new FrameContextImpl(frame, Collections.<String, Object>emptyMap());
    fakeDsContext.setFrameContext(fakeFrameContext);
    fakeDatasource.setDsContext(fakeDsContext);
    // Attention: this query should match the logic in com.haulmont.reports.wizard.ReportingWizardBean.createJpqlDataSet()
    fakeDatasource.setQuery("select queryEntity from " + metaClass.getName() + " queryEntity");
    fakeDatasource.setMetaClass(metaClass);
    fakeFilter.setDatasource(fakeDatasource);
    fakeFilter.setFrame(this.frame);
    return fakeFilter;
}
Also used : ComponentsFactory(com.haulmont.cuba.gui.xml.layout.ComponentsFactory) Filter(com.haulmont.cuba.gui.components.Filter) FrameContextImpl(com.haulmont.cuba.gui.FrameContextImpl) CollectionDatasourceImpl(com.haulmont.cuba.gui.data.impl.CollectionDatasourceImpl) DsContextImpl(com.haulmont.cuba.gui.data.impl.DsContextImpl)

Example 2 with DsContextImpl

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

the class BulkEditorWindow method init.

@Override
public void init(Map<String, Object> params) {
    super.init(params);
    String width = themeConstants.get("cuba.gui.BulkEditorWindow.width");
    String height = themeConstants.get("cuba.gui.BulkEditorWindow.height");
    getDialogOptions().setWidth(width).setHeight(height);
    checkNotNullArgument(metaClass);
    checkNotNullArgument(selected);
    if (StringUtils.isNotBlank(exclude)) {
        excludeRegex = Pattern.compile(exclude);
    }
    for (ManagedField managedField : getManagedFields(metaClass)) {
        managedFields.put(managedField.getFqn(), managedField);
    }
    View view = createView(metaClass);
    items = loadItems(view);
    dsContext = new DsContextImpl(dataSupplier);
    dsContext.setFrameContext(getDsContext().getFrameContext());
    setDsContext(dsContext);
    datasource = new DatasourceImpl<>();
    datasource.setup(dsContext, dataSupplier, metaClass.getName() + "Ds", metaClass, view);
    ((DatasourceImpl) datasource).valid();
    dsContext.register(datasource);
    createNestedEmbeddedDatasources(datasource, metaClass, "");
    Entity instance = metadata.create(metaClass);
    if (loadDynamicAttributes && (instance instanceof BaseGenericIdEntity)) {
        ((BaseGenericIdEntity) instance).setDynamicAttributes(new HashMap<>());
    }
    createEmbeddedFields(metaClass, instance, "");
    datasource.setItem(instance);
    datasource.setAllowCommit(false);
    createDataComponents();
}
Also used : BaseGenericIdEntity(com.haulmont.cuba.core.entity.BaseGenericIdEntity) Entity(com.haulmont.cuba.core.entity.Entity) DatasourceImpl(com.haulmont.cuba.gui.data.impl.DatasourceImpl) EmbeddedDatasourceImpl(com.haulmont.cuba.gui.data.impl.EmbeddedDatasourceImpl) BaseGenericIdEntity(com.haulmont.cuba.core.entity.BaseGenericIdEntity) DsContextImpl(com.haulmont.cuba.gui.data.impl.DsContextImpl)

Aggregations

DsContextImpl (com.haulmont.cuba.gui.data.impl.DsContextImpl)2 BaseGenericIdEntity (com.haulmont.cuba.core.entity.BaseGenericIdEntity)1 Entity (com.haulmont.cuba.core.entity.Entity)1 FrameContextImpl (com.haulmont.cuba.gui.FrameContextImpl)1 Filter (com.haulmont.cuba.gui.components.Filter)1 CollectionDatasourceImpl (com.haulmont.cuba.gui.data.impl.CollectionDatasourceImpl)1 DatasourceImpl (com.haulmont.cuba.gui.data.impl.DatasourceImpl)1 EmbeddedDatasourceImpl (com.haulmont.cuba.gui.data.impl.EmbeddedDatasourceImpl)1 ComponentsFactory (com.haulmont.cuba.gui.xml.layout.ComponentsFactory)1