Search in sources :

Example 1 with AppUI

use of com.haulmont.cuba.web.AppUI in project cuba by cuba-platform.

the class DefaultExceptionHandler method showDialog.

protected void showDialog(App app, Throwable exception) {
    Throwable rootCause = ExceptionUtils.getRootCause(exception);
    if (rootCause == null) {
        rootCause = exception;
    }
    ExceptionDialog dialog = new ExceptionDialog(rootCause);
    AppUI ui = app.getAppUI();
    for (Window window : ui.getWindows()) {
        if (window.isModal()) {
            dialog.setModal(true);
            break;
        }
    }
    ui.addWindow(dialog);
    dialog.focus();
}
Also used : Window(com.vaadin.ui.Window) AppUI(com.haulmont.cuba.web.AppUI)

Example 2 with AppUI

use of com.haulmont.cuba.web.AppUI 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)

Example 3 with AppUI

use of com.haulmont.cuba.web.AppUI in project cuba by cuba-platform.

the class WindowBreadCrumbs method update.

public void update() {
    AppUI ui = AppUI.getCurrent();
    boolean isTestMode = ui.isTestMode();
    linksLayout.removeAllComponents();
    btn2win.clear();
    for (Iterator<Window> it = windows.iterator(); it.hasNext(); ) {
        Window window = it.next();
        Button button = new CubaButton(StringUtils.trimToEmpty(window.getCaption()), new BtnClickListener());
        button.setSizeUndefined();
        button.setStyleName(BaseTheme.BUTTON_LINK);
        button.setTabIndex(-1);
        if (isTestMode) {
            button.setCubaId("breadCrubms_Button_" + window.getId());
            button.setId(ui.getTestIdManager().getTestId("breadCrubms_Button_" + window.getId()));
        }
        btn2win.put(button, window);
        if (it.hasNext()) {
            linksLayout.addComponent(button);
            Label separatorLab = new Label("&nbsp;&gt;&nbsp;");
            separatorLab.setStyleName("c-breadcrumbs-separator");
            separatorLab.setSizeUndefined();
            separatorLab.setContentMode(ContentMode.HTML);
            linksLayout.addComponent(separatorLab);
        } else {
            Label captionLabel = new Label(window.getCaption());
            captionLabel.setStyleName("c-breadcrumbs-win-caption");
            captionLabel.setSizeUndefined();
            linksLayout.addComponent(captionLabel);
            this.label = captionLabel;
        }
    }
}
Also used : Window(com.haulmont.cuba.gui.components.Window) WebWindow(com.haulmont.cuba.web.gui.WebWindow) CubaButton(com.haulmont.cuba.web.toolkit.ui.CubaButton) Button(com.vaadin.ui.Button) CubaButton(com.haulmont.cuba.web.toolkit.ui.CubaButton) Label(com.vaadin.ui.Label) AppUI(com.haulmont.cuba.web.AppUI)

Example 4 with AppUI

use of com.haulmont.cuba.web.AppUI in project cuba by cuba-platform.

the class WebWindow method stopTimers.

/**
 * Completely stop and remove timers of the window.
 */
public void stopTimers() {
    AppUI appUI = AppUI.getCurrent();
    if (timers != null) {
        for (Timer timer : timers) {
            timer.stop();
            WebTimer webTimer = (WebTimer) timer;
            appUI.removeTimer(webTimer.getTimerImpl());
        }
        timers.clear();
    }
}
Also used : Timer(com.haulmont.cuba.gui.components.Timer) AppUI(com.haulmont.cuba.web.AppUI)

Example 5 with AppUI

use of com.haulmont.cuba.web.AppUI in project cuba by cuba-platform.

the class WebAbstractComponent method assignAutoDebugId.

public void assignAutoDebugId() {
    AppUI ui = AppUI.getCurrent();
    if (ui != null && ui.isTestMode()) {
        String alternativeDebugId = getAlternativeDebugId();
        // always change cuba id, do not assign auto id for components
        if (getId() == null && component != null) {
            component.setCubaId(alternativeDebugId);
        }
        if (frame == null || StringUtils.isEmpty(frame.getId()))
            return;
        String fullFrameId = ComponentsHelper.getFullFrameId(frame);
        TestIdManager testIdManager = ui.getTestIdManager();
        String candidateId = fullFrameId + "." + alternativeDebugId;
        if (getDebugId() != null) {
            String postfix = StringUtils.replace(getDebugId(), testIdManager.normalize(candidateId), "");
            if (StringUtils.isEmpty(postfix) || NumberUtils.isDigits(postfix)) {
                // do not assign new Id
                return;
            }
        }
        setDebugId(testIdManager.getTestId(candidateId));
    }
}
Also used : TestIdManager(com.haulmont.cuba.gui.TestIdManager) AppUI(com.haulmont.cuba.web.AppUI)

Aggregations

AppUI (com.haulmont.cuba.web.AppUI)19 TestIdManager (com.haulmont.cuba.gui.TestIdManager)3 AggregationContainer (com.haulmont.cuba.web.toolkit.data.AggregationContainer)2 Label (com.vaadin.ui.Label)2 MetaProperty (com.haulmont.chile.core.model.MetaProperty)1 ClientConfig (com.haulmont.cuba.client.ClientConfig)1 Configuration (com.haulmont.cuba.core.global.Configuration)1 Messages (com.haulmont.cuba.core.global.Messages)1 Timer (com.haulmont.cuba.gui.components.Timer)1 Window (com.haulmont.cuba.gui.components.Window)1 CollectionFormatter (com.haulmont.cuba.gui.components.formatters.CollectionFormatter)1 Icons (com.haulmont.cuba.gui.icons.Icons)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 WebWindow (com.haulmont.cuba.web.gui.WebWindow)1 WebButton (com.haulmont.cuba.web.gui.components.WebButton)1 SortableDataGridIndexedCollectionDsWrapper (com.haulmont.cuba.web.gui.data.SortableDataGridIndexedCollectionDsWrapper)1 CubaButton (com.haulmont.cuba.web.toolkit.ui.CubaButton)1 CubaComboBox (com.haulmont.cuba.web.toolkit.ui.CubaComboBox)1