Search in sources :

Example 11 with CollectionContainer

use of com.haulmont.cuba.gui.model.CollectionContainer in project cuba by cuba-platform.

the class CalendarLoader method loadDataContainer.

@SuppressWarnings("unchecked")
protected void loadDataContainer(Calendar component, Element element) {
    String containerId = element.attributeValue("dataContainer");
    FrameOwner frameOwner = getComponentContext().getFrame().getFrameOwner();
    ScreenData screenData = UiControllerUtils.getScreenData(frameOwner);
    InstanceContainer container = screenData.getContainer(containerId);
    if (!(container instanceof CollectionContainer)) {
        throw new GuiDevelopmentException("Not a CollectionContainer: " + containerId, context);
    }
    component.setEventProvider(new ContainerCalendarEventProvider<>(((CollectionContainer) container)));
}
Also used : FrameOwner(com.haulmont.cuba.gui.screen.FrameOwner) GuiDevelopmentException(com.haulmont.cuba.gui.GuiDevelopmentException) InstanceContainer(com.haulmont.cuba.gui.model.InstanceContainer) CollectionContainer(com.haulmont.cuba.gui.model.CollectionContainer) ScreenData(com.haulmont.cuba.gui.model.ScreenData)

Example 12 with CollectionContainer

use of com.haulmont.cuba.gui.model.CollectionContainer in project cuba by cuba-platform.

the class AbstractComponentLoader method loadOptionsContainer.

protected Optional<CollectionContainer> loadOptionsContainer(Element element) {
    String containerId = element.attributeValue("optionsContainer");
    if (containerId != null) {
        FrameOwner frameOwner = getComponentContext().getFrame().getFrameOwner();
        ScreenData screenData = UiControllerUtils.getScreenData(frameOwner);
        InstanceContainer container = screenData.getContainer(containerId);
        if (!(container instanceof CollectionContainer)) {
            throw new GuiDevelopmentException("Not a CollectionContainer: " + containerId, context);
        }
        return Optional.of((CollectionContainer) container);
    }
    return Optional.empty();
}
Also used : FrameOwner(com.haulmont.cuba.gui.screen.FrameOwner) GuiDevelopmentException(com.haulmont.cuba.gui.GuiDevelopmentException) InstanceContainer(com.haulmont.cuba.gui.model.InstanceContainer) CollectionContainer(com.haulmont.cuba.gui.model.CollectionContainer) ScreenData(com.haulmont.cuba.gui.model.ScreenData)

Example 13 with CollectionContainer

use of com.haulmont.cuba.gui.model.CollectionContainer in project cuba by cuba-platform.

the class WebTableFieldFactory method getOptions.

@SuppressWarnings("unchecked")
@Nullable
@Override
protected Options getOptions(EntityValueSource valueSource, String property) {
    MetaClass metaClass = valueSource.getEntityMetaClass();
    MetaPropertyPath metaPropertyPath = metadataTools.resolveMetaPropertyPath(metaClass, property);
    Table.Column columnConf = webTable.getColumnsInternal().get(metaPropertyPath);
    CollectionContainer collectionContainer = findOptionsContainer(columnConf);
    if (collectionContainer != null) {
        return new ContainerOptions(collectionContainer);
    }
    CollectionDatasource ds = findOptionsDatasource(columnConf, property);
    if (ds != null) {
        return new DatasourceOptions(ds);
    }
    return null;
}
Also used : ContainerOptions(com.haulmont.cuba.gui.components.data.options.ContainerOptions) Table(com.haulmont.cuba.gui.components.Table) WebAbstractTable(com.haulmont.cuba.web.gui.components.WebAbstractTable) MetaClass(com.haulmont.chile.core.model.MetaClass) CollectionDatasource(com.haulmont.cuba.gui.data.CollectionDatasource) MetaPropertyPath(com.haulmont.chile.core.model.MetaPropertyPath) CollectionContainer(com.haulmont.cuba.gui.model.CollectionContainer) DatasourceOptions(com.haulmont.cuba.gui.components.data.options.DatasourceOptions) Nullable(javax.annotation.Nullable)

Aggregations

CollectionContainer (com.haulmont.cuba.gui.model.CollectionContainer)13 InstanceContainer (com.haulmont.cuba.gui.model.InstanceContainer)8 ScreenData (com.haulmont.cuba.gui.model.ScreenData)8 GuiDevelopmentException (com.haulmont.cuba.gui.GuiDevelopmentException)6 FrameOwner (com.haulmont.cuba.gui.screen.FrameOwner)6 ContainerOptions (com.haulmont.cuba.gui.components.data.options.ContainerOptions)5 MetaClass (com.haulmont.chile.core.model.MetaClass)4 MetaProperty (com.haulmont.chile.core.model.MetaProperty)3 ContainerDataUnit (com.haulmont.cuba.gui.components.data.meta.ContainerDataUnit)3 Nullable (javax.annotation.Nullable)3 Entity (com.haulmont.cuba.core.entity.Entity)2 com.haulmont.cuba.core.global (com.haulmont.cuba.core.global)2 Table (com.haulmont.cuba.gui.components.Table)2 Element (org.dom4j.Element)2 Strings (com.google.common.base.Strings)1 ImmutableList (com.google.common.collect.ImmutableList)1 EventHub (com.haulmont.bali.events.EventHub)1 Subscription (com.haulmont.bali.events.Subscription)1 ParamsMap (com.haulmont.bali.util.ParamsMap)1 Preconditions.checkNotNullArgument (com.haulmont.bali.util.Preconditions.checkNotNullArgument)1