Search in sources :

Example 6 with ContextMenuHandler

use of com.google.gwt.event.dom.client.ContextMenuHandler in project drools-wb by kiegroup.

the class GuidedDecisionTableModellerContextMenuSupportTest method testContextMenuCellIsSelectedCell.

@Test
@SuppressWarnings("unchecked")
public void testContextMenuCellIsSelectedCell() {
    final GuidedDecisionTableView.Presenter dtPresenter = makeDecisionTable();
    final GridData uiModel = dtPresenter.getView().getModel();
    final GridColumn uiColumn = new RowNumberColumn();
    uiModel.appendColumn(uiColumn);
    // Cell associated with Mock onContextMenu Event has indices (0,0)
    uiModel.selectCells(0, 0, 1, 1);
    when(columnInformation.getColumn()).thenReturn(uiColumn);
    when(modellerPresenter.getAvailableDecisionTables()).thenReturn(new HashSet<GuidedDecisionTableView.Presenter>() {

        {
            add(dtPresenter);
        }
    });
    final ContextMenuHandler handler = contextMenuSupport.getContextMenuHandler(modellerPresenter);
    handler.onContextMenu(event);
    // this method is called if the handler does a selectCell, which should not occur for this test case
    verify(cellSelectionStrategy, never()).handleSelection(any(GridData.class), any(Integer.class), any(Integer.class), any(Boolean.class), any(Boolean.class));
    verify(rowContextMenu, times(1)).show(any(Integer.class), any(Integer.class));
    verify(cellContextMenu, never()).show(any(Integer.class), any(Integer.class));
}
Also used : RowNumberColumn(org.uberfire.ext.wires.core.grids.client.widget.grid.columns.RowNumberColumn) GridData(org.uberfire.ext.wires.core.grids.client.model.GridData) BaseGridData(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridData) BaseGridColumn(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridColumn) GridColumn(org.uberfire.ext.wires.core.grids.client.model.GridColumn) ContextMenuHandler(com.google.gwt.event.dom.client.ContextMenuHandler) Test(org.junit.Test)

Example 7 with ContextMenuHandler

use of com.google.gwt.event.dom.client.ContextMenuHandler in project drools-wb by kiegroup.

the class GuidedDecisionTableModellerContextMenuSupportTest method onContextMenu_RowContextMenu.

@Test
@SuppressWarnings("unchecked")
public void onContextMenu_RowContextMenu() {
    final GuidedDecisionTableView.Presenter dtPresenter = makeDecisionTable();
    final GridData uiModel = dtPresenter.getView().getModel();
    final GridColumn uiColumn = new RowNumberColumn();
    uiModel.appendColumn(uiColumn);
    when(columnInformation.getColumn()).thenReturn(uiColumn);
    when(modellerPresenter.getAvailableDecisionTables()).thenReturn(new HashSet<GuidedDecisionTableView.Presenter>() {

        {
            add(dtPresenter);
        }
    });
    final ContextMenuHandler handler = contextMenuSupport.getContextMenuHandler(modellerPresenter);
    handler.onContextMenu(event);
    verify(rowContextMenu, times(1)).show(any(Integer.class), any(Integer.class));
    verify(cellContextMenu, never()).show(any(Integer.class), any(Integer.class));
}
Also used : RowNumberColumn(org.uberfire.ext.wires.core.grids.client.widget.grid.columns.RowNumberColumn) GridData(org.uberfire.ext.wires.core.grids.client.model.GridData) BaseGridData(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridData) BaseGridColumn(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridColumn) GridColumn(org.uberfire.ext.wires.core.grids.client.model.GridColumn) ContextMenuHandler(com.google.gwt.event.dom.client.ContextMenuHandler) Test(org.junit.Test)

Example 8 with ContextMenuHandler

use of com.google.gwt.event.dom.client.ContextMenuHandler in project drools-wb by kiegroup.

the class GuidedDecisionTableModellerContextMenuSupportTest method onContextMenuWithoutCellSelectionManager.

