Search in sources :

Example 51 with Component

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);
}
Also used : PopupButton(io.jmix.ui.component.PopupButton) HBoxLayout(io.jmix.ui.component.HBoxLayout) Label(io.jmix.ui.component.Label) ListComponent(com.haulmont.cuba.gui.components.ListComponent) Component(io.jmix.ui.component.Component) AbstractAction(io.jmix.ui.action.AbstractAction)

Example 52 with Component

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());
}
Also used : Node(io.jmix.core.common.datastruct.Node) ListComponent(com.haulmont.cuba.gui.components.ListComponent) Component(io.jmix.ui.component.Component)

Example 53 with Component

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();
        }
    });
}
Also used : Datasource(com.haulmont.cuba.gui.data.Datasource) AbstractDatasource(com.haulmont.cuba.gui.data.impl.AbstractDatasource) CollectionDatasource(com.haulmont.cuba.gui.data.CollectionDatasource) Entity(io.jmix.core.Entity) CollectionDatasource(com.haulmont.cuba.gui.data.CollectionDatasource) EditAction(com.haulmont.cuba.gui.components.actions.EditAction) Component(io.jmix.ui.component.Component)

Example 54 with Component

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;
}
Also used : Component(io.jmix.ui.component.Component)

Example 55 with Component

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));
                }
            });
        }
    }
}
Also used : Datasource(com.haulmont.cuba.gui.data.Datasource) PropertyDatasource(com.haulmont.cuba.gui.data.PropertyDatasource) CollectionDatasource(com.haulmont.cuba.gui.data.CollectionDatasource) MetaClass(io.jmix.core.metamodel.model.MetaClass) java.util(java.util) Datasource(com.haulmont.cuba.gui.data.Datasource) UiComponentProperties(io.jmix.ui.UiComponentProperties) Security(com.haulmont.cuba.core.global.Security) ParamsMap(io.jmix.core.common.util.ParamsMap) AppBeans(com.haulmont.cuba.core.global.AppBeans) Supplier(java.util.function.Supplier) Scope(org.springframework.context.annotation.Scope) Messages(io.jmix.core.Messages) EntityOp(io.jmix.core.security.EntityOp) WindowConfig(io.jmix.ui.WindowConfig) Component(io.jmix.ui.component.Component) Icons(io.jmix.ui.icon.Icons) Action(io.jmix.ui.action.Action) com.haulmont.cuba.gui.components(com.haulmont.cuba.gui.components) OpenType(com.haulmont.cuba.gui.WindowManager.OpenType) LegacyFrame(com.haulmont.cuba.gui.screen.compatibility.LegacyFrame) PropertyDatasource(com.haulmont.cuba.gui.data.PropertyDatasource) JmixIcon(io.jmix.ui.icon.JmixIcon) Consumer(java.util.function.Consumer) EntityDataUnit(io.jmix.ui.component.data.meta.EntityDataUnit) Entity(io.jmix.core.Entity) MetaProperty(io.jmix.core.metamodel.model.MetaProperty) CollectionDatasource(com.haulmont.cuba.gui.data.CollectionDatasource) CollectionDatasource(com.haulmont.cuba.gui.data.CollectionDatasource) LegacyFrame(com.haulmont.cuba.gui.screen.compatibility.LegacyFrame) Security(com.haulmont.cuba.core.global.Security) Consumer(java.util.function.Consumer) PropertyDatasource(com.haulmont.cuba.gui.data.PropertyDatasource) MetaProperty(io.jmix.core.metamodel.model.MetaProperty) Component(io.jmix.ui.component.Component) ParamsMap(io.jmix.core.common.util.ParamsMap)

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