use of io.jmix.ui.component.Component in project jmix by jmix-framework.
the class FilterDelegateImpl method createControlsLayoutForFts.
protected void createControlsLayoutForFts() {
controlsLayout = uiComponents.create(HBoxLayout.class);
controlsLayout.setSpacing(true);
controlsLayout.setWidthFull();
ftsSearchCriteriaField = uiComponents.create(TextField.NAME);
ftsSearchCriteriaField.setWidth(theme.get("cuba.gui.filter.ftsSearchCriteriaField.width"));
ftsSearchCriteriaField.setInputPrompt(getMainMessage("filter.enterSearchPhrase"));
filterHelper.addShortcutListener(ftsSearchCriteriaField, createFtsSearchShortcutListener());
ftsSearchCriteriaField.addValueChangeListener(valueChangeEvent -> {
if (isApplyImmediately()) {
applyFts();
}
});
filterHelper.setInternalDebugId(ftsSearchCriteriaField, "ftsSearchCriteriaField");
paramEditComponentToFocus = ftsSearchCriteriaField;
controlsLayout.add(ftsSearchCriteriaField);
searchBtn = uiComponents.create(Button.class);
searchBtn.setCaption(getSearchBtnCaption());
searchBtn.setIconFromSet(JmixIcon.SEARCH);
searchBtn.setAction(new AbstractAction("search") {
@Override
public void actionPerform(Component component) {
applyFts();
}
});
controlsLayout.add(searchBtn);
controlsLayoutGap = uiComponents.create(Label.class);
controlsLayout.add(controlsLayoutGap);
controlsLayout.expand(controlsLayoutGap);
createMaxResultsLayout();
if (isMaxResultsLayoutVisible()) {
controlsLayout.add(maxResultsLayout);
initMaxResults();
}
createFtsSwitch();
ftsSwitch.setAlignment(Alignment.MIDDLE_RIGHT);
controlsLayout.add(ftsSwitch);
}
use of io.jmix.ui.component.Component in project jmix by jmix-framework.
the class FilterDelegateImpl method fillConditionsLayout.
/**
* Removes all components from conditionsLayout and fills it with components for editing filter conditions
*
* @param conditionsFocusType where to set focus (first condition, last condition, no focus)
*/
protected void fillConditionsLayout(ConditionsFocusType conditionsFocusType) {
for (Component component : conditionsLayout.getComponents()) {
conditionsLayout.remove(component);
}
paramEditComponentToFocus = null;
clearParamValueChangeSubscriptions();
clearParamEditors();
recursivelyCreateConditionsLayout(conditionsFocusType, false, conditions.getRootNodes(), conditionsLayout, 0);
if (isApplyImmediately()) {
List<Node<AbstractCondition>> nodes = conditions.getRootNodes();
subscribeToParamValueChangeEventRecursively(nodes);
}
conditionsLayout.setVisible(!conditionsLayout.getComponents().isEmpty());
}
use of io.jmix.ui.component.Component in project jmix by jmix-framework.
the class EntityCombinedScreen method initBrowseEditAction.
/**
* Adds an EditAction that enables controls for editing.
*/
protected void initBrowseEditAction() {
ListComponent table = getTable();
table.addAction(new EditAction(table) {
@Override
public void actionPerform(Component component) {
if (table.getSelected().size() == 1) {
if (lockIfNeeded((Entity) table.getSelected().iterator().next())) {
super.actionPerform(component);
}
}
}
@Override
protected void internalOpenEditor(CollectionDatasource datasource, Entity existingItem, Datasource parentDs, Map<String, Object> params) {
refreshOptionsForLookupFields();
enableEditControls(false);
}
@Override
public void refreshState() {
if (target != null) {
CollectionDatasource ds = target.getDatasource();
if (ds != null && !captionInitialized) {
setCaption(messages.getMainMessage("actions.Edit"));
}
}
super.refreshState();
}
@Override
protected boolean isPermitted() {
CollectionDatasource ownerDatasource = target.getDatasource();
boolean entityOpPermitted = security.isEntityOpPermitted(ownerDatasource.getMetaClass(), EntityOp.UPDATE);
if (!entityOpPermitted) {
return false;
}
return super.isPermitted();
}
});
}
use of io.jmix.ui.component.Component in project jmix by jmix-framework.
the class RuntimePropertiesFrame method createRuntimeFieldGroup.
protected FieldGroup createRuntimeFieldGroup(Datasource ds) {
Component runtime = getComponent("runtime");
if (runtime != null) {
remove(runtime);
}
FieldGroup newRuntimeFieldGroup = uiComponents.create(FieldGroup.class);
newRuntimeFieldGroup.setBorderVisible(Boolean.TRUE.equals(borderVisible));
newRuntimeFieldGroup.setWidth("100%");
newRuntimeFieldGroup.setId("runtime");
newRuntimeFieldGroup.setFrame(getFrame());
add(newRuntimeFieldGroup);
for (FieldGroup.FieldConfig field : newRuntimeFieldGroup.getFields()) {
newRuntimeFieldGroup.removeField(field);
}
List<FieldGroup.FieldConfig> fields = createFieldsForAttributes(newRuntimeFieldGroup);
addFieldsToFieldGroup(newRuntimeFieldGroup, fields);
if (!newRuntimeFieldGroup.getFields().isEmpty()) {
newRuntimeFieldGroup.setDatasource(ds);
newRuntimeFieldGroup.bind();
}
for (FieldGroup.FieldConfig fieldConfig : newRuntimeFieldGroup.getFields()) {
loadValidators(newRuntimeFieldGroup, fieldConfig);
loadRequired(newRuntimeFieldGroup, fieldConfig);
loadEditable(newRuntimeFieldGroup, fieldConfig);
}
initFieldCaptionWidth(newRuntimeFieldGroup);
return newRuntimeFieldGroup;
}
use of io.jmix.ui.component.Component in project jmix by jmix-framework.
the class EditAction method actionPerform.
/**
* This method is invoked by the action owner component.
*
* @param component component invoking the action
*/
@Override
public void actionPerform(Component component) {
if (beforeActionPerformedHandler != null) {
if (!beforeActionPerformedHandler.beforeActionPerformed())
return;
}
final Set selected = target.getSelected();
if (selected.size() == 1) {
Datasource parentDs = null;
final CollectionDatasource datasource = target.getDatasource();
if (datasource instanceof PropertyDatasource) {
MetaProperty metaProperty = ((PropertyDatasource) datasource).getProperty();
if (metaProperty.getType().equals(MetaProperty.Type.COMPOSITION)) {
parentDs = datasource;
}
}
Map<String, Object> params = prepareWindowParams();
internalOpenEditor(datasource, datasource.getItem(), parentDs, params);
} else if (selected.size() > 1 && bulkEditorIntegration.isEnabled()) {
Security security = AppBeans.get(Security.class);
boolean isBulkEditorPermitted = security.isSpecificPermitted(BulkEditor.PERMISSION);
if (isBulkEditorPermitted) {
// if bulk editor integration enabled and permitted for user
Map<String, Object> params = ParamsMap.of("metaClass", target.getDatasource().getMetaClass(), "selected", selected, "exclude", bulkEditorIntegration.getExcludePropertiesRegex(), "fieldValidators", bulkEditorIntegration.getFieldValidators(), "modelValidators", bulkEditorIntegration.getModelValidators());
LegacyFrame frameOwner = (LegacyFrame) target.getFrame().getFrameOwner();
Window bulkEditor = frameOwner.openWindow("bulkEditor", bulkEditorIntegration.getOpenType(), params);
bulkEditor.addCloseListener(actionId -> {
if (Window.COMMIT_ACTION_ID.equals(actionId)) {
target.getDatasource().refresh();
}
if (target instanceof Component.Focusable) {
((Component.Focusable) target).focus();
}
Consumer<BulkEditorCloseEvent> afterEditorCloseHandler = bulkEditorIntegration.getAfterEditorCloseHandler();
if (afterEditorCloseHandler != null) {
afterEditorCloseHandler.accept(new BulkEditorCloseEvent(this, bulkEditor, actionId));
}
});
}
}
}
Aggregations