Search in sources :

Example 1 with ComponentContainer

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

the class AttributeAccessSupport method applyAttributeAccess.

/**
 * Apply attribute access rules to a given frame. It means that all components bound to datasources will adjust
 * their visible/read-only/required state according to security state of entity instances contained in the datasources.
 *
 * @param frameOwner frame or screen
 * @param reset      whether to reset the components to the default state specified by role-based security and model
 *                   annotations. If you invoke this method to apply attribute access to already opened screen, set
 *                   the parameter to true, but keep in mind that previous programmatic changes in the components
 *                   visible/read-only/required state will be lost.
 */
public void applyAttributeAccess(FrameOwner frameOwner, boolean reset) {
    ComponentContainer componentContainer;
    if (frameOwner instanceof Screen) {
        componentContainer = ((Screen) frameOwner).getWindow();
    } else {
        componentContainer = (Window) frameOwner;
    }
    ComponentsHelper.walkComponents(componentContainer, (component, name) -> visitComponent(component, reset));
}
Also used : Screen(com.haulmont.cuba.gui.screen.Screen) ComponentContainer(com.haulmont.cuba.gui.components.ComponentContainer)

Example 2 with ComponentContainer

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

the class WebComponentsHelper method getShortcutEvent.

public static ShortcutTriggeredEvent getShortcutEvent(com.haulmont.cuba.gui.components.Component source, Component target) {
    Component vaadinSource = getVaadinSource(source);
    if (vaadinSource == target) {
        return new ShortcutTriggeredEvent(source, source);
    }
    if (source instanceof ComponentContainer) {
        ComponentContainer container = (ComponentContainer) source;
        com.haulmont.cuba.gui.components.Component childComponent = findChildComponent(container, target);
        return new ShortcutTriggeredEvent(source, childComponent);
    }
    return new ShortcutTriggeredEvent(source, null);
}
Also used : com.haulmont.cuba.gui.components(com.haulmont.cuba.gui.components) ComponentContainer(com.haulmont.cuba.gui.components.ComponentContainer) Component(com.vaadin.ui.Component)

Example 3 with ComponentContainer

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

the class WebComponentsHelper method findChildComponent.

protected static com.haulmont.cuba.gui.components.Component findChildComponent(Collection<com.haulmont.cuba.gui.components.Component> components, Component vaadinSource, Component target) {
    Component targetComponent = getDirectChildComponent(target, vaadinSource);
    for (com.haulmont.cuba.gui.components.Component component : components) {
        Component unwrapped = component.unwrapComposition(Component.class);
        if (unwrapped == targetComponent) {
            com.haulmont.cuba.gui.components.Component child = null;
            if (component instanceof ComponentContainer) {
                child = findChildComponent((ComponentContainer) component, target);
            }
            if (component instanceof HasButtonsPanel) {
                ButtonsPanel buttonsPanel = ((HasButtonsPanel) component).getButtonsPanel();
                if (buttonsPanel != null) {
                    if (getVaadinSource(buttonsPanel) == target) {
                        return buttonsPanel;
                    } else {
                        child = findChildComponent(buttonsPanel, target);
                    }
                }
            }
            if (component instanceof FieldGroup) {
                FieldGroup fieldGroup = (FieldGroup) component;
                child = findChildComponent(fieldGroup, target);
            }
            return child != null ? child : component;
        }
    }
    return null;
}
Also used : com.haulmont.cuba.gui.components(com.haulmont.cuba.gui.components) ComponentContainer(com.haulmont.cuba.gui.components.ComponentContainer) Component(com.vaadin.ui.Component)

Aggregations

ComponentContainer (com.haulmont.cuba.gui.components.ComponentContainer)3 com.haulmont.cuba.gui.components (com.haulmont.cuba.gui.components)2 Component (com.vaadin.ui.Component)2 Screen (com.haulmont.cuba.gui.screen.Screen)1