Search in sources :

Example 26 with FrameOwner

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

the class AbstractSingleFilterComponentLoader method loadDataLoader.

protected void loadDataLoader(C resultComponent, Element element) {
    String dataLoaderId = element.attributeValue("dataLoader");
    if (StringUtils.isNotBlank(dataLoaderId)) {
        FrameOwner frameOwner = getComponentContext().getFrame().getFrameOwner();
        ScreenData screenData = UiControllerUtils.getScreenData(frameOwner);
        DataLoader dataLoader = screenData.getLoader(dataLoaderId);
        resultComponent.setDataLoader(dataLoader);
    }
}
Also used : DataLoader(io.jmix.ui.model.DataLoader) FrameOwner(io.jmix.ui.screen.FrameOwner) ScreenData(io.jmix.ui.model.ScreenData)

Example 27 with FrameOwner

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

the class AbstractTableLoader method initTableDataHolder.

protected TableDataHolder initTableDataHolder() {
    TableDataHolder holder = new TableDataHolder();
    String containerId = element.attributeValue("dataContainer");
    if (Strings.isNullOrEmpty(containerId)) {
        loadMetaClass(element, holder::setMetaClass);
        return holder;
    }
    FrameOwner frameOwner = getComponentContext().getFrame().getFrameOwner();
    ScreenData screenData = UiControllerUtils.getScreenData(frameOwner);
    InstanceContainer container = screenData.getContainer(containerId);
    CollectionContainer collectionContainer;
    if (container instanceof CollectionContainer) {
        collectionContainer = ((CollectionContainer) container);
    } else {
        throw new GuiDevelopmentException("Not a CollectionContainer: " + containerId, context);
    }
    if (container instanceof CollectionPropertyContainer) {
        initMasterDataLoaderListener((CollectionPropertyContainer) container);
    }
    if (collectionContainer instanceof HasLoader) {
        holder.setDataLoader(((HasLoader) collectionContainer).getLoader());
    }
    holder.setMetaClass(collectionContainer.getEntityMetaClass());
    holder.setContainer(collectionContainer);
    holder.setFetchPlan(collectionContainer.getFetchPlan());
    return holder;
}
Also used : FrameOwner(io.jmix.ui.screen.FrameOwner) GuiDevelopmentException(io.jmix.ui.GuiDevelopmentException)

Example 28 with FrameOwner

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

the class UiControllerPropertyInjector method findComponent.

@Nullable
protected Component findComponent(String componentId) {
    Component component = null;
    Window window = null;
    if (sourceScreen != null) {
        window = sourceScreen.getWindow();
    } else if (frameOwner instanceof ScreenFragment) {
        FrameOwner host = ((ScreenFragment) frameOwner).getHostController();
        if (host instanceof Screen) {
            window = ((Screen) host).getWindow();
        }
    } else if (frameOwner instanceof Screen) {
        window = ((Screen) frameOwner).getWindow();
    }
    if (window != null) {
        component = window.getComponent(componentId);
    }
    return component;
}
Also used : Window(io.jmix.ui.component.Window) ScreenFragment(io.jmix.ui.screen.ScreenFragment) FrameOwner(io.jmix.ui.screen.FrameOwner) Screen(io.jmix.ui.screen.Screen) Component(io.jmix.ui.component.Component) Nullable(javax.annotation.Nullable)

Example 29 with FrameOwner

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

the class TestCommentaryPanelLoader method loadDataContainer.

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(io.jmix.ui.screen.FrameOwner) GuiDevelopmentException(io.jmix.ui.GuiDevelopmentException) InstanceContainer(io.jmix.ui.model.InstanceContainer) CollectionContainer(io.jmix.ui.model.CollectionContainer) ScreenData(io.jmix.ui.model.ScreenData)

Example 30 with FrameOwner

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

the class FilterLoader method loadDataLoader.

protected void loadDataLoader(Filter component, Element element) {
    loadString(element, "dataLoader", (dataLoaderId) -> {
        FrameOwner frameOwner = getComponentContext().getFrame().getFrameOwner();
        ScreenData screenData = UiControllerUtils.getScreenData(frameOwner);
        DataLoader dataLoader = screenData.getLoader(dataLoaderId);
        component.setDataLoader(dataLoader);
    });
}
Also used : DataLoader(io.jmix.ui.model.DataLoader) FrameOwner(io.jmix.ui.screen.FrameOwner) ScreenData(io.jmix.ui.model.ScreenData)

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