use of io.jmix.ui.component.Component in project jmix by jmix-framework.
the class FileUploadFieldLoader method loadDropZone.
protected void loadDropZone(UploadField uploadField, Element element) {
String dropZoneId = element.attributeValue("dropZone");
if (StringUtils.isNotEmpty(dropZoneId)) {
Component dropZone = findComponent(dropZoneId);
if (dropZone instanceof BoxLayout) {
uploadField.setDropZone(new UploadField.DropZone((BoxLayout) dropZone));
} else if (dropZone != null) {
throw new GuiDevelopmentException("Unsupported dropZone class " + dropZone.getClass().getName(), context);
} else {
throw new GuiDevelopmentException("Unable to find dropZone component with id: " + dropZoneId, context);
}
}
String dropZonePrompt = element.attributeValue("dropZonePrompt");
if (StringUtils.isNotEmpty(dropZonePrompt)) {
uploadField.setDropZonePrompt(loadResourceString(dropZonePrompt));
}
}
use of io.jmix.ui.component.Component in project jmix by jmix-framework.
the class JpqlFilterLoader method createValueComponent.
@SuppressWarnings("rawtypes")
@Override
protected Component createValueComponent(List<Element> elements) {
return elements.stream().filter(valueComponentElement -> !"condition".equals(valueComponentElement.getName())).map(valueComponentElement -> {
ComponentLoader valueComponentLoader = getLayoutLoader().createComponent(valueComponentElement);
valueComponentLoader.loadComponent();
return valueComponentLoader.getResultComponent();
}).findFirst().orElseGet(this::generateValueComponent);
}
use of io.jmix.ui.component.Component in project jmix by jmix-framework.
the class FilterDelegateImpl method recursivelyCreateConditionsLayout.
protected void recursivelyCreateConditionsLayout(ConditionsFocusType conditionsFocusType, boolean initialFocusSet, List<Node<AbstractCondition>> nodes, ComponentContainer parentContainer, int level) {
FilterDataContext filterDataContext = new FilterDataContext(filter.getFrame());
List<Node<AbstractCondition>> visibleConditionNodes = fetchVisibleNodes(nodes);
if (visibleConditionNodes.isEmpty()) {
if (level == 0)
controlsLayout.setStyleName("filter-control-no-border");
return;
}
// note that this is not grid columns count, but number of conditions (label cell + value cell) in one row
int conditionsCount = getColumnsCount();
int row = 0;
int nextColumnStart = 0;
GridLayout grid = uiComponents.create(GridLayout.class);
grid.setStyleName("conditions-grid");
grid.setColumns(conditionsCount * 2);
// set expand ratio only for cells with param edit components
for (int i = 0; i < conditionsCount; i++) {
grid.setColumnExpandRatio(i * 2 + 1, 1);
}
grid.setRows(1);
grid.setSpacing(true);
grid.setWidth("100%");
ParamEditor firstParamEditor = null;
ParamEditor lastParamEditor = null;
boolean currentFocusSet = initialFocusSet;
RuntimeException entityParamInformationException = null;
for (int i = 0; i < visibleConditionNodes.size(); i++) {
Node<AbstractCondition> node = visibleConditionNodes.get(i);
final AbstractCondition condition = node.getData();
BoxLayout labelAndOperationCellContent = null;
Component paramEditComponentCellContent = null;
Component groupCellContent = null;
if (condition.isGroup()) {
groupCellContent = createGroupConditionBox(condition, node, conditionsFocusType, currentFocusSet, level);
level++;
} else {
if (condition.getParam().getJavaClass() != null) {
Pair<ParamEditor, RuntimeException> pair = createParamEditorWithChecks(condition, filterDataContext);
ParamEditor paramEditor = pair.getFirst();
addParamEditor(condition, paramEditor);
if (pair.getSecond() != null) {
entityParamInformationException = pair.getSecond();
}
if (firstParamEditor == null)
firstParamEditor = paramEditor;
lastParamEditor = paramEditor;
currentFocusSet = true;
labelAndOperationCellContent = paramEditor.getLabelAndOperationLayout();
paramEditComponentCellContent = paramEditor.getParamEditComponentLayout();
} else {
BoxLayout paramLayout = uiComponents.create(HBoxLayout.class);
paramLayout.setSpacing(true);
paramLayout.setMargin(false);
labelAndOperationCellContent = paramLayout;
}
}
// groupBox for group conditions must occupy the whole line in conditions grid
Integer conditionWidth = condition.isGroup() ? (Integer) conditionsCount : condition.getWidth();
int nextColumnEnd = nextColumnStart + conditionWidth - 1;
if (nextColumnEnd >= conditionsCount) {
// complete current row in grid with gaps if next cell will be on next row
completeGridRowWithGaps(grid, row, nextColumnStart, false);
// place cell to next row in grid
nextColumnStart = 0;
nextColumnEnd = conditionWidth - 1;
row++;
grid.setRows(row + 1);
}
if (groupCellContent != null) {
grid.add(groupCellContent, nextColumnStart * 2, row, nextColumnEnd * 2 + 1, row);
}
if (labelAndOperationCellContent != null) {
labelAndOperationCellContent.addStyleName("param-label-layout");
grid.add(labelAndOperationCellContent, nextColumnStart * 2, row, nextColumnStart * 2, row);
if (nextColumnStart != 0)
labelAndOperationCellContent.setMargin(false, false, false, true);
}
if (paramEditComponentCellContent != null) {
paramEditComponentCellContent.addStyleName("param-field-layout");
if (condition.getParam().getType() == Param.Type.UNARY) {
paramEditComponentCellContent.addStyleName("unary-param-type");
}
grid.add(paramEditComponentCellContent, nextColumnStart * 2 + 1, row, nextColumnEnd * 2 + 1, row);
}
nextColumnStart = nextColumnEnd + 1;
// add next row if necessary
if (i < visibleConditionNodes.size() - 1) {
if (nextColumnStart >= conditionsCount) {
nextColumnStart = 0;
row++;
grid.setRows(row + 1);
}
}
}
filterDataContext.loadAll();
if (!initialFocusSet) {
switch(conditionsFocusType) {
case FIRST:
if (firstParamEditor != null) {
paramEditComponentToFocus = firstParamEditor;
}
break;
case LAST:
if (lastParamEditor != null) {
paramEditComponentToFocus = lastParamEditor;
}
break;
default:
// no action
break;
}
}
// complete last row in grid with gaps
completeGridRowWithGaps(grid, row, nextColumnStart, true);
if (parentContainer != null) {
parentContainer.add(grid);
}
if (level == 0)
controlsLayout.setStyleName(getControlsLayoutStyleName());
if (entityParamInformationException != null) {
getDialogs().createExceptionDialog().withThrowable(entityParamInformationException).show();
}
}
use of io.jmix.ui.component.Component in project jmix by jmix-framework.
the class FilterDelegateImpl method createGroupConditionBox.
protected Component createGroupConditionBox(AbstractCondition condition, Node<AbstractCondition> node, ConditionsFocusType conditionsFocusType, boolean focusSet, int level) {
Component groupCellContent;
GroupBoxLayout groupBox = uiComponents.create(GroupBoxLayout.class);
groupBox.setStyleName("conditions-group");
groupBox.setWidth("100%");
groupBox.setCaption(condition.getLocCaption());
if (!node.getChildren().isEmpty()) {
recursivelyCreateConditionsLayout(conditionsFocusType, focusSet, node.getChildren(), groupBox, level);
}
groupCellContent = groupBox;
return groupCellContent;
}
use of io.jmix.ui.component.Component in project jmix by jmix-framework.
the class FilterDelegateImpl method createParamEditor.
protected ParamEditor createParamEditor(final AbstractCondition condition, FilterDataContext filterDataContext) {
boolean conditionRemoveEnabled = !initialConditions.contains(condition);
ParamEditor paramEditor = new ParamEditor(condition, filterDataContext, conditionRemoveEnabled, isParamEditorOperationEditable());
AbstractAction removeConditionAction = new AbstractAction("") {
@Override
public void actionPerform(Component component) {
conditions.removeCondition(condition);
fillConditionsLayout(ConditionsFocusType.NONE);
updateFilterModifiedIndicator();
applyWithImmediateMode();
}
};
removeConditionAction.setVisible(conditionRemoveEnabled);
paramEditor.setRemoveButtonAction(removeConditionAction);
return paramEditor;
}
Aggregations