Search in sources :

Example 71 with Component

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

the class FormImpl method calculateComponentAreas.

protected List<ComponentArea> calculateComponentAreas() {
    List<ComponentArea> componentAreas = new ArrayList<>();
    // Inspired by GridLayoutLoader logic
    boolean[][] spanMatrix = new boolean[this.component.getColumns()][this.component.getRows()];
    for (int col = 0; col < columnComponentMapping.size(); col++) {
        int row = 0;
        List<ComponentPosition> columnFields = columnComponentMapping.get(col);
        for (ComponentPosition componentPosition : columnFields) {
            while (spanMatrix[col][row]) {
                row++;
            }
            Component component = componentPosition.getComponent();
            int colSpan = componentPosition.getColSpan();
            int rowSpan = componentPosition.getRowSpan();
            if (colSpan == 1 && rowSpan == 1) {
                componentAreas.add(new ComponentArea(component, col, row, col, row));
            } else {
                fillSpanMatrix(spanMatrix, col, row, colSpan, rowSpan);
                int endColumn = col + colSpan - 1;
                int endRow = row + rowSpan - 1;
                componentAreas.add(new ComponentArea(component, col, row, endColumn, endRow));
            }
            row++;
        }
    }
    return componentAreas;
}
Also used : ComponentPosition(io.jmix.ui.component.form.ComponentPosition) ComponentArea(io.jmix.ui.component.form.ComponentArea) ArrayList(java.util.ArrayList) Component(io.jmix.ui.component.Component)

Example 72 with Component

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

the class FormImpl method applyPermission.

@Override
public void applyPermission(UiPermissionDescriptor permissionDescriptor) {
    checkNotNullArgument(permissionDescriptor);
    String subComponentId = permissionDescriptor.getSubComponentId();
    UiPermissionValue permissionValue = permissionDescriptor.getPermissionValue();
    String screenId = permissionDescriptor.getScreenId();
    if (subComponentId != null) {
        Component component = getComponent(subComponentId);
        if (component != null) {
            if (permissionValue == UiPermissionValue.HIDE) {
                component.setVisible(false);
            } else if (permissionValue == UiPermissionValue.READ_ONLY && this.component instanceof Editable) {
                ((Editable) component).setEditable(false);
            }
        } else {
            log.info("Couldn't find suitable component {} in window {} for UI security rule", subComponentId, screenId);
        }
    } else {
        String actionHolderComponentId = permissionDescriptor.getActionHolderComponentId();
        if (actionHolderComponentId == null || !(getComponent(actionHolderComponentId) instanceof SecuredActionsHolder)) {
            log.info("Couldn't find suitable component {} in window {} for UI security rule", actionHolderComponentId, screenId);
            return;
        }
        String actionId = permissionDescriptor.getActionId();
        ActionsPermissions permissions = ((SecuredActionsHolder) component).getActionsPermissions();
        if (permissionValue == UiPermissionValue.HIDE) {
            permissions.addHiddenActionPermission(actionId);
        } else if (permissionValue == UiPermissionValue.READ_ONLY) {
            permissions.addDisabledActionPermission(actionId);
        }
    }
}
Also used : UiPermissionValue(io.jmix.ui.security.UiPermissionValue) ActionsPermissions(io.jmix.ui.component.ActionsPermissions) SecuredActionsHolder(io.jmix.ui.component.SecuredActionsHolder) Component(io.jmix.ui.component.Component)

Example 73 with Component

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

the class HtmlBoxLayoutImpl method removeAll.

@Override
public void removeAll() {
    component.removeAllComponents();
    Component[] components = ownComponents.toArray(new Component[0]);
    ownComponents.clear();
    for (Component childComponent : components) {
        childComponent.setParent(null);
    }
}
Also used : Component(io.jmix.ui.component.Component)

Example 74 with Component

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

the class SplitPanelImpl method removeAll.

@Override
public void removeAll() {
    component.removeAllComponents();
    Component[] components = ownComponents.toArray(new Component[0]);
    ownComponents.clear();
    for (Component childComponent : components) {
        childComponent.setParent(null);
    }
}
Also used : Component(io.jmix.ui.component.Component)

Example 75 with Component

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

the class AccordionLoader method createComponent.

@Override
public void createComponent() {
    resultComponent = createComponentInternal();
    loadId(resultComponent, element);
    LayoutLoader layoutLoader = getLayoutLoader();
    List<Element> tabElements = element.elements("tab");
    for (Element tabElement : tabElements) {
        String name = tabElement.attributeValue("id");
        boolean lazy = Boolean.parseBoolean(tabElement.attributeValue("lazy"));
        ComponentLoader tabComponentLoader = layoutLoader.getLoader(tabElement, TabComponentLoader.class);
        Accordion.Tab tab;
        if (lazy) {
            tab = resultComponent.addLazyTab(name, tabElement, tabComponentLoader);
        } else {
            tabComponentLoader.createComponent();
            Component tabComponent = tabComponentLoader.getResultComponent();
            tab = resultComponent.addTab(name, tabComponent);
            pendingLoadComponents.add(tabComponentLoader);
        }
        pendingLoadTabs.put(tabElement, tab);
    }
}
Also used : Accordion(io.jmix.ui.component.Accordion) Element(org.dom4j.Element) Component(io.jmix.ui.component.Component) ComponentLoader(io.jmix.ui.xml.layout.ComponentLoader)

Aggregations

Component (io.jmix.ui.component.Component)81 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 MetaClass (io.jmix.core.metamodel.model.MetaClass)7 Action (io.jmix.ui.action.Action)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