use of com.haulmont.cuba.web.widgets.CubaUI in project cuba by cuba-platform.
the class WebAbstractDataGrid method onItemClick.
protected void onItemClick(Grid.ItemClick<E> e) {
CubaUI ui = (CubaUI) component.getUI();
if (!ui.isAccessibleForUser(component)) {
LoggerFactory.getLogger(WebDataGrid.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 && !WebAbstractDataGrid.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 = WebWrapperUtils.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<>(WebAbstractDataGrid.this, mouseEventDetails, item, item.getId(), column != null ? column.getId() : null);
publish(ItemClickEvent.class, event);
}
}
use of com.haulmont.cuba.web.widgets.CubaUI in project cuba by cuba-platform.
the class WebAbstractTable method initComponent.
protected void initComponent(T component) {
component.setMultiSelect(false);
component.setValidationVisible(false);
component.setShowBufferedSourceException(false);
component.setCustomCellValueFormatter(this::formatCellValue);
component.addValueChangeListener(this::tableSelectionChanged);
component.setSpecificVariablesHandler(this::handleSpecificVariables);
component.setIconProvider(this::getItemIcon);
component.setBeforePaintListener(this::beforeComponentPaint);
component.setSortAscendingLabel(messages.getMainMessage("tableSort.ascending"));
component.setSortResetLabel(messages.getMainMessage("tableSort.reset"));
component.setSortDescendingLabel(messages.getMainMessage("tableSort.descending"));
component.setSelectAllLabel(messages.getMainMessage("tableColumnSelector.selectAll"));
component.setDeselectAllLabel(messages.getMainMessage("tableColumnSelector.deselectAll"));
int defaultRowHeaderWidth = 16;
ThemeConstantsManager themeConstantsManager = beanLocator.get(ThemeConstantsManager.NAME, ThemeConstantsManager.class);
ThemeConstants theme = themeConstantsManager.getConstants();
if (theme != null) {
defaultRowHeaderWidth = theme.getInt("cuba.web.Table.defaultRowHeaderWidth", 16);
}
component.setColumnWidth(ROW_HEADER_PROPERTY_ID, defaultRowHeaderWidth);
contextMenuPopup.setParent(component);
component.setContextMenuPopup(contextMenuPopup);
shortcutsDelegate.setAllowEnterShortcut(false);
component.addShortcutListener(new ShortcutListenerDelegate("tableEnter", KeyCode.ENTER, null).withHandler((sender, target) -> {
T tableImpl = WebAbstractTable.this.component;
CubaUI ui = (CubaUI) tableImpl.getUI();
if (!ui.isAccessibleForUser(tableImpl)) {
LoggerFactory.getLogger(WebAbstractTable.class).debug("Ignore click attempt because Table is inaccessible for user");
return;
}
if (target == this.component) {
if (enterPressAction != null) {
enterPressAction.actionPerform(this);
} else {
handleClickAction();
}
}
}));
component.addShortcutListener(new ShortcutListenerDelegate("tableSelectAll", KeyCode.A, new int[] { com.vaadin.event.ShortcutAction.ModifierKey.CTRL }).withHandler((sender, target) -> {
if (target == this.component) {
selectAll();
}
}));
component.addItemClickListener(event -> {
if (event.isDoubleClick() && event.getItem() != null) {
T tableImpl = WebAbstractTable.this.component;
CubaUI ui = (CubaUI) tableImpl.getUI();
if (!ui.isAccessibleForUser(tableImpl)) {
LoggerFactory.getLogger(WebAbstractTable.class).debug("Ignore click attempt because Table is inaccessible for user");
return;
}
handleClickAction();
}
});
component.setAfterUnregisterComponentHandler(this::onAfterUnregisterComponent);
component.setBeforeRefreshRowCacheHandler(this::onBeforeRefreshRowCache);
component.setSelectable(true);
component.setTableFieldFactory(createFieldFactory());
component.setColumnCollapsingAllowed(true);
component.setColumnReorderingAllowed(true);
setEditable(false);
componentComposition = new TableComposition();
componentComposition.setTable(component);
componentComposition.setPrimaryStyleName("c-table-composition");
componentComposition.addComponent(component);
component.setCellStyleGenerator(createStyleGenerator());
component.addColumnCollapseListener(this::handleColumnCollapsed);
// force default sizes
componentComposition.setHeightUndefined();
componentComposition.setWidthUndefined();
setClientCaching();
initEmptyState();
}
use of com.haulmont.cuba.web.widgets.CubaUI in project cuba by cuba-platform.
the class MenuShortcutAction method handleAction.
@Override
public void handleAction(Object sender, Object target) {
Component menuImpl = menuItem.getMenu().unwrap(Component.class);
CubaUI ui = (CubaUI) menuImpl.getUI();
if (ui.isAccessibleForUser(menuImpl)) {
menuItem.getCommand().accept(menuItem);
} else {
LoggerFactory.getLogger(MenuShortcutAction.class).debug("Ignoring shortcut action because menu is inaccessible for user");
}
}
use of com.haulmont.cuba.web.widgets.CubaUI in project cuba by cuba-platform.
the class WebDialogWindow method onCloseShortcutTriggered.
protected void onCloseShortcutTriggered(@SuppressWarnings("unused") Object sender, @SuppressWarnings("unused") Object target) {
if (this.isCloseable()) {
com.vaadin.ui.Component component = getComponent();
CubaUI ui = (CubaUI) component.getUI();
if (!ui.isAccessibleForUser(component)) {
LoggerFactory.getLogger(WebWindow.class).debug("Ignore shortcut action because Window is inaccessible for user");
return;
}
BeforeCloseEvent event = new BeforeCloseEvent(this, CloseOriginType.SHORTCUT);
fireBeforeClose(event);
if (!event.isClosePrevented()) {
getFrameOwner().close(new StandardCloseAction(Window.CLOSE_ACTION_ID));
}
}
}
use of com.haulmont.cuba.web.widgets.CubaUI in project cuba by cuba-platform.
the class WebDialogWindow method onCloseButtonClick.
protected void onCloseButtonClick(CubaWindow.PreCloseEvent preCloseEvent) {
preCloseEvent.setPreventClose(true);
com.vaadin.ui.Component component = getComponent();
CubaUI ui = (CubaUI) component.getUI();
if (!ui.isAccessibleForUser(component)) {
LoggerFactory.getLogger(WebWindow.class).debug("Ignore close button click because Window is inaccessible for user");
return;
}
BeforeCloseEvent event = new BeforeCloseEvent(this, CloseOriginType.CLOSE_BUTTON);
fireBeforeClose(event);
if (!event.isClosePrevented()) {
// user has clicked on X
getFrameOwner().close(new StandardCloseAction(Window.CLOSE_ACTION_ID));
}
}
Aggregations