use of io.jmix.ui.action.DialogAction in project jmix-docs by Haulmont.
the class OrderBrowse2 method onBeforeCommitChanges.
@Subscribe
public void onBeforeCommitChanges(BeforeCommitChangesEvent event) {
if (getEditedEntity().getNum() == null) {
dialogs.createOptionDialog().withCaption("Confirmation").withMessage("Number is empty. Do you want to commit?").withActions(new DialogAction(DialogAction.Type.OK).withHandler(e -> {
event.resume();
}), new DialogAction(DialogAction.Type.CANCEL)).show();
event.preventCommit();
}
}
use of io.jmix.ui.action.DialogAction in project jmix-docs by Haulmont.
the class OrderEdit3 method onBeforeCommitChanges.
@Subscribe
public void onBeforeCommitChanges(BeforeCommitChangesEvent event) {
if (getEditedEntity().getNum() == null) {
dialogs.createOptionDialog().withCaption("Confirmation").withMessage("Number is empty. Do you want to set default?").withActions(new DialogAction(DialogAction.Type.OK).withHandler(e -> {
getEditedEntity().setNum(DEFAULT_NUM);
event.resume(commitChanges());
}), new DialogAction(DialogAction.Type.CANCEL)).show();
event.preventCommit();
}
}
use of io.jmix.ui.action.DialogAction in project jmix-docs by Haulmont.
the class CustomerEdit method onBrandsTableExclude.
// end::exclude-action-cancelled-handler[]
// tag::exclude-action-performed-event[]
@Subscribe("brandsTable.exclude")
public void onBrandsTableExclude(Action.ActionPerformedEvent event) {
excludeAction.setConfirmation(false);
dialogs.createOptionDialog().withCaption("My confirm dialog").withMessage("Do you really want to remove the brand from the list?").withActions(new DialogAction(DialogAction.Type.YES).withHandler(// execute action
e -> excludeAction.execute()), new DialogAction(DialogAction.Type.NO)).show();
}
use of io.jmix.ui.action.DialogAction in project jmix by jmix-framework.
the class UserIndicatorImpl method substituteUser.
protected void substituteUser(HasValue.ValueChangeEvent<UserDetails> valueChangedEvent) {
UserDetails newUser = valueChangedEvent.getValue();
UserDetails prevUser = valueChangedEvent.getPrevValue();
if (newUser == null || prevUser == null) {
// should not happen
return;
}
if (currentUserSubstitution.getEffectiveUser().equals(newUser)) {
return;
}
SubstituteUserAction substituteUserAction = new SubstituteUserAction(newUser, prevUser, messages, icons, substitutionManager).withCancelAction(this::revertSelection);
substituteUserAction.setPrimary(true);
dialogs.createOptionDialog().withCaption(messages.getMessage("substitutionConfirmation.caption")).withMessage(messages.formatMessage("", "substitutionConfirmation.message", generateUserCaption(newUser))).withActions(substituteUserAction, new DialogAction(DialogAction.Type.CANCEL).withHandler(event -> revertSelection(prevUser))).show();
}
use of io.jmix.ui.action.DialogAction 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();
}
}
Aggregations