use of org.kie.workbench.common.dmn.client.widgets.grid.BaseGrid in project kie-wb-common by kiegroup.
the class DMNGridPanelContextMenuHandlerTest method onContextMenu_WithGridWidget_WithHeader.
@Test
@SuppressWarnings("unchecked")
public void onContextMenu_WithGridWidget_WithHeader() {
final int EVENT_X = (int) (COLUMN0_WIDTH + COLUMN1_WIDTH / 2);
final int EVENT_Y = (int) (HEADER_HEIGHT / 2);
when(nativeEvent.getClientX()).thenReturn(EVENT_X);
when(nativeEvent.getClientY()).thenReturn(EVENT_Y);
final BaseGrid gridWidget = mockGridWidget();
when(gridLayer.getGridWidgets()).thenReturn(Collections.singleton(gridWidget));
final MockContextMenuHeaderMetaData headerMetaData = mock(MockContextMenuHeaderMetaData.class);
when(gridColumn.getHeaderMetaData()).thenReturn(Collections.singletonList(headerMetaData));
when(headerMetaData.getEditor()).thenReturn(Optional.of(editor));
handler.onContextMenu(event);
verify(editor).bind(eq(headerMetaData), eq(0), eq(1));
verify(cellEditorControls).show(eq(editor), eq(EVENT_X), eq(EVENT_Y));
}
use of org.kie.workbench.common.dmn.client.widgets.grid.BaseGrid in project kie-wb-common by kiegroup.
the class DMNGridPanelContextMenuHandlerTest method onContextMenu_WithGridWidget_WithNullCell.
@Test
public void onContextMenu_WithGridWidget_WithNullCell() {
when(nativeEvent.getClientX()).thenReturn((int) (COLUMN0_WIDTH / 2));
when(nativeEvent.getClientY()).thenReturn((int) (ROW_HEIGHT + ROW_HEIGHT / 2));
final BaseGrid gridWidget = mockGridWidget();
when(gridLayer.getGridWidgets()).thenReturn(Collections.singleton(gridWidget));
handler.onContextMenu(event);
verify(cellEditorControls, never()).show(any(HasCellEditorControls.Editor.class), anyInt(), anyInt());
}
use of org.kie.workbench.common.dmn.client.widgets.grid.BaseGrid in project kie-wb-common by kiegroup.
the class DMNGridPanelContextMenuHandlerTest method onContextMenu_WithGridWidget_WithCellValue.
@Test
@SuppressWarnings("unchecked")
public void onContextMenu_WithGridWidget_WithCellValue() {
final int EVENT_X = (int) (COLUMN0_WIDTH / 2);
final int EVENT_Y = (int) (HEADER_HEIGHT + ROW_HEIGHT + ROW_HEIGHT / 2);
when(nativeEvent.getClientX()).thenReturn(EVENT_X);
when(nativeEvent.getClientY()).thenReturn(EVENT_Y);
final BaseGrid gridWidget = mockGridWidget();
when(gridLayer.getGridWidgets()).thenReturn(Collections.singleton(gridWidget));
final MockCell cell = mock(MockCell.class);
gridWidget.getModel().setCell(1, 0, () -> cell);
when(cell.getEditor()).thenReturn(Optional.of(editor));
handler.onContextMenu(event);
verify(editor).bind(eq(gridWidget), eq(1), eq(0));
verify(cellEditorControls).show(eq(editor), eq(EVENT_X), eq(EVENT_Y));
}
use of org.kie.workbench.common.dmn.client.widgets.grid.BaseGrid in project kie-wb-common by kiegroup.
the class DMNGridPanelContextMenuHandlerTest method mockGridWidget.
private BaseGrid mockGridWidget() {
final BaseGrid gridWidget = spy(new BaseGrid(gridLayer, new BaseGridData(false), renderer, sessionManager, sessionCommandManager, canvasCommandFactory, refreshFormPropertiesEvent, domainObjectSelectionEvent, cellEditorControls, translationService) {
@Override
public Layer getLayer() {
return gridLayer;
}
});
gridWidget.getModel().appendColumn(new RowNumberColumn());
gridWidget.getModel().appendColumn(gridColumn);
gridWidget.getModel().appendRow(new BaseGridRow());
gridWidget.getModel().appendRow(new BaseGridRow());
return gridWidget;
}
use of org.kie.workbench.common.dmn.client.widgets.grid.BaseGrid in project kie-wb-common by kiegroup.
the class DMNGridWidgetDnDMouseUpHandler method onNodeMouseUp.
@Override
public void onNodeMouseUp(final NodeMouseUpEvent event) {
if (state.getOperation() == GridWidgetDnDHandlersState.GridWidgetHandlersOperation.COLUMN_RESIZE) {
final GridWidget gridWidget = state.getActiveGridWidget();
final List<GridColumn<?>> gridColumns = state.getActiveGridColumns();
if (isBaseGrid(gridWidget) && isSingleDMNColumn(gridColumns)) {
final BaseGrid uiGridWidget = (BaseGrid) gridWidget;
final DMNGridColumn uiColumn = (DMNGridColumn) gridColumns.get(0);
uiGridWidget.registerColumnResizeCompleted(uiColumn, state.getEventInitialColumnWidth());
}
}
super.onNodeMouseUp(event);
}
Aggregations