Search in sources :

Example 66 with WindowInfo

use of com.haulmont.cuba.gui.config.WindowInfo in project cuba by cuba-platform.

the class HasWindowManager method openLookup.

/**
 * Open a lookup screen. <br> It is recommended to use {@link ScreenBuilders} bean instead.
 *
 * @param windowAlias screen ID as defined in {@code screens.xml}
 * @param handler     is invoked when selection confirmed and the lookup screen closes
 * @param openType    how to open the screen
 * @param params      parameters to pass to {@code init()} method of the screen's controller
 * @return created window
 */
@Deprecated
default AbstractLookup openLookup(String windowAlias, Window.Lookup.Handler handler, WindowManager.OpenType openType, Map<String, Object> params) {
    WindowConfig windowConfig = AppBeans.get(WindowConfig.NAME);
    WindowInfo windowInfo = windowConfig.getWindowInfo(windowAlias);
    return (AbstractLookup) getWindowManager().openLookup(windowInfo, handler, openType, params);
}
Also used : WindowConfig(com.haulmont.cuba.gui.config.WindowConfig) WindowInfo(com.haulmont.cuba.gui.config.WindowInfo)

Example 67 with WindowInfo

use of com.haulmont.cuba.gui.config.WindowInfo in project cuba by cuba-platform.

the class HasWindowManager method openEditor.

/**
 * Open an edit screen for entity instance. <br> It is recommended to use {@link ScreenBuilders} bean instead.
 *
 * @param item        entity to edit
 * @param openType    how to open the screen
 * @param params      parameters to pass to {@code init()} method of the screen's controller
 * @param parentDs    if this parameter is not null, the editor will commit edited instance into this
 *                    datasource instead of directly to database
 * @return created window
 */
@Deprecated
default AbstractEditor openEditor(Entity item, WindowManager.OpenType openType, Map<String, Object> params, Datasource parentDs) {
    WindowConfig windowConfig = AppBeans.get(WindowConfig.NAME);
    WindowInfo editorScreen = windowConfig.getEditorScreen(item);
    return (AbstractEditor) getWindowManager().openEditor(editorScreen, item, openType, params, parentDs);
}
Also used : WindowConfig(com.haulmont.cuba.gui.config.WindowConfig) WindowInfo(com.haulmont.cuba.gui.config.WindowInfo)

Example 68 with WindowInfo

use of com.haulmont.cuba.gui.config.WindowInfo in project cuba by cuba-platform.

the class HasWindowManager method openEditor.

/**
 * Open an edit screen. <br> It is recommended to use {@link ScreenBuilders} bean instead.
 *
 * @param windowAlias screen ID as defined in {@code screens.xml}
 * @param item        entity to edit
 * @param openType    how to open the screen
 * @param parentDs    if this parameter is not null, the editor will commit edited instance into this
 *                    datasource instead of directly to database
 * @return created window
 */
@Deprecated
default AbstractEditor openEditor(String windowAlias, Entity item, WindowManager.OpenType openType, Datasource parentDs) {
    WindowConfig windowConfig = AppBeans.get(WindowConfig.NAME);
    WindowInfo windowInfo = windowConfig.getWindowInfo(windowAlias);
    return (AbstractEditor) getWindowManager().openEditor(windowInfo, item, openType, parentDs);
}
Also used : WindowConfig(com.haulmont.cuba.gui.config.WindowConfig) WindowInfo(com.haulmont.cuba.gui.config.WindowInfo)

Example 69 with WindowInfo

use of com.haulmont.cuba.gui.config.WindowInfo in project cuba by cuba-platform.

the class HasWindowManager method openEditor.

/**
 * Open an edit screen. <br> It is recommended to use {@link ScreenBuilders} bean instead.
 *
 * @param windowAlias screen ID as defined in {@code screens.xml}
 * @param item        entity to edit
 * @param openType    how to open the screen
 * @param params      parameters to pass to {@code init()} method of the screen's controller
 * @param parentDs    if this parameter is not null, the editor will commit edited instance into this
 *                    datasource instead of directly to database
 * @return created window
 */
@Deprecated
default AbstractEditor openEditor(String windowAlias, Entity item, WindowManager.OpenType openType, Map<String, Object> params, Datasource parentDs) {
    WindowConfig windowConfig = AppBeans.get(WindowConfig.NAME);
    WindowInfo windowInfo = windowConfig.getWindowInfo(windowAlias);
    return (AbstractEditor) getWindowManager().openEditor(windowInfo, item, openType, params, parentDs);
}
Also used : WindowConfig(com.haulmont.cuba.gui.config.WindowConfig) WindowInfo(com.haulmont.cuba.gui.config.WindowInfo)

Example 70 with WindowInfo

use of com.haulmont.cuba.gui.config.WindowInfo in project cuba by cuba-platform.

the class FragmentComponentLoader method createComponent.

