use of io.jmix.ui.component.BoxLayout in project jmix by jmix-framework.
the class CustomOperationEditor method createComponent.
@Override
protected Component createComponent() {
ComponentsFactory componentsFactory = AppBeans.get(ComponentsFactory.class);
BoxLayout layout = componentsFactory.createComponent(VBoxLayout.class);
return layout;
}
use of io.jmix.ui.component.BoxLayout 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.BoxLayout in project jmix by jmix-framework.
the class FilterDelegateImpl method addAppliedFilter.
protected void addAppliedFilter() {
if (lastAppliedFilter == null)
return;
if (!appliedFilters.isEmpty() && appliedFilters.getLast().filter.equals(lastAppliedFilter))
return;
this.layout.add(appliedFiltersLayout, CONDITIONS_LOCATION_TOP.equals(conditionsLocation) ? 0 : 1);
BoxLayout layout = uiComponents.create(HBoxLayout.class);
layout.setSpacing(true);
if (!appliedFilters.isEmpty()) {
AppliedFilterHolder holder = appliedFilters.getLast();
holder.layout.remove(holder.button);
}
Label<String> label = uiComponents.create(Label.NAME);
label.setValue(lastAppliedFilter.getText());
layout.add(label);
label.setAlignment(Alignment.MIDDLE_LEFT);
LinkButton button = uiComponents.create(LinkButton.class);
button.setIconFromSet(JmixIcon.TIMES);
button.addClickListener(e -> removeAppliedFilter());
layout.add(button);
addAppliedFilterLayoutHook(layout);
appliedFiltersLayout.add(layout);
appliedFilters.add(new AppliedFilterHolder(lastAppliedFilter, layout, button));
}
use of io.jmix.ui.component.BoxLayout 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.BoxLayout in project jmix by jmix-framework.
the class FileMultiUploadFieldLoader 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));
}
}
Aggregations