Search in sources :

Example 21 with WindowInfo

use of io.jmix.ui.WindowInfo in project jmix by jmix-framework.

the class RuntimePropertiesFrameLoader method createComponent.

@Override
public void createComponent() {
    String src = element.attributeValue("src");
    String screenId = element.attributeValue("id");
    if (src == null) {
        src = DEFAULT_DESCRIPTOR;
    }
    String fragmentId = screenId != null ? screenId : src;
    FragmentHelper fragmentHelper = getFragmentHelper();
    FrameHelper frameHelper = getFrameHelper();
    WindowInfo windowInfo = frameHelper.createFakeWindowInfo(src, fragmentId);
    UiComponents uiComponents = applicationContext.getBean(UiComponents.class);
    Fragment fragment = uiComponents.create(Fragment.NAME);
    ScreenFragment controller = fragmentHelper.createController(windowInfo, fragment);
    // setup screen and controller
    ComponentLoaderContext parentContext = (ComponentLoaderContext) getContext();
    FrameOwner hostController = parentContext.getFrame().getFrameOwner();
    // setup screen and controller
    setHostController(controller, hostController);
    setWindowId(controller, windowInfo.getId());
    setFrame(controller, fragment);
    setScreenContext(controller, new ScreenContextImpl(windowInfo, parentContext.getOptions(), getScreenContext(hostController)));
    setScreenData(controller, applicationContext.getBean(ScreenData.class));
    FragmentImplementation fragmentImpl = (FragmentImplementation) fragment;
    fragmentImpl.setFrameOwner(controller);
    fragmentImpl.setId(fragmentId);
    FragmentContextImpl frameContext = new FragmentContextImpl(fragment, innerContext);
    ((FrameImplementation) fragment).setContext(frameContext);
    if (windowInfo.getTemplate() != null) {
        String frameId = fragmentId;
        if (parentContext.getFullFrameId() != null) {
            frameId = parentContext.getFullFrameId() + "." + frameId;
        }
        innerContext = new ComponentLoaderContext(getContext().getOptions());
        innerContext.setMessageGroup(fragmentHelper.getMessageGroup(windowInfo.getTemplate()));
        innerContext.setCurrentFrameId(fragmentId);
        innerContext.setFullFrameId(frameId);
        innerContext.setFrame(fragment);
        innerContext.setParent(parentContext);
        LayoutLoader layoutLoader = getLayoutLoader(innerContext);
        ScreenXmlLoader screenXmlLoader = applicationContext.getBean(ScreenXmlLoader.class);
        Element rootElement = screenXmlLoader.load(windowInfo.getTemplate(), windowInfo.getId(), getContext().getParams());
        String messagesPack = rootElement.attributeValue("messagesPack");
        if (messagesPack != null) {
            innerContext.setMessageGroup(messagesPack);
        }
        this.fragmentLoader = layoutLoader.createFragmentContent(fragment, rootElement);
    }
    this.resultComponent = fragment;
}
Also used : LayoutLoader(io.jmix.ui.xml.layout.loader.LayoutLoader) FrameHelper(com.haulmont.cuba.gui.sys.FrameHelper) UiComponents(com.haulmont.cuba.gui.UiComponents) FragmentImplementation(io.jmix.ui.component.impl.FragmentImplementation) Element(org.dom4j.Element) FragmentContextImpl(io.jmix.ui.sys.FragmentContextImpl) FrameImplementation(io.jmix.ui.component.impl.FrameImplementation) ScreenFragment(io.jmix.ui.screen.ScreenFragment) Fragment(io.jmix.ui.component.Fragment) WindowInfo(io.jmix.ui.WindowInfo) ScreenFragment(io.jmix.ui.screen.ScreenFragment) FrameOwner(io.jmix.ui.screen.FrameOwner) FragmentHelper(io.jmix.ui.sys.FragmentHelper) ScreenContextImpl(io.jmix.ui.sys.ScreenContextImpl) ScreenXmlLoader(io.jmix.ui.sys.ScreenXmlLoader) ScreenData(io.jmix.ui.model.ScreenData)

Example 22 with WindowInfo

use of io.jmix.ui.WindowInfo in project jmix by jmix-framework.

the class WidgetRepositoryImpl method initializeWidgets.

protected void initializeWidgets() {
    widgetTypeInfos = new ArrayList<>();
    for (WindowInfo windowInfo : windowConfig.getWindows()) {
        if (StringUtils.isNotBlank(windowInfo.getTemplate())) {
            Class clazz = windowInfo.getControllerClass();
            if (clazz.isAnnotationPresent(DashboardWidget.class)) {
                DashboardWidget widgetAnnotation = (DashboardWidget) clazz.getAnnotation(DashboardWidget.class);
                String editFragmentId = widgetAnnotation.editFragmentId();
                if (StringUtils.isNotBlank(editFragmentId) && !windowConfig.hasWindow(editFragmentId)) {
                    log.error("Unable to find {} edit screen in screen config for widget {}", editFragmentId, widgetAnnotation.name());
                    throw new IllegalArgumentException(String.format("Unable to find %s edit screen in screen config for widget %s", editFragmentId, widgetAnnotation.name()));
                }
                widgetTypeInfos.add(new WidgetTypeInfo(widgetAnnotation.name(), windowInfo.getId(), editFragmentId));
            }
        }
    }
}
Also used : DashboardWidget(io.jmix.dashboardsui.annotation.DashboardWidget) WidgetTypeInfo(io.jmix.dashboardsui.repository.WidgetTypeInfo) WindowInfo(io.jmix.ui.WindowInfo)

