Search in sources :

Example 16 with AppUI

use of io.jmix.ui.AppUI in project jmix by jmix-framework.

the class AccordionImpl method setDebugId.

@Override
public void setDebugId(@Nullable String id) {
    super.setDebugId(id);
    String debugId = getDebugId();
    AppUI ui = AppUI.getCurrent();
    if (debugId != null && ui != null) {
        TestIdManager testIdManager = ui.getTestIdManager();
        for (Map.Entry<com.vaadin.ui.Component, ComponentDescriptor> tabEntry : tabMapping.entrySet()) {
            com.vaadin.ui.Component tabComponent = tabEntry.getKey();
            com.vaadin.ui.Accordion.Tab tab = component.getTab(tabComponent);
            ComponentDescriptor componentDescriptor = tabEntry.getValue();
            String name = componentDescriptor.name;
            component.setTestId(tab, testIdManager.getTestId(debugId + "." + name));
        }
    }
}
Also used : TestIdManager(io.jmix.ui.sys.TestIdManager) JmixAccordion(io.jmix.ui.widget.JmixAccordion) AppUI(io.jmix.ui.AppUI)

Example 17 with AppUI

use of io.jmix.ui.AppUI in project jmix by jmix-framework.

the class AbstractComponent method assignDebugId.

protected void assignDebugId() {
    AppUI ui = AppUI.getCurrent();
    if (ui == null) {
        return;
    }
    if (this.component == null || frame == null || StringUtils.isEmpty(frame.getId())) {
        return;
    }
    if (ui.isPerformanceTestMode() && getDebugId() == null) {
        String fullFrameId = ComponentsHelper.getFullFrameId(frame);
        TestIdManager testIdManager = ui.getTestIdManager();
        String alternativeId = id != null ? id : getClass().getSimpleName();
        String candidateId = fullFrameId + "." + alternativeId;
        setDebugId(testIdManager.getTestId(candidateId));
    }
}
Also used : TestIdManager(io.jmix.ui.sys.TestIdManager) AppUI(io.jmix.ui.AppUI)

Example 18 with AppUI

use of io.jmix.ui.AppUI in project jmix by jmix-framework.

the class AbstractDataGrid method setupGridColumnProperties.

protected void setupGridColumnProperties(Grid.Column<E, ?> gridColumn, Column<E> column) {
    if (gridColumn.getId() == null) {
        gridColumn.setId(column.getId());
    } else if (!Objects.equals(gridColumn.getId(), column.getId())) {
        log.warn("Trying to copy column settings with mismatched ids. Grid.Column: " + gridColumn.getId() + "; DataGrid.Column: " + column.getId());
    }
    gridColumn.setCaption(column.getCaption());
    gridColumn.setHidingToggleCaption(column.getCollapsingToggleCaption());
    if (column.isWidthAuto()) {
        gridColumn.setWidthUndefined();
    } else {
        gridColumn.setWidth(column.getWidth());
    }
    gridColumn.setExpandRatio(column.getExpandRatio());
    gridColumn.setMinimumWidth(column.getMinimumWidth());
    gridColumn.setMaximumWidth(column.getMaximumWidth());
    gridColumn.setHidden(column.isCollapsed());
    gridColumn.setHidable(column.isCollapsible() && column.getOwner().isColumnsCollapsingAllowed());
    gridColumn.setResizable(column.isResizable());
    gridColumn.setSortable(column.isSortable() && column.getOwner().isSortable());
    gridColumn.setEditable(column.isEditable());
    AppUI current = AppUI.getCurrent();
    if (current != null && current.isTestMode()) {
        addColumnId(gridColumn, column);
    }
    com.vaadin.ui.renderers.Renderer columnRenderer = getColumnRendererImplementation(column);
    if (!Objects.equals(gridColumn.getRenderer(), columnRenderer)) {
        gridColumn.setRenderer(getColumnPresentationValueProvider(column), columnRenderer);
    }
    gridColumn.setStyleGenerator(new CellStyleGeneratorAdapter<>(column));
    gridColumn.setDescriptionGenerator(new CellDescriptionGeneratorAdapter<>(column), WrapperUtils.toVaadinContentMode(((ColumnImpl) column).getDescriptionContentMode()));
    ((ColumnImpl<E>) column).setGridColumn(gridColumn);
}
Also used : AppUI(io.jmix.ui.AppUI)