@Test
@SuppressWarnings("unchecked")
public void onContextMenuWithoutCellSelectionManager() {
    final GuidedDecisionTableView.Presenter dtPresenter = makeDecisionTable();
    final GridData uiModel = dtPresenter.getView().getModel();
    final GridColumn uiColumn = new RowNumberColumn();
    uiModel.appendColumn(uiColumn);
    when(columnInformation.getColumn()).thenReturn(uiColumn);
    when(modellerPresenter.getAvailableDecisionTables()).thenReturn(new HashSet<GuidedDecisionTableView.Presenter>() {

        {
            add(dtPresenter);
        }
    });
    final GridCell uiCell = mock(GridCell.class);
    when(uiModel.getCell(any(Integer.class), any(Integer.class))).thenReturn(uiCell);
    when(uiCell.getSelectionStrategy()).thenReturn(null);
    final ContextMenuHandler handler = contextMenuSupport.getContextMenuHandler(modellerPresenter);
    handler.onContextMenu(event);
    verify(layer, never()).batch();
}
Also used : RowNumberColumn(org.uberfire.ext.wires.core.grids.client.widget.grid.columns.RowNumberColumn) GridData(org.uberfire.ext.wires.core.grids.client.model.GridData) BaseGridData(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridData) BaseGridColumn(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridColumn) GridColumn(org.uberfire.ext.wires.core.grids.client.model.GridColumn) ContextMenuHandler(com.google.gwt.event.dom.client.ContextMenuHandler) GridCell(org.uberfire.ext.wires.core.grids.client.model.GridCell) Test(org.junit.Test)

Example 9 with ContextMenuHandler

use of com.google.gwt.event.dom.client.ContextMenuHandler in project drools-wb by kiegroup.

the class GuidedDecisionTableModellerContextMenuSupportTest method onContextMenuWithCellSelectionManagerWithoutChangeInSelection.

@Test
@SuppressWarnings("unchecked")
public void onContextMenuWithCellSelectionManagerWithoutChangeInSelection() {
    final GuidedDecisionTableView.Presenter dtPresenter = makeDecisionTable();
    final GridData uiModel = dtPresenter.getView().getModel();
    final GridColumn uiColumn = new RowNumberColumn();
    uiModel.appendColumn(uiColumn);
    when(columnInformation.getColumn()).thenReturn(uiColumn);
    when(modellerPresenter.getAvailableDecisionTables()).thenReturn(new HashSet<GuidedDecisionTableView.Presenter>() {

        {
            add(dtPresenter);
        }
    });
    when(uiModel.getCell(any(Integer.class), any(Integer.class))).thenReturn(uiCell);
    final ContextMenuHandler handler = contextMenuSupport.getContextMenuHandler(modellerPresenter);
    handler.onContextMenu(event);
    verify(cellSelectionStrategy, times(1)).handleSelection(eq(uiModel), eq(0), eq(0), eq(false), eq(false));
    verify(layer, never()).batch();
}
Also used : RowNumberColumn(org.uberfire.ext.wires.core.grids.client.widget.grid.columns.RowNumberColumn) GridData(org.uberfire.ext.wires.core.grids.client.model.GridData) BaseGridData(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridData) BaseGridColumn(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridColumn) GridColumn(org.uberfire.ext.wires.core.grids.client.model.GridColumn) ContextMenuHandler(com.google.gwt.event.dom.client.ContextMenuHandler) Test(org.junit.Test)

Aggregations

ContextMenuHandler (com.google.gwt.event.dom.client.ContextMenuHandler)9 Test (org.junit.Test)9 GridColumn (org.uberfire.ext.wires.core.grids.client.model.GridColumn)8 GridData (org.uberfire.ext.wires.core.grids.client.model.GridData)8 BaseGridColumn (org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridColumn)8 BaseGridData (org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridData)8 RowNumberColumn (org.uberfire.ext.wires.core.grids.client.widget.grid.columns.RowNumberColumn)6 GridColumnRenderer (org.uberfire.ext.wires.core.grids.client.widget.grid.renderers.columns.GridColumnRenderer)2 GridCell (org.uberfire.ext.wires.core.grids.client.model.GridCell)1 BaseGridRow (org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow)1