Search in sources :

Example 51 with FrameOwner

use of io.jmix.ui.screen.FrameOwner in project jmix by jmix-framework.

the class ScreensHelper method isEntityAvailable.

protected boolean isEntityAvailable(Element window, Class<? extends FrameOwner> controllerClass, Class entityClass, ScreenType filterScreenType, boolean useComplexSearch) {
    Element dsContext = window.element("dsContext");
    Element data = window.element("data");
    if (dsContext == null && data == null) {
        return false;
    }
    Element dataElement = data != null ? data : dsContext;
    if (!useComplexSearch) {
        String dataElementId = data != null ? getDataContainerId(window, controllerClass, filterScreenType) : getDatasourceId(window, filterScreenType);
        if (StringUtils.isEmpty(dataElementId)) {
            return false;
        }
        return isEntityAvailableInDataElement(entityClass, dataElement, dataElementId);
    }
    if (!checkWindowType(controllerClass, filterScreenType)) {
        return false;
    }
    List<Element> dataElements = dataElement.elements();
    List<String> dataElementIds = dataElements.stream().filter(de -> isEntityAvailableInDataElement(entityClass, de)).map(de -> de.attributeValue("id")).collect(Collectors.toList());
    if (!ScreenType.BROWSER.equals(filterScreenType)) {
        String editedEntityDataElementId = data != null ? resolveEditedEntityContainerId(controllerClass) : window.attributeValue("datasource");
        dataElementIds.addAll(getDataElementsIdForComposition(dataElement, entityClass, editedEntityDataElementId));
    }
    return dataElementIds.size() > 0;
}
Also used : MetaClass(io.jmix.core.metamodel.model.MetaClass) Fragment(io.jmix.ui.component.Fragment) Document(org.dom4j.Document) java.util(java.util) UiShowScreenContext(io.jmix.ui.accesscontext.UiShowScreenContext) FrameOwner(io.jmix.ui.screen.FrameOwner) LoggerFactory(org.slf4j.LoggerFactory) Autowired(org.springframework.beans.factory.annotation.Autowired) io.jmix.core(io.jmix.core) StringUtils(org.apache.commons.lang3.StringUtils) WindowConfig(io.jmix.ui.WindowConfig) Strings(com.google.common.base.Strings) EditedEntityContainer(io.jmix.ui.screen.EditedEntityContainer) LookupComponent(io.jmix.ui.screen.LookupComponent) Dom4jTools(io.jmix.core.common.xmlparsing.Dom4jTools) LayoutLoaderConfig(io.jmix.ui.xml.layout.LayoutLoaderConfig) Nullable(javax.annotation.Nullable) CurrentAuthentication(io.jmix.core.security.CurrentAuthentication) Collections.emptyMap(java.util.Collections.emptyMap) Logger(org.slf4j.Logger) ImmutableMap(com.google.common.collect.ImmutableMap) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) ApplicationContext(org.springframework.context.ApplicationContext) Collectors(java.util.stream.Collectors) FileNotFoundException(java.io.FileNotFoundException) Component(org.springframework.stereotype.Component) WindowInfo(io.jmix.ui.WindowInfo) Element(org.dom4j.Element) ReflectionHelper(io.jmix.core.common.util.ReflectionHelper) MetaProperty(io.jmix.core.metamodel.model.MetaProperty) Element(org.dom4j.Element)

Aggregations

FrameOwner (io.jmix.ui.screen.FrameOwner)51 ScreenData (io.jmix.ui.model.ScreenData)18 GuiDevelopmentException (io.jmix.ui.GuiDevelopmentException)17 InstanceContainer (io.jmix.ui.model.InstanceContainer)11 CollectionContainer (io.jmix.ui.model.CollectionContainer)9 Component (io.jmix.ui.component.Component)7 Method (java.lang.reflect.Method)6 LegacyFragmentAdapter (com.haulmont.cuba.gui.components.compatibility.LegacyFragmentAdapter)5 MetaClass (io.jmix.core.metamodel.model.MetaClass)5 Screens (io.jmix.ui.Screens)5 Screen (io.jmix.ui.screen.Screen)5 ScreenFragment (io.jmix.ui.screen.ScreenFragment)5 WindowInfo (io.jmix.ui.WindowInfo)4 Frame (io.jmix.ui.component.Frame)4 Element (org.dom4j.Element)4 Fragment (io.jmix.ui.component.Fragment)3 DataUnit (io.jmix.ui.component.data.DataUnit)3 DataLoader (io.jmix.ui.model.DataLoader)3 LegacyFrame (com.haulmont.cuba.gui.screen.compatibility.LegacyFrame)2 Notifications (io.jmix.ui.Notifications)2