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