Search in sources :

Example 16 with ScreenData

use of com.haulmont.cuba.gui.model.ScreenData 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 17 with ScreenData

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

the class AbstractComponentLoader method loadContainer.

protected Optional<InstanceContainer> loadContainer(Element element, String property) {
    String containerId = element.attributeValue("dataContainer");
    // For instance, a component is placed within the Form component
    if (Strings.isNullOrEmpty(containerId) && property != null) {
        containerId = getParentDataContainer(element);
    }
    if (!Strings.isNullOrEmpty(containerId)) {
        if (property == null) {
            throw new GuiDevelopmentException(String.format("Can't set container '%s' for component '%s' because 'property' " + "attribute is not defined", containerId, element.attributeValue("id")), context);
        }
        FrameOwner frameOwner = getComponentContext().getFrame().getFrameOwner();
        ScreenData screenData = UiControllerUtils.getScreenData(frameOwner);
        return Optional.of(screenData.getContainer(containerId));
    }
    return Optional.empty();
}
Also used : FrameOwner(com.haulmont.cuba.gui.screen.FrameOwner) GuiDevelopmentException(com.haulmont.cuba.gui.GuiDevelopmentException) 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