Search in sources :

Example 1 with Settings

use of com.haulmont.cuba.gui.settings.Settings in project cuba by cuba-platform.

the class DesktopTabSheet method initLazyTab.

protected void initLazyTab(JComponent tab) {
    LazyTabInfo lti = null;
    for (LazyTabInfo lazyTabInfo : lazyTabs) {
        if (lazyTabInfo.getTabComponent() == tab) {
            lti = lazyTabInfo;
            break;
        }
    }
    if (lti == null) {
        // already initialized
        return;
    }
    if (!lti.getTab().isEnabled()) {
        return;
    }
    lazyTabs.remove(lti);
    lti.loader.createComponent();
    Component lazyContent = lti.loader.getResultComponent();
    lazyContent.setWidth("100%");
    lti.tabContent.add(lazyContent);
    lti.tabContent.expand(lazyContent, "", "");
    lazyContent.setParent(this);
    lti.loader.loadComponent();
    if (lazyContent instanceof DesktopAbstractComponent && !isEnabledWithParent()) {
        ((DesktopAbstractComponent) lazyContent).setParentEnabled(false);
    }
    final Window window = ComponentsHelper.getWindow(DesktopTabSheet.this);
    if (window != null) {
        ComponentsHelper.walkComponents(lti.tabContent, (component, name) -> {
            if (component instanceof HasSettings) {
                Settings settings = window.getSettings();
                if (settings != null) {
                    Element e = settings.get(name);
                    ((HasSettings) component).applySettings(e);
                }
            }
        });
        lti.getTab().setLazyInitialized(true);
    }
}
Also used : Window(com.haulmont.cuba.gui.components.Window) Element(org.dom4j.Element) ButtonTabComponent(com.haulmont.cuba.desktop.sys.ButtonTabComponent) Component(com.haulmont.cuba.gui.components.Component) Settings(com.haulmont.cuba.gui.settings.Settings)

Aggregations

ButtonTabComponent (com.haulmont.cuba.desktop.sys.ButtonTabComponent)1 Component (com.haulmont.cuba.gui.components.Component)1 Window (com.haulmont.cuba.gui.components.Window)1 Settings (com.haulmont.cuba.gui.settings.Settings)1 Element (org.dom4j.Element)1