Search in sources :

Example 16 with Component

use of io.jmix.ui.component.Component in project jmix by jmix-framework.

the class EntityCombinedScreen method initEditComponents.

/**
 * Initializes edit controls, depending on if they should be enabled or disabled.
 * @param enabled if true - enables edit controls and disables controls on the left side of the splitter
 *                if false - vice versa
 */
protected void initEditComponents(boolean enabled) {
    TabSheet tabSheet = getTabSheet();
    if (tabSheet != null) {
        ComponentsHelper.walkComponents(tabSheet, (component, name) -> {
            if (component instanceof FieldGroup) {
                ((FieldGroup) component).setEditable(enabled);
            } else if (component instanceof Table) {
                ((Table) component).getActions().forEach(action -> action.setEnabled(enabled));
            } else if (!(component instanceof HasComponents)) {
                component.setEnabled(enabled);
            }
        });
    }
    getFieldGroup().setEditable(enabled);
    getActionsPane().setVisible(enabled);
    getLookupBox().setEnabled(!enabled);
}
Also used : MetaClass(io.jmix.core.metamodel.model.MetaClass) Datasource(com.haulmont.cuba.gui.data.Datasource) LockService(com.haulmont.cuba.core.app.LockService) LockNotSupported(io.jmix.core.pessimisticlocking.LockNotSupported) TabSheet(io.jmix.ui.component.TabSheet) EditAction(com.haulmont.cuba.gui.components.actions.EditAction) RemoveAction(com.haulmont.cuba.gui.components.actions.RemoveAction) EntityValues(io.jmix.core.entity.EntityValues) Metadata(com.haulmont.cuba.core.global.Metadata) CreateAction(com.haulmont.cuba.gui.components.actions.CreateAction) EntityOp(io.jmix.core.security.EntityOp) ArrayList(java.util.ArrayList) AbstractDatasource(com.haulmont.cuba.gui.data.impl.AbstractDatasource) Component(io.jmix.ui.component.Component) List(java.util.List) LockInfo(io.jmix.core.pessimisticlocking.LockInfo) ExtendedEntities(io.jmix.core.ExtendedEntities) Map(java.util.Map) Entity(io.jmix.core.Entity) DatatypeFormatter(io.jmix.core.metamodel.datatype.DatatypeFormatter) Collections(java.util.Collections) CollectionDatasource(com.haulmont.cuba.gui.data.CollectionDatasource) Nullable(javax.annotation.Nullable) io.jmix.ui.component(io.jmix.ui.component) TabSheet(io.jmix.ui.component.TabSheet)

Example 17 with Component

use of io.jmix.ui.component.Component in project jmix by jmix-framework.

the class CubaComponentsHelper method findChildComponent.

@Nullable
protected static Component findChildComponent(Collection<Component> components, com.vaadin.ui.Component vaadinSource, com.vaadin.ui.Component target) {
    com.vaadin.ui.Component targetComponent = ComponentsHelper.getDirectChildComponent(target, vaadinSource);
    for (Component component : components) {
        com.vaadin.ui.Component unwrapped = component.unwrapComposition(com.vaadin.ui.Component.class);
        if (unwrapped == targetComponent) {
            Component child = null;
            if (component instanceof HasComponents) {
                child = ComponentsHelper.findChildComponent((HasComponents) component, target);
            }
            if (component instanceof HasButtonsPanel) {
                ButtonsPanel buttonsPanel = ((HasButtonsPanel) component).getButtonsPanel();
                if (buttonsPanel != null) {
                    if (ComponentsHelper.getVaadinSource(buttonsPanel) == target) {
                        return buttonsPanel;
                    } else {
                        child = ComponentsHelper.findChildComponent(buttonsPanel, target);
                    }
                }
            }
            if (component instanceof FieldGroup) {
                FieldGroup fieldGroup = (FieldGroup) component;
                child = ComponentsHelper.findChildComponent(fieldGroup, target);
            }
            return child != null ? child : component;
        }
    }
    return null;
}
Also used : Component(io.jmix.ui.component.Component) ButtonsPanel(io.jmix.ui.component.ButtonsPanel) Nullable(javax.annotation.Nullable)

