Search in sources :

Example 1 with Frame

use of io.jmix.ui.component.Frame in project jmix by jmix-framework.

the class FilteringLookupAction method getFilterComponentPath.

public static String getFilterComponentPath(Filter filter) {
    StringBuilder sb = new StringBuilder(filter.getId() != null ? filter.getId() : "filterWithoutId");
    Frame frame = filter.getFrame();
    while (frame != null) {
        sb.insert(0, ".");
        String s = frame.getId() != null ? frame.getId() : "frameWithoutId";
        if (s.contains(".")) {
            s = "[" + s + "]";
        }
        sb.insert(0, s);
        if (frame instanceof Window) {
            break;
        }
        frame = frame.getFrame();
    }
    return sb.toString();
}
Also used : AbstractWindow(com.haulmont.cuba.gui.components.AbstractWindow) Window(io.jmix.ui.component.Window) Frame(io.jmix.ui.component.Frame)

Example 2 with Frame

use of io.jmix.ui.component.Frame in project jmix by jmix-framework.

the class DsContextImpl method get.

@Override
public Datasource get(String id) {
    checkNotNullArgument(id, "Null datasource ID");
    id = aliasesMap.getOrDefault(id, id);
    Datasource ds = null;
    if (!id.contains(".")) {
        ds = datasourceMap.get(id);
        if (ds == null && parent != null) {
            ds = parent.get(id);
        }
    } else {
        if (windowContext != null) {
            String nestedFramePath = id.substring(0, id.indexOf("."));
            Component nestedFrame = getFrameContext().getFrame().getComponent(nestedFramePath);
            if (nestedFrame instanceof Frame) {
                String nestedDsId = id.substring(id.indexOf(".") + 1);
                FrameOwner frameOwner = ((Frame) nestedFrame).getFrameOwner();
                if (frameOwner instanceof LegacyFrame) {
                    ds = ((LegacyFrame) frameOwner).getDsContext().get(nestedDsId);
                }
            }
        }
    }
    return ds;
}
Also used : Frame(io.jmix.ui.component.Frame) LegacyFrame(com.haulmont.cuba.gui.screen.compatibility.LegacyFrame) FrameOwner(io.jmix.ui.screen.FrameOwner) LegacyFrame(com.haulmont.cuba.gui.screen.compatibility.LegacyFrame) Component(io.jmix.ui.component.Component)

Example 3 with Frame

use of io.jmix.ui.component.Frame in project jmix by jmix-framework.

the class HasWindowManager method openFrame.

/**
 * Load a frame registered in {@code screens.xml} and optionally show it inside a parent component of this
 * frame. <br> It is recommended to use {@link Fragments} bean instead.
 *
 * @param parent      if specified, all parent's sub components will be removed and the frame will be added
 * @param windowAlias frame ID as defined in {@code screens.xml}
 * @param params      parameters to be passed into the frame's controller {@code init} method
 * @return frame's controller instance
 */
@Deprecated
default Frame openFrame(@Nullable Component parent, String windowAlias, Map<String, Object> params) {
    WindowConfig windowConfig = AppBeans.get(WindowConfig.class);
    WindowInfo windowInfo = windowConfig.getWindowInfo(windowAlias);
    Frame parentFrame;
    if (this instanceof LegacyFrame) {
        parentFrame = ((LegacyFrame) this).getWrappedFrame();
    } else {
        parentFrame = ((Frame) this);
    }
    return getWindowManager().openFrame(parentFrame, parent, windowInfo, params);
}
Also used : Frame(io.jmix.ui.component.Frame) LegacyFrame(com.haulmont.cuba.gui.screen.compatibility.LegacyFrame) LegacyFrame(com.haulmont.cuba.gui.screen.compatibility.LegacyFrame)

Example 4 with Frame

use of io.jmix.ui.component.Frame in project jmix by jmix-framework.

the class DateIntervalAction method actionPerform.

@Override
public void actionPerform(Component component) {
    super.actionPerform(component);
    if (component instanceof Component.BelongToFrame) {
        Frame frame = ((Component.BelongToFrame) component).getFrame();
        if (frame == null) {
            throw new IllegalStateException("Component is not attached to the frame");
        }
        screenBuilders.screen(frame.getFrameOwner()).withScreenClass(DateIntervalDialog.class).withOpenMode(OpenMode.DIALOG).withAfterCloseListener(this::onDateIntervalDialogCloseEvent).build().withValue(valuePicker.getValue()).withMetaPropertyPath(metaPropertyPath).show();
    }
}
Also used : Frame(io.jmix.ui.component.Frame)

Example 5 with Frame

use of io.jmix.ui.component.Frame in project jmix by jmix-framework.

the class FragmentsImpl method createFragment.

