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));
}
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);
}
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;
}
Aggregations