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));
}
}
}
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));
}
}
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);
}
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);
}
}
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");
}
}
Aggregations