Search in sources :

Example 1 with CubaLabel

use of com.haulmont.cuba.web.toolkit.ui.CubaLabel in project cuba by cuba-platform.

the class NoUserSessionHandler method showNoUserSessionDialog.

protected void showNoUserSessionDialog(App app) {
    Messages messages = AppBeans.get(Messages.NAME);
    Window dialog = new NoUserSessionExceptionDialog();
    dialog.setStyleName("c-nousersession-dialog");
    dialog.setCaption(messages.getMainMessage("dialogs.Information", locale));
    dialog.setClosable(false);
    dialog.setResizable(false);
    dialog.setModal(true);
    AppUI ui = app.getAppUI();
    if (ui.isTestMode()) {
        dialog.setCubaId("optionDialog");
        dialog.setId(ui.getTestIdManager().getTestId("optionDialog"));
    }
    Label messageLab = new CubaLabel();
    messageLab.setWidthUndefined();
    messageLab.setValue(messages.getMainMessage("noUserSession.message", locale));
    VerticalLayout layout = new VerticalLayout();
    layout.setSpacing(true);
    layout.setWidthUndefined();
    layout.setStyleName("c-nousersession-dialog-layout");
    layout.setSpacing(true);
    dialog.setContent(layout);
    Button reloginBtn = new Button();
    if (ui.isTestMode()) {
        reloginBtn.setCubaId("reloginBtn");
        reloginBtn.setId(ui.getTestIdManager().getTestId("reloginBtn"));
    }
    reloginBtn.addStyleName(WebButton.ICON_STYLE);
    reloginBtn.addStyleName("c-primary-action");
    reloginBtn.addClickListener(event -> relogin());
    reloginBtn.setCaption(messages.getMainMessage(Type.OK.getMsgKey()));
    String iconName = AppBeans.get(Icons.class).get(Type.OK.getIconKey());
    reloginBtn.setIcon(AppBeans.get(IconResolver.class).getIconResource(iconName));
    ClientConfig clientConfig = AppBeans.get(Configuration.class).getConfig(ClientConfig.class);
    setClickShortcut(reloginBtn, clientConfig.getCommitShortcut());
    reloginBtn.focus();
    layout.addComponent(messageLab);
    layout.addComponent(reloginBtn);
    layout.setComponentAlignment(reloginBtn, Alignment.BOTTOM_RIGHT);
    ui.addWindow(dialog);
    dialog.center();
}
Also used : CubaWindow(com.haulmont.cuba.web.toolkit.ui.CubaWindow) Messages(com.haulmont.cuba.core.global.Messages) CubaLabel(com.haulmont.cuba.web.toolkit.ui.CubaLabel) Configuration(com.haulmont.cuba.core.global.Configuration) WebButton(com.haulmont.cuba.web.gui.components.WebButton) CubaLabel(com.haulmont.cuba.web.toolkit.ui.CubaLabel) Icons(com.haulmont.cuba.gui.icons.Icons) ClientConfig(com.haulmont.cuba.client.ClientConfig) AppUI(com.haulmont.cuba.web.AppUI)

Aggregations

ClientConfig (com.haulmont.cuba.client.ClientConfig)1 Configuration (com.haulmont.cuba.core.global.Configuration)1 Messages (com.haulmont.cuba.core.global.Messages)1 Icons (com.haulmont.cuba.gui.icons.Icons)1 AppUI (com.haulmont.cuba.web.AppUI)1 WebButton (com.haulmont.cuba.web.gui.components.WebButton)1 CubaLabel (com.haulmont.cuba.web.toolkit.ui.CubaLabel)1 CubaWindow (com.haulmont.cuba.web.toolkit.ui.CubaWindow)1