Search in sources :

Example 1 with ScreenData

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

the class TwinColumnLoader method loadOptionsContainer.

protected void loadOptionsContainer(TwinColumn component, 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);
        }
        // noinspection unchecked
        component.setOptions(new ContainerOptions((CollectionContainer) container));
    }
}
Also used : ContainerOptions(com.haulmont.cuba.gui.components.data.options.ContainerOptions) 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 2 with ScreenData

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

the class WebTableFieldFactory method findOptionsContainer.

@Nullable
protected CollectionContainer findOptionsContainer(Table.Column columnConf) {
    String optDcName = columnConf.getXmlDescriptor() != null ? columnConf.getXmlDescriptor().attributeValue("optionsContainer") : null;
    if (Strings.isNullOrEmpty(optDcName)) {
        return null;
    } else {
        ScreenData screenData = UiControllerUtils.getScreenData(webTable.getFrame().getFrameOwner());
        InstanceContainer container = screenData.getContainer(optDcName);
        if (container instanceof CollectionContainer) {
            return (CollectionContainer) container;
        }
        throw new IllegalStateException(String.format("'%s' is not an instance of CollectionContainer", optDcName));
    }
}
Also used : InstanceContainer(com.haulmont.cuba.gui.model.InstanceContainer) CollectionContainer(com.haulmont.cuba.gui.model.CollectionContainer) ScreenData(com.haulmont.cuba.gui.model.ScreenData) Nullable(javax.annotation.Nullable)

Example 3 with ScreenData

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

the class DynamicAttributesPanelLoader method loadDataContainer.

protected void loadDataContainer(DynamicAttributesPanel resultComponent, Element element) {
    String containerId = element.attributeValue("dataContainer");
    if (Strings.isNullOrEmpty(containerId)) {
        throw new GuiDevelopmentException("DynamicAttributesPanel element doesn't have 'dataContainer' attribute", context, "DynamicAttributesPanel ID", element.attributeValue("id"));
    }
    FrameOwner frameOwner = getComponentContext().getFrame().getFrameOwner();
    ScreenData screenData = UiControllerUtils.getScreenData(frameOwner);
    InstanceContainer container = screenData.getContainer(containerId);
    // noinspection unchecked
    resultComponent.setInstanceContainer(container);
}
Also used : FrameOwner(com.haulmont.cuba.gui.screen.FrameOwner) GuiDevelopmentException(com.haulmont.cuba.gui.GuiDevelopmentException) InstanceContainer(com.haulmont.cuba.gui.model.InstanceContainer) ScreenData(com.haulmont.cuba.gui.model.ScreenData)

Example 4 with ScreenData

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

the class TestCommentaryPanelLoader method loadDataContainer.

@SuppressWarnings("unchecked")
private void loadDataContainer(TestCommentaryPanel resultComponent, Element element) {
    String containerId = this.element.attributeValue("dataContainer");
    if (Strings.isNullOrEmpty(containerId)) {
        throw new GuiDevelopmentException("CommentaryPanel element doesn't have 'dataContainer' attribute", context, "CommentaryPanel ID", element.attributeValue("id"));
    }
    FrameOwner frameOwner = getComponentContext().getFrame().getFrameOwner();
    ScreenData screenData = UiControllerUtils.getScreenData(frameOwner);
    InstanceContainer container = screenData.getContainer(containerId);
    if (container instanceof CollectionContainer) {
        resultComponent.setDataContainer((CollectionContainer) container);
    } else {
        throw new GuiDevelopmentException("Not a CollectionContainer: " + containerId, context);
    }
}
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 5 with ScreenData

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

the class WebDataLoadCoordinator method configureAutomatically.

@Override
public void configureAutomatically() {
    FrameOwner frameOwner = getFrameOwner();
    ScreenData screenData = UiControllerUtils.getScreenData(frameOwner);
    getUnconfiguredLoaders(screenData).forEach(loader -> configureAutomatically(loader, frameOwner));
}
Also used : FrameOwner(com.haulmont.cuba.gui.screen.FrameOwner) ScreenData(com.haulmont.cuba.gui.model.ScreenData)

Aggregations

ScreenData (com.haulmont.cuba.gui.model.ScreenData)17 InstanceContainer (com.haulmont.cuba.gui.model.InstanceContainer)9 FrameOwner (com.haulmont.cuba.gui.screen.FrameOwner)9 GuiDevelopmentException (com.haulmont.cuba.gui.GuiDevelopmentException)8 CollectionContainer (com.haulmont.cuba.gui.model.CollectionContainer)8 DevelopmentException (com.haulmont.cuba.core.global.DevelopmentException)2 ContainerOptions (com.haulmont.cuba.gui.components.data.options.ContainerOptions)2 ScreenDataXmlLoader (com.haulmont.cuba.gui.model.impl.ScreenDataXmlLoader)2 UiControllerUtils.getScreenData (com.haulmont.cuba.gui.screen.UiControllerUtils.getScreenData)2 LegacyFrame (com.haulmont.cuba.gui.screen.compatibility.LegacyFrame)2 Consumer (java.util.function.Consumer)2 Nullable (javax.annotation.Nullable)2 Element (org.dom4j.Element)2 Preconditions.checkNotNullArgument (com.haulmont.bali.util.Preconditions.checkNotNullArgument)1 MetaClass (com.haulmont.chile.core.model.MetaClass)1 MetaProperty (com.haulmont.chile.core.model.MetaProperty)1 ClientConfiguration (com.haulmont.cuba.client.ClientConfiguration)1 Entity (com.haulmont.cuba.core.entity.Entity)1 com.haulmont.cuba.core.global (com.haulmont.cuba.core.global)1 Focusable (com.haulmont.cuba.gui.components.Component.Focusable)1