Search in sources :

Example 1 with DialogAction

use of com.haulmont.cuba.gui.components.DialogAction in project cuba by cuba-platform.

the class SessionLogBrowser method enableLogging.

public void enableLogging() {
    if (globalConfig.getUserSessionLogEnabled()) {
        showOptionDialog(getMessage("dialogs.Confirmation"), getMessage("confirmDisable"), MessageType.CONFIRMATION, new Action[] { new DialogAction(DialogAction.Type.YES, true).withHandler(actionPerformedEvent -> {
            globalConfig.setUserSessionLogEnabled(false);
            enableBtn.setCaption(getMessage("enableLogging"));
        }), new DialogAction(DialogAction.Type.NO) });
    } else {
        globalConfig.setUserSessionLogEnabled(true);
        enableBtn.setCaption(getMessage("disableLogging"));
    }
}
Also used : Inject(javax.inject.Inject) GlobalConfig(com.haulmont.cuba.core.global.GlobalConfig) AbstractLookup(com.haulmont.cuba.gui.components.AbstractLookup) Map(java.util.Map) Button(com.haulmont.cuba.gui.components.Button) DialogAction(com.haulmont.cuba.gui.components.DialogAction) Action(com.haulmont.cuba.gui.components.Action) DialogAction(com.haulmont.cuba.gui.components.DialogAction)

Example 2 with DialogAction

use of com.haulmont.cuba.gui.components.DialogAction 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();");
        }) });
    }
}
Also used : App(com.haulmont.cuba.web.App) LoadContext(com.haulmont.cuba.core.global.LoadContext) Frame(com.haulmont.cuba.gui.components.Frame) JavaScript(com.vaadin.ui.JavaScript) Ordered(org.springframework.core.Ordered) StringUtils(org.apache.commons.lang.StringUtils) Logger(org.slf4j.Logger) Resource(javax.annotation.Resource) DoNotChangeSubstUserAction(com.haulmont.cuba.web.actions.DoNotChangeSubstUserAction) App(com.haulmont.cuba.web.App) Messages(com.haulmont.cuba.core.global.Messages) UUID(java.util.UUID) User(com.haulmont.cuba.security.entity.User) UserSession(com.haulmont.cuba.security.global.UserSession) Inject(javax.inject.Inject) List(java.util.List) Page(com.vaadin.server.Page) TimeSource(com.haulmont.cuba.core.global.TimeSource) DialogAction(com.haulmont.cuba.gui.components.DialogAction) UserSubstitution(com.haulmont.cuba.security.entity.UserSubstitution) ChangeSubstUserAction(com.haulmont.cuba.web.actions.ChangeSubstUserAction) Component(com.haulmont.cuba.gui.components.Component) DataService(com.haulmont.cuba.core.app.DataService) Action(com.haulmont.cuba.gui.components.Action) DoNotChangeSubstUserAction(com.haulmont.cuba.web.actions.DoNotChangeSubstUserAction) ChangeSubstUserAction(com.haulmont.cuba.web.actions.ChangeSubstUserAction) User(com.haulmont.cuba.security.entity.User) DialogAction(com.haulmont.cuba.gui.components.DialogAction) UserSession(com.haulmont.cuba.security.global.UserSession) JavaScript(com.vaadin.ui.JavaScript) DoNotChangeSubstUserAction(com.haulmont.cuba.web.actions.DoNotChangeSubstUserAction) Component(com.haulmont.cuba.gui.components.Component)

Aggregations

Action (com.haulmont.cuba.gui.components.Action)2 DialogAction (com.haulmont.cuba.gui.components.DialogAction)2 Inject (javax.inject.Inject)2 DataService (com.haulmont.cuba.core.app.DataService)1 GlobalConfig (com.haulmont.cuba.core.global.GlobalConfig)1 LoadContext (com.haulmont.cuba.core.global.LoadContext)1 Messages (com.haulmont.cuba.core.global.Messages)1 TimeSource (com.haulmont.cuba.core.global.TimeSource)1 AbstractLookup (com.haulmont.cuba.gui.components.AbstractLookup)1 Button (com.haulmont.cuba.gui.components.Button)1 Component (com.haulmont.cuba.gui.components.Component)1 Frame (com.haulmont.cuba.gui.components.Frame)1 User (com.haulmont.cuba.security.entity.User)1 UserSubstitution (com.haulmont.cuba.security.entity.UserSubstitution)1 UserSession (com.haulmont.cuba.security.global.UserSession)1 App (com.haulmont.cuba.web.App)1 ChangeSubstUserAction (com.haulmont.cuba.web.actions.ChangeSubstUserAction)1 DoNotChangeSubstUserAction (com.haulmont.cuba.web.actions.DoNotChangeSubstUserAction)1 Page (com.vaadin.server.Page)1 JavaScript (com.vaadin.ui.JavaScript)1