Search in sources :

Example 1 with FrameImplementation

use of com.haulmont.cuba.gui.components.sys.FrameImplementation in project cuba by cuba-platform.

the class WebSplitPanel method add.

@Override
public void add(Component childComponent) {
    if (childComponent.getParent() != null && childComponent.getParent() != this) {
        throw new IllegalStateException("Component already has parent");
    }
    if (component == null) {
        createComponentImpl();
    }
    AppUI ui = AppUI.getCurrent();
    if (ui.isTestMode()) {
        component.setCubaId(getId());
    }
    com.vaadin.ui.Component vComponent = childComponent.unwrapComposition(com.vaadin.ui.Component.class);
    component.addComponent(vComponent);
    if (frame != null) {
        if (childComponent instanceof BelongToFrame && ((BelongToFrame) childComponent).getFrame() == null) {
            ((BelongToFrame) childComponent).setFrame(frame);
        } else {
            ((FrameImplementation) frame).registerComponent(childComponent);
        }
    }
    ownComponents.add(childComponent);
    childComponent.setParent(this);
}
Also used : FrameImplementation(com.haulmont.cuba.gui.components.sys.FrameImplementation) AppUI(com.haulmont.cuba.web.AppUI)

Example 2 with FrameImplementation

use of com.haulmont.cuba.gui.components.sys.FrameImplementation in project cuba by cuba-platform.

the class WebGroupBox method add.

@Override
public void add(Component childComponent, int index) {
    if (childComponent.getParent() != null && childComponent.getParent() != this) {
        throw new IllegalStateException("Component already has parent");
    }
    AbstractOrderedLayout newContent = null;
    if (orientation == Orientation.VERTICAL && !(component.getContent() instanceof CubaVerticalActionsLayout)) {
        newContent = new CubaVerticalActionsLayout();
    } else if (orientation == Orientation.HORIZONTAL && !(component.getContent() instanceof CubaHorizontalActionsLayout)) {
        newContent = new CubaHorizontalActionsLayout();
    }
    if (newContent != null) {
        newContent.setStyleName("c-groupbox-inner");
        component.setContent(newContent);
        CubaOrderedActionsLayout currentContent = (CubaOrderedActionsLayout) component.getContent();
        newContent.setMargin(currentContent.getMargin());
        newContent.setSpacing(currentContent.isSpacing());
    }
    if (ownComponents.contains(childComponent)) {
        int existingIndex = getComponentContent().getComponentIndex(WebComponentsHelper.getComposition(childComponent));
        if (index > existingIndex) {
            index--;
        }
        remove(childComponent);
    }
    com.vaadin.ui.Component vComponent = WebComponentsHelper.getComposition(childComponent);
    getComponentContent().addComponent(vComponent, index);
    getComponentContent().setComponentAlignment(vComponent, WebWrapperUtils.toVaadinAlignment(childComponent.getAlignment()));
    if (frame != null) {
        if (childComponent instanceof BelongToFrame && ((BelongToFrame) childComponent).getFrame() == null) {
            ((BelongToFrame) childComponent).setFrame(frame);
        } else {
            ((FrameImplementation) frame).registerComponent(childComponent);
        }
    }
    if (index == ownComponents.size()) {
        ownComponents.add(childComponent);
    } else {
        ownComponents.add(index, childComponent);
    }
    childComponent.setParent(this);
}
Also used : CubaVerticalActionsLayout(com.haulmont.cuba.web.widgets.CubaVerticalActionsLayout) FrameImplementation(com.haulmont.cuba.gui.components.sys.FrameImplementation) AbstractOrderedLayout(com.vaadin.ui.AbstractOrderedLayout) CubaHorizontalActionsLayout(com.haulmont.cuba.web.widgets.CubaHorizontalActionsLayout) CubaOrderedActionsLayout(com.haulmont.cuba.web.widgets.CubaOrderedActionsLayout)

Example 3 with FrameImplementation