Example 18 with Component

use of io.jmix.ui.component.Component in project jmix by jmix-framework.

the class WebFilter method setDelegate.

@Autowired
protected void setDelegate(FilterDelegate delegate) {
    this.delegate = delegate;
    delegate.setFilter(this);
    ComponentContainer layout = delegate.getLayout();
    layout.setParent(this);
    component = layout.unwrapComposition(com.vaadin.ui.Component.class);
    component.setWidth(100, Sizeable.Unit.PERCENTAGE);
    component.addStyleName(FILTER_STYLENAME);
    delegate.setExpandedStateChangeListener(e -> fireExpandStateChange(e.isExpanded(), e.isUserOriginated()));
    delegate.setCaptionChangedListener(this::updateCaptions);
}
Also used : ComponentContainer(io.jmix.ui.component.ComponentContainer) AbstractComponent(io.jmix.ui.component.impl.AbstractComponent) Component(io.jmix.ui.component.Component) Autowired(org.springframework.beans.factory.annotation.Autowired)

Example 19 with Component

use of io.jmix.ui.component.Component in project jmix by jmix-framework.

the class ScreenSettingsFacetImpl method fillWithInnerComponents.

protected Collection<Component> fillWithInnerComponents(Collection<Component> components, HasInnerComponents hasInnerComponents) {
    Collection<Component> innerComponents = hasInnerComponents.getInnerComponents();
    components.addAll(innerComponents);
    for (Component component : innerComponents) {
        if (component instanceof HasInnerComponents) {
            fillWithInnerComponents(components, (HasInnerComponents) component);
        }
    }
    return components;
}
Also used : HasInnerComponents(io.jmix.ui.component.HasInnerComponents) Component(io.jmix.ui.component.Component)

Example 20 with Component

use of io.jmix.ui.component.Component in project jmix by jmix-framework.

the class FormImpl method setDebugId.

@Override
public void setDebugId(@Nullable String id) {
    super.setDebugId(id);
    AppUI ui = AppUI.getCurrent();
    if (ui != null && id != null) {
        for (final Component component : getOwnComponents()) {
            com.vaadin.ui.Component composition = ComponentsHelper.getComposition(component);
            composition.setId(ui.getTestIdManager().getTestId(id + "_" + component.getId()));
        }
    }
}
Also used : Component(io.jmix.ui.component.Component) AppUI(io.jmix.ui.AppUI)

Aggregations

Component (io.jmix.ui.component.Component)82 GuiDevelopmentException (io.jmix.ui.GuiDevelopmentException)16 Datasource (com.haulmont.cuba.gui.data.Datasource)12 CollectionDatasource (com.haulmont.cuba.gui.data.CollectionDatasource)11 Test (org.junit.jupiter.api.Test)11 Element (org.dom4j.Element)10 Consumer (java.util.function.Consumer)9 ListComponent (com.haulmont.cuba.gui.components.ListComponent)8 Action (io.jmix.ui.action.Action)8 MetaClass (io.jmix.core.metamodel.model.MetaClass)7 HasValue (io.jmix.ui.component.HasValue)7 FrameOwner (io.jmix.ui.screen.FrameOwner)7 ArrayList (java.util.ArrayList)7 DatasourceImpl (com.haulmont.cuba.gui.data.impl.DatasourceImpl)6 FetchPlan (io.jmix.core.FetchPlan)6 UUID (java.util.UUID)6 Nullable (javax.annotation.Nullable)6 User (com.haulmont.cuba.core.model.common.User)5 DsBuilder (com.haulmont.cuba.gui.data.DsBuilder)5 Entity (io.jmix.core.Entity)5