Search in sources :

Example 6 with BaseAction

use of io.jmix.ui.action.BaseAction in project jmix by jmix-framework.

the class AbstractEditor method initCommitActions.

protected void initCommitActions(@SuppressWarnings("unused") InitEvent event) {
    Component commitAndCloseButton = ComponentsHelper.findComponent(getFrame(), WINDOW_COMMIT_AND_CLOSE);
    UiScreenProperties screenProperties = getApplicationContext().getBean(UiScreenProperties.class);
    boolean commitAndCloseButtonExists = false;
    String commitShortcut = screenProperties.getCommitShortcut();
    if (commitAndCloseButton != null) {
        commitAndCloseButtonExists = true;
        getFrame().addAction(new BaseAction(WINDOW_COMMIT_AND_CLOSE).withCaption(messages.getMessage("actions.SaveClose")).withPrimary(true).withShortcut(commitShortcut).withHandler(e -> commitAndClose()));
    }
    boolean finalCommitAndCloseButtonExists = commitAndCloseButtonExists;
    Action commitAction = new BaseAction(WINDOW_COMMIT).withCaption(messages.getMessage(commitAndCloseButtonExists ? "actions.Save" : "actions.Ok")).withPrimary(!commitAndCloseButtonExists).withShortcut(commitAndCloseButtonExists ? null : commitShortcut).withHandler(e -> {
        if (!finalCommitAndCloseButtonExists) {
            commitAndClose();
        } else {
            if (commit()) {
                commitActionPerformed = true;
            }
        }
    });
    getFrame().addAction(commitAction);
    Action closeAction = new BaseAction(WINDOW_CLOSE).withCaption(messages.getMessage("actions.Cancel")).withHandler(e -> close(commitActionPerformed ? Window.COMMIT_ACTION_ID : getId()));
    getFrame().addAction(closeAction);
    Action enableEditingAction = new BaseAction(ENABLE_EDITING).withCaption(messages.getMessage("actions.EnableEditing")).withHandler(e -> setReadOnly(false));
    enableEditingAction.setVisible(false);
    getFrame().addAction(enableEditingAction);
}
Also used : Iterables(com.google.common.collect.Iterables) EntityAccessException(io.jmix.core.EntityAccessException) MetaClass(io.jmix.core.metamodel.model.MetaClass) DynamicAttributesGuiTools(com.haulmont.cuba.gui.dynamicattributes.DynamicAttributesGuiTools) Security(com.haulmont.cuba.core.global.Security) Date(java.util.Date) ValidationErrors(io.jmix.ui.component.ValidationErrors) Autowired(org.springframework.beans.factory.annotation.Autowired) StringUtils(org.apache.commons.lang3.StringUtils) EntityValues(io.jmix.core.entity.EntityValues) Metadata(com.haulmont.cuba.core.global.Metadata) EntityOp(io.jmix.core.security.EntityOp) DatasourceImplementation(com.haulmont.cuba.gui.data.impl.DatasourceImplementation) Categorized(io.jmix.dynattr.model.Categorized) Component(io.jmix.ui.component.Component) DsContextImplementation(com.haulmont.cuba.gui.data.impl.DsContextImplementation) com.haulmont.cuba.gui.data(com.haulmont.cuba.gui.data) PersistenceHelper(com.haulmont.cuba.core.global.PersistenceHelper) Action(io.jmix.ui.action.Action) BaseAction(io.jmix.ui.action.BaseAction) UiCrossFieldChecks(io.jmix.core.validation.group.UiCrossFieldChecks) MetadataTools(io.jmix.core.MetadataTools) ConstraintViolation(javax.validation.ConstraintViolation) Window(io.jmix.ui.component.Window) Nullable(javax.annotation.Nullable) LockService(com.haulmont.cuba.core.app.LockService) LockNotSupported(io.jmix.core.pessimisticlocking.LockNotSupported) Collection(java.util.Collection) EntityCopyUtils(com.haulmont.cuba.gui.data.impl.EntityCopyUtils) Datatypes(com.haulmont.chile.core.datatypes.Datatypes) Validator(javax.validation.Validator) Set(java.util.Set) UserSessionSource(com.haulmont.cuba.core.global.UserSessionSource) CollectionPropertyDatasourceImpl(com.haulmont.cuba.gui.data.impl.CollectionPropertyDatasourceImpl) WindowParams(com.haulmont.cuba.gui.WindowParams) GuiDevelopmentException(io.jmix.ui.GuiDevelopmentException) LockInfo(io.jmix.core.pessimisticlocking.LockInfo) ReadOnlyScreensSupport(io.jmix.ui.screen.ReadOnlyScreensSupport) EntityStates(io.jmix.core.EntityStates) Entity(io.jmix.core.Entity) Element(org.dom4j.Element) ReadOnlyAwareScreen(io.jmix.ui.screen.ReadOnlyAwareScreen) ElementKind(javax.validation.ElementKind) MetaProperty(io.jmix.core.metamodel.model.MetaProperty) OperationResult(io.jmix.ui.util.OperationResult) UiScreenProperties(io.jmix.ui.UiScreenProperties) ComponentsHelper(io.jmix.ui.component.ComponentsHelper) Action(io.jmix.ui.action.Action) BaseAction(io.jmix.ui.action.BaseAction) UiScreenProperties(io.jmix.ui.UiScreenProperties) BaseAction(io.jmix.ui.action.BaseAction) Component(io.jmix.ui.component.Component)