protected <T extends ScreenFragment> T createFragment(FrameOwner parent, WindowInfo windowInfo, ScreenOptions options) {
    if (windowInfo.getType() != WindowInfo.Type.FRAGMENT) {
        throw new IllegalArgumentException(String.format("Unable to create fragment %s it is a screen: %s", windowInfo.getId(), windowInfo.getControllerClass()));
    }
    Timer.Sample createSample = Timer.start(meterRegistry);
    Fragment fragment = createFragmentInternal();
    ScreenFragment controller = fragmentHelper.createController(windowInfo, fragment);
    // setup screen and controller
    setHostController(controller, parent);
    setWindowId(controller, windowInfo.getId());
    setFrame(controller, fragment);
    setScreenContext(controller, new ScreenContextImpl(windowInfo, options, getScreenContext(parent)));
    setScreenData(controller, applicationContext.getBean(ScreenData.class));
    FragmentImplementation fragmentImpl = (FragmentImplementation) fragment;
    fragmentImpl.setFrameOwner(controller);
    fragmentImpl.setId(controller.getId());
    createSample.stop(createScreenTimer(meterRegistry, ScreenLifeCycle.CREATE, windowInfo.getId()));
    Timer.Sample loadSample = Timer.start(meterRegistry);
    Frame parentFrame = getFrame(parent);
    // fake parent loader context
    ComponentLoaderContext loaderContext = createComponentLoaderContext(options);
    FragmentContextImpl frameContext = new FragmentContextImpl(fragment, loaderContext);
    frameContext.setManualInitRequired(true);
    ((FrameImplementation) fragment).setContext(frameContext);
    loaderContext.setCurrentFrameId(windowInfo.getId());
    loaderContext.setFullFrameId(windowInfo.getId());
    loaderContext.setFrame(fragment);
    loaderContext.setParent(null);
    loaderContext.setScreenData(UiControllerUtils.getScreenData(parent));
    // load XML if needed
    if (windowInfo.getTemplate() != null) {
        ComponentLoaderContext innerContext = createComponentLoaderContext(options);
        innerContext.setCurrentFrameId(windowInfo.getId());
        innerContext.setFullFrameId(windowInfo.getId());
        innerContext.setFrame(fragment);
        innerContext.setParent(loaderContext);
        LayoutLoader layoutLoader = applicationContext.getBean(LayoutLoader.class, innerContext);
        Element rootElement = screenXmlLoader.load(windowInfo.getTemplate(), windowInfo.getId(), emptyMap());
        innerContext.setMessageGroup(fragmentHelper.findMessageGroup(rootElement, windowInfo.getTemplate()));
        loadAdditionalData(rootElement, innerContext);
        ComponentLoader<Fragment> fragmentLoader = layoutLoader.createFragmentContent(fragment, rootElement);
        fragmentLoader.loadComponent();
        loaderContext.getInjectTasks().addAll(innerContext.getInjectTasks());
        loaderContext.getInitTasks().addAll(innerContext.getInitTasks());
        loaderContext.getPostInitTasks().addAll(innerContext.getPostInitTasks());
    }
    loaderContext.addInjectTask(new FragmentLoaderInjectTask(fragment, options, applicationContext));
    loaderContext.addInitTask(new FragmentLoaderInitTask(fragment, options, loaderContext, applicationContext));
    loadSample.stop(createScreenTimer(meterRegistry, ScreenLifeCycle.LOAD, windowInfo.getId()));
    loaderContext.executeInjectTasks();
    fragmentImpl.setFrame(parentFrame);
    // noinspection unchecked
    return (T) controller;
}
Also used : LayoutLoader(io.jmix.ui.xml.layout.loader.LayoutLoader) Frame(io.jmix.ui.component.Frame) FragmentImplementation(io.jmix.ui.component.impl.FragmentImplementation) Element(org.dom4j.Element) FragmentLoaderInjectTask(io.jmix.ui.sys.FragmentHelper.FragmentLoaderInjectTask) FrameImplementation(io.jmix.ui.component.impl.FrameImplementation) Fragment(io.jmix.ui.component.Fragment) ComponentLoaderContext(io.jmix.ui.xml.layout.loader.ComponentLoaderContext) Timer(io.micrometer.core.instrument.Timer) UiMonitoring.createScreenTimer(io.jmix.ui.monitoring.UiMonitoring.createScreenTimer) FragmentLoaderInitTask(io.jmix.ui.sys.FragmentHelper.FragmentLoaderInitTask) ScreenData(io.jmix.ui.model.ScreenData)

Aggregations

Frame (io.jmix.ui.component.Frame)24 LegacyFrame (com.haulmont.cuba.gui.screen.compatibility.LegacyFrame)6 Component (io.jmix.ui.component.Component)5 FrameOwner (io.jmix.ui.screen.FrameOwner)4 Screen (io.jmix.ui.screen.Screen)4 MetaClass (io.jmix.core.metamodel.model.MetaClass)3 GuiDevelopmentException (io.jmix.ui.GuiDevelopmentException)3 Window (io.jmix.ui.component.Window)3 CollectionDatasource (com.haulmont.cuba.gui.data.CollectionDatasource)2 MetaProperty (io.jmix.core.metamodel.model.MetaProperty)2 ContainerDataUnit (io.jmix.ui.component.data.meta.ContainerDataUnit)2 EntityDataUnit (io.jmix.ui.component.data.meta.EntityDataUnit)2 CollectionContainer (io.jmix.ui.model.CollectionContainer)2 ScreenSettingsFacet (io.jmix.ui.settings.facet.ScreenSettingsFacet)2 Nullable (javax.annotation.Nullable)2 Strings (com.google.common.base.Strings)1 Iterables (com.google.common.collect.Iterables)1 Security (com.haulmont.cuba.core.global.Security)1 UiComponents (com.haulmont.cuba.gui.UiComponents)1 AbstractWindow (com.haulmont.cuba.gui.components.AbstractWindow)1