Search in sources :

Example 1 with Fragments

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

the class WebFragment method attached.

@Override
public void attached() {
    super.attached();
    FragmentContextImpl context = (FragmentContextImpl) getContext();
    if (context.isManualInitRequired()) {
        if (!context.isInitialized()) {
            Fragments fragments = UiControllerUtils.getScreenContext(frameOwner).getFragments();
            fragments.init(frameOwner);
        }
        UiControllerUtils.fireEvent(frameOwner, ScreenFragment.AttachEvent.class, new ScreenFragment.AttachEvent(frameOwner));
    }
}
Also used : ScreenFragment(com.haulmont.cuba.gui.screen.ScreenFragment) Fragments(com.haulmont.cuba.gui.Fragments) FragmentContextImpl(com.haulmont.cuba.gui.sys.FragmentContextImpl)

Example 2 with Fragments

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

the class AbstractLookup method initLookupLayout.

@Override
public void initLookupLayout() {
    Action selectAction = getAction(LOOKUP_SELECT_ACTION_ID);
    if (selectAction != null && selectAction.getOwner() == null) {
        Fragments fragments = UiControllerUtils.getScreenContext(this).getFragments();
        ScreenFragment lookupWindowActions = fragments.create(this, "lookupWindowActions");
        lookupWindowActions.getFragment().setId("lookupWindowActions");
        lookupWindowActions.getFragment().setVisible(false);
        getFrame().add(lookupWindowActions.getFragment());
    }
    Element element = ((Component.HasXmlDescriptor) getFrame()).getXmlDescriptor();
    if (element != null) {
        String lookupComponent = element.attributeValue("lookupComponent");
        if (StringUtils.isNotEmpty(lookupComponent)) {
            Component component = getFrame().getComponent(lookupComponent);
            setLookupComponent(component);
        }
    }
    Component lookupComponent = getLookupComponent();
    if (lookupComponent instanceof LookupSelectionChangeNotifier) {
        LookupSelectionChangeNotifier selectionNotifier = (LookupSelectionChangeNotifier) lookupComponent;
        if (selectAction != null) {
            // noinspection unchecked
            selectionNotifier.addLookupValueChangeListener(valueChangeEvent -> selectAction.setEnabled(!selectionNotifier.getLookupSelectedItems().isEmpty()));
            selectAction.setEnabled(!selectionNotifier.getLookupSelectedItems().isEmpty());
        }
    }
}
Also used : BaseAction(com.haulmont.cuba.gui.components.actions.BaseAction) ScreenFragment(com.haulmont.cuba.gui.screen.ScreenFragment) Element(org.dom4j.Element) Fragments(com.haulmont.cuba.gui.Fragments) LookupSelectionChangeNotifier(com.haulmont.cuba.gui.components.LookupComponent.LookupSelectionChangeNotifier)

Aggregations

Fragments (com.haulmont.cuba.gui.Fragments)2 ScreenFragment (com.haulmont.cuba.gui.screen.ScreenFragment)2 LookupSelectionChangeNotifier (com.haulmont.cuba.gui.components.LookupComponent.LookupSelectionChangeNotifier)1 BaseAction (com.haulmont.cuba.gui.components.actions.BaseAction)1 FragmentContextImpl (com.haulmont.cuba.gui.sys.FragmentContextImpl)1 Element (org.dom4j.Element)1