Search in sources :

Example 1 with WindowAttributesProvider

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

the class FragmentHelper method createFakeWindowInfo.

@SuppressWarnings("unchecked")
public WindowInfo createFakeWindowInfo(String src, String fragmentId) {
    Element screenElement = DocumentHelper.createElement("screen");
    screenElement.addAttribute("template", src);
    screenElement.addAttribute("id", fragmentId);
    Element windowElement = screenXmlLoader.load(src, fragmentId, Collections.emptyMap());
    Class<? extends ScreenFragment> fragmentClass;
    String className = windowElement.attributeValue("class");
    if (StringUtils.isNotEmpty(className)) {
        fragmentClass = (Class<? extends ScreenFragment>) scripting.loadClassNN(className);
    } else {
        fragmentClass = AbstractFrame.class;
    }
    return new WindowInfo(fragmentId, new WindowAttributesProvider() {

        @Override
        public WindowInfo.Type getType(WindowInfo wi) {
            return WindowInfo.Type.FRAGMENT;
        }

        @Override
        public String getTemplate(WindowInfo wi) {
            return src;
        }

        @Nonnull
        @Override
        public Class<? extends FrameOwner> getControllerClass(WindowInfo wi) {
            return fragmentClass;
        }

        @Override
        public WindowInfo resolve(WindowInfo windowInfo) {
            return windowInfo;
        }
    }, screenElement);
}
Also used : FrameOwner(com.haulmont.cuba.gui.screen.FrameOwner) WindowAttributesProvider(com.haulmont.cuba.gui.config.WindowAttributesProvider) Nonnull(javax.annotation.Nonnull) Element(org.dom4j.Element) WindowInfo(com.haulmont.cuba.gui.config.WindowInfo)

Aggregations

WindowAttributesProvider (com.haulmont.cuba.gui.config.WindowAttributesProvider)1 WindowInfo (com.haulmont.cuba.gui.config.WindowInfo)1 FrameOwner (com.haulmont.cuba.gui.screen.FrameOwner)1 Nonnull (javax.annotation.Nonnull)1 Element (org.dom4j.Element)1