Search in sources :

Example 6 with AppUI

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

the class WebFieldGroup method assignDebugId.

protected void assignDebugId(FieldConfig fc, com.vaadin.ui.Field composition) {
    AppUI ui = AppUI.getCurrent();
    if (ui != null) {
        if (ui.isTestMode()) {
            String debugId = getDebugId();
            if (composition != null) {
                if (debugId != null) {
                    TestIdManager testIdManager = ui.getTestIdManager();
                    composition.setId(testIdManager.getTestId(debugId + "_" + fc.getId()));
                }
                composition.setCubaId(fc.getId());
            }
        }
    }
}
Also used : TestIdManager(com.haulmont.cuba.gui.TestIdManager) AppUI(com.haulmont.cuba.web.AppUI)

Example 7 with AppUI

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

the class WebLogoutButton method logout.

protected void logout() {
    AppUI ui = ((AppUI) component.getUI());
    if (ui == null) {
        throw new IllegalStateException("Logout button is not attached to UI");
    }
    ui.getApp().logout();
}
Also used : AppUI(com.haulmont.cuba.web.AppUI)

Example 8 with AppUI

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

the class WebUserIndicator method refreshUserSubstitutions.

@Override
public void refreshUserSubstitutions() {
    component.removeAllComponents();
    UserSessionSource uss = AppBeans.get(UserSessionSource.NAME);
    List<UserSubstitution> substitutions = getUserSubstitutions();
    User user = uss.getUserSession().getUser();
    AppUI ui = AppUI.getCurrent();
    String substitutedUserCaption = getSubstitutedUserCaption(user);
    if (substitutions.isEmpty()) {
        userComboBox = null;
        userNameLabel = new Label(substitutedUserCaption);
        userNameLabel.setStyleName("c-user-select-label");
        userNameLabel.setSizeUndefined();
        if (ui.isTestMode()) {
            userNameLabel.setCubaId("currentUserLabel");
        }
        component.addComponent(userNameLabel);
        component.setDescription(substitutedUserCaption);
    } else {
        userNameLabel = null;
        userComboBox = new CubaComboBox();
        userComboBox.setFilteringMode(FilteringMode.CONTAINS);
        userComboBox.setNullSelectionAllowed(false);
        userComboBox.setImmediate(true);
        if (ui.isTestMode()) {
            userComboBox.setCubaId("substitutedUserSelect");
            userComboBox.setId(ui.getTestIdManager().getTestId("substitutedUserSelect"));
        }
        userComboBox.setStyleName("c-user-select-combobox");
        userComboBox.addItem(user);
        userComboBox.setItemCaption(user, substitutedUserCaption);
        for (UserSubstitution substitution : substitutions) {
            User substitutedUser = substitution.getSubstitutedUser();
            userComboBox.addItem(substitutedUser);
            userComboBox.setItemCaption(substitutedUser, getSubstitutedUserCaption(substitutedUser));
        }
        UserSession session = uss.getUserSession();
        userComboBox.select(session.getSubstitutedUser() == null ? session.getUser() : session.getSubstitutedUser());
        userComboBox.addValueChangeListener(new SubstitutedUserChangeListener(userComboBox));
        component.addComponent(userComboBox);
        component.setDescription(null);
    }
    adjustWidth();
    adjustHeight();
}
Also used : User(com.haulmont.cuba.security.entity.User) CubaComboBox(com.haulmont.cuba.web.toolkit.ui.CubaComboBox) UserSession(com.haulmont.cuba.security.global.UserSession) Label(com.vaadin.ui.Label) UserSubstitution(com.haulmont.cuba.security.entity.UserSubstitution) AppUI(com.haulmont.cuba.web.AppUI)

Example 9 with AppUI

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

the class CubaTable method paintAdditionalData.

@Override
protected void paintAdditionalData(PaintTarget target) throws PaintException {
    if (reqFirstRowToPaint == -1) {
        boolean hasAggregation = items instanceof AggregationContainer && isAggregatable() && !((AggregationContainer) items).getAggregationPropertyIds().isEmpty();
        if (hasAggregation && isShowTotalAggregation() && Table.AggregationStyle.TOP.equals(getAggregationStyle())) {
            Context context = new Context(getAggregationItemIds());
            paintAggregationRow(target, ((AggregationContainer) items).aggregate(context));
        }
    }
    // paint cuba-ids
    AppUI current = AppUI.getCurrent();
    if (current != null && current.isTestMode()) {
        ArrayList<String> visibleColOrder = new ArrayList<>();
        for (Object columnId : visibleColumns) {
            if (!isColumnCollapsed(columnId)) {
                visibleColOrder.add(columnId.toString());
            }
        }
        target.addAttribute("colcubaids", visibleColOrder.toArray());
    }
}
Also used : AppUI(com.haulmont.cuba.web.AppUI) AggregationContainer(com.haulmont.cuba.web.toolkit.data.AggregationContainer)

Example 10 with AppUI

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

the class CubaTable method changeVariables.

@Override
public void changeVariables(Object source, Map<String, Object> variables) {
    if (Page.getCurrent().getWebBrowser().isIE() && variables.containsKey("clickEvent")) {
        focus();
    }
    super.changeVariables(source, variables);
    if (shortcutActionManager != null) {
        shortcutActionManager.handleActions(variables, this);
    }
    String profilerMarker = (String) variables.get("profilerMarker");
    if (StringUtils.isNotEmpty(profilerMarker)) {
        AppUI ui = AppUI.getCurrent();
        ui.setProfilerMarker(profilerMarker);
    }
}
Also used : 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