Search in sources :

Example 1 with JavaScript

use of com.vaadin.ui.JavaScript in project VaadinUtils by rlsutton1.

the class JSCallWithReturnValue method removeHooks.

void removeHooks(final String hook1, final String hook2) {
    final JavaScript js = JavaScript.getCurrent();
    js.removeFunction(hook1);
    js.removeFunction(hook2);
}
Also used : JavaScript(com.vaadin.ui.JavaScript)

Example 2 with JavaScript

use of com.vaadin.ui.JavaScript 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

JavaScript (com.vaadin.ui.JavaScript)2 DataService (com.haulmont.cuba.core.app.DataService)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 Action (com.haulmont.cuba.gui.components.Action)1 Component (com.haulmont.cuba.gui.components.Component)1 DialogAction (com.haulmont.cuba.gui.components.DialogAction)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 List (java.util.List)1 UUID (java.util.UUID)1 Resource (javax.annotation.Resource)1 Inject (javax.inject.Inject)1