Example 7 with BaseAction

use of io.jmix.ui.action.BaseAction in project jmix by jmix-framework.

the class AttributeComponentProvider method addRow.

protected void addRow(Object value, ComponentContainer parent, boolean isReadOnly) {
    BoxLayout row = uiComponents.create(HBoxLayout.class);
    row.setSpacing(true);
    row.setWidthFull();
    TextField valueField = uiComponents.create(TextField.class);
    valueField.setValue(value);
    valueField.setEditable(!isReadOnly);
    row.add(valueField);
    row.expand(valueField);
    Button btnRemove = uiComponents.create(Button.class);
    btnRemove.setIconFromSet(JmixIcon.TIMES);
    btnRemove.setDescription(messages.getMessage(getClass(), "editAttribute.array.btnRemove"));
    Action removeRowAction = new BaseAction("removeRow").withCaption("").withHandler(actionPerformedEvent -> parent.remove(row));
    removeRowAction.setEnabled(!isReadOnly);
    btnRemove.setAction(removeRowAction);
    row.add(btnRemove);
    parent.add(row);
}
Also used : AbstractAction(io.jmix.ui.action.AbstractAction) Action(io.jmix.ui.action.Action) BaseAction(io.jmix.ui.action.BaseAction) BaseAction(io.jmix.ui.action.BaseAction)

Example 8 with BaseAction

use of io.jmix.ui.action.BaseAction in project jmix by jmix-framework.

the class SelectValueDialog method createEntityPicker.

protected Field createEntityPicker(MetaClass metaClass) {
    EntityPicker<Object> entityPicker = uiComponents.create(EntityPicker.NAME);
    entityPicker.setMetaClass(metaClass);
    Actions actions = getApplicationContext().getBean(Actions.class);
    BaseAction lookupAction = (BaseAction) actions.create(EntityLookupAction.ID);
    lookupAction.addActionPerformedListener(this::lookupActionPerformed);
    entityPicker.addAction(lookupAction);
    return entityPicker;
}
Also used : Actions(io.jmix.ui.Actions) BaseAction(io.jmix.ui.action.BaseAction)

Example 9 with BaseAction

use of io.jmix.ui.action.BaseAction in project jmix by jmix-framework.

the class ScreensImpl method checkModificationsAndCloseAll.

/**
 * Check modifications and close all screens in all main windows excluding root screens.
 *
 * @return operation result
 */
public OperationResult checkModificationsAndCloseAll() {
    if (hasUnsavedChanges()) {
        UnknownOperationResult result = new UnknownOperationResult();
        ui.getDialogs().createOptionDialog().withCaption(messages.getMessage("closeUnsaved.caption")).withMessage(messages.getMessage("discardChangesOnClose")).withActions(new BaseAction("closeApplication").withCaption(messages.getMessage("closeApplication")).withIcon(icons.get(JmixIcon.DIALOG_OK)).withHandler(event -> {
            ui.getApp().closeWindowsInternal(true);
            result.success();
        }), new DialogAction(DialogAction.Type.CANCEL, Action.Status.PRIMARY).withHandler(event -> result.fail())).show();
        return result;
    } else {
        ui.getApp().closeWindowsInternal(true);
        return OperationResult.success();
    }
}
Also used : DialogAction(io.jmix.ui.action.DialogAction) UnknownOperationResult(io.jmix.ui.util.UnknownOperationResult) BaseAction(io.jmix.ui.action.BaseAction)

Example 10 with BaseAction

use of io.jmix.ui.action.BaseAction in project jmix by jmix-framework.

the class SearchFieldImpl method initActions.

protected void initActions() {
    removeAllActions();
    BaseAction searchAction = new BaseAction("search").withHandler(actionPerformedEvent -> performSearch()).withIcon(JmixIcon.SEARCH.source()).withShortcut("ENTER");
    addAction(searchAction);
}
Also used : BaseAction(io.jmix.ui.action.BaseAction)

Aggregations

BaseAction (io.jmix.ui.action.BaseAction)49 Action (io.jmix.ui.action.Action)30 Autowired (org.springframework.beans.factory.annotation.Autowired)12 Icons (io.jmix.ui.icon.Icons)11 io.jmix.ui.screen (io.jmix.ui.screen)9 DialogAction (io.jmix.ui.action.DialogAction)8 Window (io.jmix.ui.component.Window)8 UiScreenProperties (io.jmix.ui.UiScreenProperties)7 io.jmix.ui.component (io.jmix.ui.component)7 JmixIcon (io.jmix.ui.icon.JmixIcon)7 GuiDevelopmentException (io.jmix.ui.GuiDevelopmentException)6 Notifications (io.jmix.ui.Notifications)6 Component (io.jmix.ui.component.Component)6 Collection (java.util.Collection)6 Messages (io.jmix.core.Messages)5 UiComponents (io.jmix.ui.UiComponents)5 Nullable (javax.annotation.Nullable)5 Strings (com.google.common.base.Strings)4 Dialogs (io.jmix.ui.Dialogs)4 ItemTrackingAction (io.jmix.ui.action.ItemTrackingAction)4