@Override
public void createComponent() {
    String src = element.attributeValue("src");
    String screenId = element.attributeValue("screen");
    if (src == null && screenId == null) {
        throw new GuiDevelopmentException("Either 'src' or 'screen' must be specified for 'frame'", context, "fragment", element.attributeValue("id"));
    }
    String fragmentId;
    if (element.attributeValue("id") != null) {
        fragmentId = element.attributeValue("id");
    } else if (screenId != null) {
        fragmentId = screenId;
    } else {
        fragmentId = src;
    }
    FragmentHelper fragmentHelper = getFragmentHelper();
    WindowInfo windowInfo;
    if (src == null) {
        // load screen class only once
        windowInfo = getWindowConfig().getWindowInfo(screenId).resolve();
    } else {
        windowInfo = fragmentHelper.createFakeWindowInfo(src, fragmentId);
    }
    StopWatch createStopWatch = createStopWatch(ScreenLifeCycle.CREATE, windowInfo.getId());
    Fragment fragment = factory.create(Fragment.NAME);
    ScreenFragment controller = fragmentHelper.createController(windowInfo, fragment);
    // setup screen and controller
    ComponentLoaderContext parentContext = (ComponentLoaderContext) getContext();
    FrameOwner hostController = parentContext.getFrame().getFrameOwner();
    setHostController(controller, hostController);
    setWindowId(controller, windowInfo.getId());
    setFrame(controller, fragment);
    setScreenContext(controller, new ScreenContextImpl(windowInfo, parentContext.getOptions(), getScreenContext(hostController)));
    setScreenData(controller, new ScreenDataImpl());
    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(getComponentContext().getOptions());
        innerContext.setMessagesPack(fragmentHelper.getMessagePack(windowInfo.getTemplate()));
        innerContext.setCurrentFrameId(fragmentId);
        innerContext.setFullFrameId(frameId);
        innerContext.setFrame(fragment);
        innerContext.setParent(parentContext);
        innerContext.setProperties(loadProperties(element));
        LayoutLoader layoutLoader = getLayoutLoader(innerContext);
        ScreenXmlLoader screenXmlLoader = beanLocator.get(ScreenXmlLoader.NAME);
        Element rootElement = screenXmlLoader.load(windowInfo.getTemplate(), windowInfo.getId(), getComponentContext().getParams());
        String messagesPack = rootElement.attributeValue("messagesPack");
        if (messagesPack != null) {
            innerContext.setMessagesPack(messagesPack);
        }
        this.fragmentLoader = layoutLoader.createFragmentContent(fragment, rootElement);
    }
    createStopWatch.stop();
    this.resultComponent = fragment;
}
Also used : LayoutLoader(com.haulmont.cuba.gui.xml.layout.LayoutLoader) FragmentImplementation(com.haulmont.cuba.gui.components.sys.FragmentImplementation) Element(org.dom4j.Element) FragmentContextImpl(com.haulmont.cuba.gui.sys.FragmentContextImpl) FrameImplementation(com.haulmont.cuba.gui.components.sys.FrameImplementation) Fragment(com.haulmont.cuba.gui.components.Fragment) ScreenFragment(com.haulmont.cuba.gui.screen.ScreenFragment) WindowInfo(com.haulmont.cuba.gui.config.WindowInfo) UIPerformanceLogger.createStopWatch(com.haulmont.cuba.gui.logging.UIPerformanceLogger.createStopWatch) StopWatch(org.perf4j.StopWatch) ScreenFragment(com.haulmont.cuba.gui.screen.ScreenFragment) FrameOwner(com.haulmont.cuba.gui.screen.FrameOwner) ScreenDataImpl(com.haulmont.cuba.gui.model.impl.ScreenDataImpl) FragmentHelper(com.haulmont.cuba.gui.sys.FragmentHelper) GuiDevelopmentException(com.haulmont.cuba.gui.GuiDevelopmentException) ScreenContextImpl(com.haulmont.cuba.gui.sys.ScreenContextImpl) ScreenXmlLoader(com.haulmont.cuba.gui.xml.layout.ScreenXmlLoader)

Aggregations

WindowInfo (com.haulmont.cuba.gui.config.WindowInfo)74 WindowConfig (com.haulmont.cuba.gui.config.WindowConfig)43 WebWindowManager (com.haulmont.cuba.web.WebWindowManager)15 WindowManager (com.haulmont.cuba.gui.WindowManager)9 Element (org.dom4j.Element)8 Window (com.haulmont.cuba.gui.components.Window)7 LegacyFrame (com.haulmont.cuba.gui.screen.compatibility.LegacyFrame)5 HashMap (java.util.HashMap)5 Screens (com.haulmont.cuba.gui.Screens)3 FrameOwner (com.haulmont.cuba.gui.screen.FrameOwner)3 LayoutLoader (com.haulmont.cuba.gui.xml.layout.LayoutLoader)3 com.haulmont.cuba.core.global (com.haulmont.cuba.core.global)2 DetachedFrame (com.haulmont.cuba.desktop.DetachedFrame)2 GuiDevelopmentException (com.haulmont.cuba.gui.GuiDevelopmentException)2 Notifications (com.haulmont.cuba.gui.Notifications)2 OpenType (com.haulmont.cuba.gui.WindowManager.OpenType)2 Filter (com.haulmont.cuba.gui.components.Filter)2 Fragment (com.haulmont.cuba.gui.components.Fragment)2 RelatedAction (com.haulmont.cuba.gui.components.actions.RelatedAction)2 AddConditionWindow (com.haulmont.cuba.gui.components.filter.addcondition.AddConditionWindow)2