Example 19 with AppUI

use of io.jmix.ui.AppUI in project jmix by jmix-framework.

the class AbstractDataGrid method onItemClick.

protected void onItemClick(Grid.ItemClick<E> e) {
    AppUI ui = (AppUI) component.getUI();
    if (!ui.isAccessibleForUser(component)) {
        LoggerFactory.getLogger(DataGridImpl.class).debug("Ignore click attempt because DataGrid is inaccessible for user");
        return;
    }
    com.vaadin.shared.MouseEventDetails vMouseEventDetails = e.getMouseEventDetails();
    if (vMouseEventDetails.isDoubleClick() && e.getItem() != null && !AbstractDataGrid.this.isEditorEnabled()) {
        // note: for now Grid doesn't send double click if editor is enabled,
        // but it's better to handle it manually
        handleDoubleClickAction();
    }
    if (hasSubscriptions(ItemClickEvent.class)) {
        MouseEventDetails mouseEventDetails = WrapperUtils.toMouseEventDetails(vMouseEventDetails);
        E item = e.getItem();
        if (item == null) {
            // datasource, so we don't want to send such event because it's useless
            return;
        }
        Column<E> column = e.getColumn() != null ? getColumnById(e.getColumn().getId()) : null;
        ItemClickEvent<E> event = new ItemClickEvent<>(AbstractDataGrid.this, mouseEventDetails, item, EntityValues.getId(item), column != null ? column.getId() : null);
        publish(ItemClickEvent.class, event);
    }
}
Also used : AppUI(io.jmix.ui.AppUI)

Example 20 with AppUI

use of io.jmix.ui.AppUI in project jmix by jmix-framework.

the class AbstractActionsHolderComponent method initContextMenuPopup.

protected void initContextMenuPopup(VerticalLayout contextMenuPopup) {
    contextMenuPopup.setSpacing(false);
    contextMenuPopup.setMargin(false);
    contextMenuPopup.setSizeUndefined();
    contextMenuPopup.setStyleName("jmix-cm-container");
    AppUI ui = AppUI.getCurrent();
    if (ui != null && ui.isTestMode()) {
        contextMenuPopup.setJTestId("jmixContextMenu");
    }
}
Also used : AppUI(io.jmix.ui.AppUI)

Aggregations

AppUI (io.jmix.ui.AppUI)56 TestIdManager (io.jmix.ui.sys.TestIdManager)8 Component (com.vaadin.ui.Component)5 UiEventsMulticaster (io.jmix.ui.sys.event.UiEventsMulticaster)4 ApplicationListener (org.springframework.context.ApplicationListener)4 SearchFolder (com.haulmont.cuba.security.entity.SearchFolder)3 Notifications (io.jmix.ui.Notifications)3 Folder (com.haulmont.cuba.core.entity.Folder)2 Internal (io.jmix.core.annotation.Internal)2 Screen (io.jmix.ui.screen.Screen)2 StandardCloseAction (io.jmix.ui.screen.StandardCloseAction)2 Subscribe (io.jmix.ui.screen.Subscribe)2 JmixButton (io.jmix.ui.widget.JmixButton)2 Nullable (javax.annotation.Nullable)2 Strings (com.google.common.base.Strings)1 AbstractSearchFolder (com.haulmont.cuba.core.entity.AbstractSearchFolder)1 AppFolder (com.haulmont.cuba.core.entity.AppFolder)1 AppFolderEditWindow (com.haulmont.cuba.web.app.folders.AppFolderEditWindow)1 FolderEditWindow (com.haulmont.cuba.web.app.folders.FolderEditWindow)1 KeyCode (com.vaadin.event.ShortcutAction.KeyCode)1