use of com.haulmont.cuba.web.actions.ChangeSubstUserAction in project cuba by cuba-platform.
the class UserSwitchLinkHandlerProcessor method substituteUserAndOpenWindow.
protected void substituteUserAndOpenWindow(ExternalLinkContext linkContext, UUID userId) {
App app = linkContext.getApp();
UserSession userSession = app.getConnection().getSession();
assert userSession != null;
final User substitutedUser = loadUser(userId, userSession.getUser());
if (substitutedUser != null) {
app.getWindowManager().showOptionDialog(messages.getMainMessage("toSubstitutedUser.title"), getDialogMessage(substitutedUser), Frame.MessageType.CONFIRMATION_HTML, new Action[] { new ChangeSubstUserAction(substitutedUser) {
@Override
public void doAfterChangeUser() {
super.doAfterChangeUser();
screenHandler.handle(linkContext);
}
@Override
public void doRevert() {
super.doRevert();
JavaScript js = Page.getCurrent().getJavaScript();
js.execute("window.close();");
}
@Override
public String getCaption() {
return messages.getMainMessage("action.switch");
}
}, new DoNotChangeSubstUserAction() {
@Override
public void actionPerform(Component component) {
super.actionPerform(component);
JavaScript js = Page.getCurrent().getJavaScript();
js.execute("window.close();");
}
@Override
public String getCaption() {
return messages.getMainMessage("action.cancel");
}
} });
} else {
User user = loadUser(userId);
app.getWindowManager().showOptionDialog(messages.getMainMessage("warning.title"), getWarningMessage(user), Frame.MessageType.WARNING_HTML, new Action[] { new DialogAction(DialogAction.Type.OK).withHandler(event -> {
JavaScript js = Page.getCurrent().getJavaScript();
js.execute("window.close();");
}) });
}
}
Aggregations