use of com.haulmont.cuba.gui.components.actions.BaseAction in project cuba by cuba-platform.
the class WebWindow method close.
@Override
public boolean close(final String actionId) {
if (!forceClose) {
if (!delegate.preClose(actionId))
return false;
}
if (closing) {
return true;
}
Configuration configuration = AppBeans.get(Configuration.NAME);
ClientConfig clientConfig = configuration.getConfig(ClientConfig.class);
if (!forceClose && isModified()) {
final Committable committable = (getWrapper() instanceof Committable) ? (Committable) getWrapper() : (this instanceof Committable) ? (Committable) this : null;
if ((committable != null) && clientConfig.getUseSaveConfirmation()) {
windowManager.showOptionDialog(messages.getMainMessage("closeUnsaved.caption"), messages.getMainMessage("saveUnsaved"), MessageType.WARNING, new Action[] { new DialogAction(Type.OK, Status.PRIMARY).withCaption(messages.getMainMessage("closeUnsaved.save")).withHandler(event -> {
committable.commitAndClose();
}), new BaseAction("discard").withIcon(icons.get(CubaIcon.DIALOG_CANCEL)).withCaption(messages.getMainMessage("closeUnsaved.discard")).withHandler(event -> {
committable.close(actionId, true);
}), new DialogAction(Type.CANCEL).withIcon(null).withHandler(event -> {
doAfterClose = null;
// try to move focus back
findAndFocusChildComponent();
}) });
} else {
windowManager.showOptionDialog(messages.getMainMessage("closeUnsaved.caption"), messages.getMainMessage("closeUnsaved"), MessageType.WARNING, new Action[] { new DialogAction(Type.YES).withHandler(event -> getWrapper().close(actionId, true)), new DialogAction(Type.NO, Status.PRIMARY).withHandler(event -> {
doAfterClose = null;
// try to move focus back
findAndFocusChildComponent();
}) });
}
closing = false;
return false;
}
if (!clientConfig.getManualScreenSettingsSaving()) {
if (getWrapper() != null) {
getWrapper().saveSettings();
} else {
saveSettings();
}
}
delegate.disposeComponents();
windowManager.close(this);
boolean res = onClose(actionId);
if (res && doAfterClose != null) {
doAfterClose.run();
}
closing = res;
return res;
}
Aggregations