Search in sources :

Example 1 with UiScreenProperties

use of io.jmix.ui.UiScreenProperties 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 2 with UiScreenProperties

use of io.jmix.ui.UiScreenProperties in project jmix by jmix-framework.

the class ScriptEditorDialog method initAction.

protected void initAction() {
    Icons icons = getApplicationContext().getBean(Icons.class);
    UiScreenProperties screenProperties = getApplicationContext().getBean(UiScreenProperties.class);
    Action commitAction = new BaseAction("commit").withCaption(messages.getMessage("actions.Ok")).withIcon(icons.get(JmixIcon.OK)).withPrimary(true).withShortcut(screenProperties.getCommitShortcut()).withHandler(this::commit);
    getWindow().addAction(commitAction);
    Action cancelAction = new BaseAction("cancel").withCaption(messages.getMessage("actions.Cancel")).withIcon(icons.get(JmixIcon.CANCEL)).withShortcut(screenProperties.getCloseShortcut()).withHandler(this::cancel);
    getWindow().addAction(cancelAction);
}
Also used : Action(io.jmix.ui.action.Action) BaseAction(io.jmix.ui.action.BaseAction) UiScreenProperties(io.jmix.ui.UiScreenProperties) Icons(io.jmix.ui.icon.Icons) BaseAction(io.jmix.ui.action.BaseAction)

Aggregations

UiScreenProperties (io.jmix.ui.UiScreenProperties)2 Action (io.jmix.ui.action.Action)2 BaseAction (io.jmix.ui.action.BaseAction)2 Iterables (com.google.common.collect.Iterables)1 Datatypes (com.haulmont.chile.core.datatypes.Datatypes)1 LockService (com.haulmont.cuba.core.app.LockService)1 Metadata (com.haulmont.cuba.core.global.Metadata)1 PersistenceHelper (com.haulmont.cuba.core.global.PersistenceHelper)1 Security (com.haulmont.cuba.core.global.Security)1 UserSessionSource (com.haulmont.cuba.core.global.UserSessionSource)1 WindowParams (com.haulmont.cuba.gui.WindowParams)1 com.haulmont.cuba.gui.data (com.haulmont.cuba.gui.data)1 CollectionPropertyDatasourceImpl (com.haulmont.cuba.gui.data.impl.CollectionPropertyDatasourceImpl)1 DatasourceImplementation (com.haulmont.cuba.gui.data.impl.DatasourceImplementation)1 DsContextImplementation (com.haulmont.cuba.gui.data.impl.DsContextImplementation)1 EntityCopyUtils (com.haulmont.cuba.gui.data.impl.EntityCopyUtils)1 DynamicAttributesGuiTools (com.haulmont.cuba.gui.dynamicattributes.DynamicAttributesGuiTools)1 Entity (io.jmix.core.Entity)1 EntityAccessException (io.jmix.core.EntityAccessException)1 EntityStates (io.jmix.core.EntityStates)1