Example 23 with WindowInfo

use of io.jmix.ui.WindowInfo in project jmix by jmix-framework.

the class EditorBuilderProcessor method getOptionsForScreen.

@Override
protected <E> ScreenOptions getOptionsForScreen(String editorScreenId, E entity, EditorBuilder<E> builder) {
    ScreenOptions options = super.getOptionsForScreen(editorScreenId, entity, builder);
    WindowInfo windowInfo = windowConfig.getWindowInfo(editorScreenId);
    if (LegacyFrame.class.isAssignableFrom(windowInfo.getControllerClass()) && options == FrameOwner.NO_OPTIONS) {
        HashMap<String, Object> paramsMap = new HashMap<>();
        paramsMap.put(WindowParams.ITEM.name(), entity);
        options = new MapScreenOptions(paramsMap);
    }
    return options;
}
Also used : HashMap(java.util.HashMap) LegacyFrame(com.haulmont.cuba.gui.screen.compatibility.LegacyFrame) MapScreenOptions(io.jmix.ui.screen.MapScreenOptions) ScreenOptions(io.jmix.ui.screen.ScreenOptions) MapScreenOptions(io.jmix.ui.screen.MapScreenOptions) WindowInfo(io.jmix.ui.WindowInfo)

Example 24 with WindowInfo

use of io.jmix.ui.WindowInfo in project jmix by jmix-framework.

the class BackgroundWorkWindow method show.

/**
 * Show modal window with message which will last until task completes.
 * Optionally cancel button can be displayed. By pressing cancel button user can cancel task execution.
 *
 * @param task          background task containing long operation
 * @param title         window title, optional
 * @param message       window message, optional
 * @param cancelAllowed show or not cancel button
 * @param <T>           task progress unit
 * @param <V>           task result type
 */
public static <T, V> void show(BackgroundTask<T, V> task, @Nullable String title, @Nullable String message, boolean cancelAllowed) {
    if (task.getOwnerScreen() == null) {
        throw new IllegalArgumentException("Task without owner cannot be run");
    }
    Map<String, Object> params = new HashMap<>();
    params.put("task", task);
    params.put("title", title);
    params.put("message", message);
    params.put("cancelAllowed", cancelAllowed);
    Screens screens = UiControllerUtils.getScreenContext(task.getOwnerScreen()).getScreens();
    WindowInfo windowInfo = AppBeans.get(WindowConfig.class).getWindowInfo("backgroundWorkWindow");
    ((WindowManager) screens).openWindow(windowInfo, OpenType.DIALOG, params);
}
Also used : WindowConfig(io.jmix.ui.WindowConfig) HashMap(java.util.HashMap) Screens(io.jmix.ui.Screens) WindowInfo(io.jmix.ui.WindowInfo) WindowManager(com.haulmont.cuba.gui.WindowManager)

Aggregations

WindowInfo (io.jmix.ui.WindowInfo)24 WindowManager (com.haulmont.cuba.gui.WindowManager)7 WindowConfig (io.jmix.ui.WindowConfig)7 HashMap (java.util.HashMap)6 Element (org.dom4j.Element)5 OpenType (com.haulmont.cuba.gui.WindowManager.OpenType)3 Window (io.jmix.ui.component.Window)3 AppBeans (com.haulmont.cuba.core.global.AppBeans)2 WindowManagerProvider (com.haulmont.cuba.gui.WindowManagerProvider)2 Filter (com.haulmont.cuba.gui.components.Filter)2 Window (com.haulmont.cuba.gui.components.Window)2 AddConditionWindow (com.haulmont.cuba.gui.components.filter.addcondition.AddConditionWindow)2 ConditionDescriptorsTreeBuilderAPI (com.haulmont.cuba.gui.components.filter.addcondition.ConditionDescriptorsTreeBuilderAPI)2 AbstractConditionDescriptor (com.haulmont.cuba.gui.components.filter.descriptor.AbstractConditionDescriptor)2 LegacyFrame (com.haulmont.cuba.gui.screen.compatibility.LegacyFrame)2 Screens (io.jmix.ui.Screens)2 NotFoundScreen (io.jmix.ui.app.navigation.notfoundwindow.NotFoundScreen)2 Fragment (io.jmix.ui.component.Fragment)2 FragmentImplementation (io.jmix.ui.component.impl.FragmentImplementation)2 FrameImplementation (io.jmix.ui.component.impl.FrameImplementation)2