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);
}
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);
}
Aggregations