use of com.haulmont.cuba.gui.components.sys.FrameImplementation in project cuba by cuba-platform.

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();
    WindowInfo windowInfo = fragmentHelper.createFakeWindowInfo(src, fragmentId);
    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();
    // 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, 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(getContext().getOptions());
        innerContext.setMessagesPack(fragmentHelper.getMessagePack(windowInfo.getTemplate()));
        innerContext.setCurrentFrameId(fragmentId);
        innerContext.setFullFrameId(frameId);
        innerContext.setFrame(fragment);
        innerContext.setParent(parentContext);
        LayoutLoader layoutLoader = getLayoutLoader(innerContext);
        ScreenXmlLoader screenXmlLoader = beanLocator.get(ScreenXmlLoader.NAME);
        Element rootElement = screenXmlLoader.load(windowInfo.getTemplate(), windowInfo.getId(), getContext().getParams());
        String messagesPack = rootElement.attributeValue("messagesPack");
        if (messagesPack != null) {
            innerContext.setMessagesPack(messagesPack);
        }
        this.fragmentLoader = layoutLoader.createFragmentContent(fragment, rootElement);
    }
    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) 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) ScreenContextImpl(com.haulmont.cuba.gui.sys.ScreenContextImpl) ScreenXmlLoader(com.haulmont.cuba.gui.xml.layout.ScreenXmlLoader)

Example 4 with FrameImplementation

use of com.haulmont.cuba.gui.components.sys.FrameImplementation in project cuba by cuba-platform.

the class WebAbstractComponent method setId.

@Override
public void setId(String id) {
    if (!Objects.equals(this.id, id)) {
        if (frame != null) {
            ((FrameImplementation) frame).unregisterComponent(this);
        }
        this.id = id;
        AppUI ui = AppUI.getCurrent();
        if (ui != null) {
            if (this.component != null && ui.isTestMode()) {
                this.component.setCubaId(id);
            }
        }
        assignDebugId();
        if (frame != null) {
            ((FrameImplementation) frame).registerComponent(this);
        }
    }
}
Also used : FrameImplementation(com.haulmont.cuba.gui.components.sys.FrameImplementation) AppUI(com.haulmont.cuba.web.AppUI)

Example 5 with FrameImplementation

use of com.haulmont.cuba.gui.components.sys.FrameImplementation in project cuba by cuba-platform.

the class CompositeComponent method setId.

@Override
public void setId(String id) {
    if (!Objects.equals(this.id, id)) {
        if (frame != null) {
            ((FrameImplementation) frame).unregisterComponent(this);
        }
        this.id = id;
        AppUI ui = AppUI.getCurrent();
        if (ui != null) {
            if (root != null && ui.isTestMode()) {
                com.vaadin.ui.Component vComponent = root.unwrap(com.vaadin.ui.Component.class);
                if (vComponent != null) {
                    vComponent.setCubaId(id);
                }
            }
        }
        assignDebugId();
        if (frame != null) {
            ((FrameImplementation) frame).registerComponent(this);
        }
    }
}
Also used : FrameImplementation(com.haulmont.cuba.gui.components.sys.FrameImplementation) AppUI(com.haulmont.cuba.web.AppUI)

Aggregations

FrameImplementation (com.haulmont.cuba.gui.components.sys.FrameImplementation)10 Fragment (com.haulmont.cuba.gui.components.Fragment)3 FragmentImplementation (com.haulmont.cuba.gui.components.sys.FragmentImplementation)3 ScreenDataImpl (com.haulmont.cuba.gui.model.impl.ScreenDataImpl)3 FragmentContextImpl (com.haulmont.cuba.gui.sys.FragmentContextImpl)3 ScreenContextImpl (com.haulmont.cuba.gui.sys.ScreenContextImpl)3 LayoutLoader (com.haulmont.cuba.gui.xml.layout.LayoutLoader)3 AppUI (com.haulmont.cuba.web.AppUI)3 Element (org.dom4j.Element)3 WindowInfo (com.haulmont.cuba.gui.config.WindowInfo)2 UIPerformanceLogger.createStopWatch (com.haulmont.cuba.gui.logging.UIPerformanceLogger.createStopWatch)2 FrameOwner (com.haulmont.cuba.gui.screen.FrameOwner)2 ScreenFragment (com.haulmont.cuba.gui.screen.ScreenFragment)2 FragmentHelper (com.haulmont.cuba.gui.sys.FragmentHelper)2 ScreenXmlLoader (com.haulmont.cuba.gui.xml.layout.ScreenXmlLoader)2 CubaHorizontalActionsLayout (com.haulmont.cuba.web.widgets.CubaHorizontalActionsLayout)2 CubaVerticalActionsLayout (com.haulmont.cuba.web.widgets.CubaVerticalActionsLayout)2 AbstractOrderedLayout (com.vaadin.ui.AbstractOrderedLayout)2 Nullable (javax.annotation.Nullable)2 StopWatch (org.perf4j.StopWatch)2