use of com.google.gwt.event.dom.client.ContextMenuHandler in project drools-wb by kiegroup.
the class GuidedDecisionTableModellerContextMenuSupportTest method onContextMenuWithMultipleTables.
@Test
@SuppressWarnings("unchecked")
public void onContextMenuWithMultipleTables() {
final GuidedDecisionTableView.Presenter dtPresenter1 = makeDecisionTable(0, 0);
final GuidedDecisionTableView.Presenter dtPresenter2 = makeDecisionTable(200, 200);
when(modellerPresenter.getAvailableDecisionTables()).thenReturn(new HashSet<GuidedDecisionTableView.Presenter>() {
{
add(dtPresenter1);
add(dtPresenter2);
}
});
final GridData uiModel1 = dtPresenter1.getView().getModel();
final GridData uiModel2 = dtPresenter2.getView().getModel();
final GridColumn uiColumn = new BaseGridColumn(mock(GridColumn.HeaderMetaData.class), mock(GridColumnRenderer.class), 100.0);
uiModel1.appendColumn(uiColumn);
uiModel2.appendColumn(uiColumn);
when(uiModel1.getCell(any(Integer.class), any(Integer.class))).thenReturn(uiCell);
when(uiModel2.getCell(any(Integer.class), any(Integer.class))).thenReturn(uiCell);
when(columnInformation.getColumn()).thenReturn(uiColumn);
final ContextMenuHandler handler = contextMenuSupport.getContextMenuHandler(modellerPresenter);
when(nativeEvent.getClientX()).thenReturn(50);
when(nativeEvent.getClientY()).thenReturn(50);
handler.onContextMenu(event);
verify(cellSelectionStrategy, times(1)).handleSelection(uiModelCaptor.capture(), any(Integer.class), any(Integer.class), any(Boolean.class), any(Boolean.class));
assertEquals(uiModel1, uiModelCaptor.getValue());
when(nativeEvent.getClientX()).thenReturn(250);
when(nativeEvent.getClientY()).thenReturn(250);
handler.onContextMenu(event);
verify(cellSelectionStrategy, times(2)).handleSelection(uiModelCaptor.capture(), any(Integer.class), any(Integer.class), any(Boolean.class), any(Boolean.class));
assertEquals(uiModel2, uiModelCaptor.getValue());
}
use of com.google.gwt.event.dom.client.ContextMenuHandler in project drools-wb by kiegroup.
the class GuidedDecisionTableModellerContextMenuSupportTest method testContextMenuCellIsNotSelectedCell.
@Test
@SuppressWarnings("unchecked")
public void testContextMenuCellIsNotSelectedCell() {
final GuidedDecisionTableView.Presenter dtPresenter = makeDecisionTable();
final GridData uiModel = dtPresenter.getView().getModel();
final GridColumn uiColumn = new RowNumberColumn();
uiModel.appendColumn(uiColumn);
uiModel.appendRow(new BaseGridRow());
// Cell associated with Mock onContextMenu Event has indices (0,0)
uiModel.selectCells(1, 0, 1, 1);
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);
// this method is called if the handler does a selectCell, which should occur for this test case
verify(cellSelectionStrategy, times(1)).handleSelection(any(GridData.class), eq(0), eq(0), eq(false), eq(false));
verify(rowContextMenu, times(1)).show(any(Integer.class), any(Integer.class));
verify(cellContextMenu, never()).show(any(Integer.class), any(Integer.class));
}
use of com.google.gwt.event.dom.client.ContextMenuHandler in project drools-wb by kiegroup.
the class GuidedDecisionTableModellerContextMenuSupportTest method onContextMenuWithCellSelectionManagerWithChangeInSelection.
@Test
@SuppressWarnings("unchecked")
public void onContextMenuWithCellSelectionManagerWithChangeInSelection() {
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);
when(cellSelectionStrategy.handleSelection(any(GridData.class), any(Integer.class), any(Integer.class), any(Boolean.class), any(Boolean.class))).thenReturn(true);
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, times(1)).batch();
}
use of com.google.gwt.event.dom.client.ContextMenuHandler in project drools-wb by kiegroup.
the class GuidedDecisionTableModellerContextMenuSupportTest method getContextMenuHandler.
@Test
public void getContextMenuHandler() {
final ContextMenuHandler handler = contextMenuSupport.getContextMenuHandler(modellerPresenter);
assertNotNull(handler);
}
use of com.google.gwt.event.dom.client.ContextMenuHandler in project drools-wb by kiegroup.
the class GuidedDecisionTableModellerContextMenuSupportTest method onContextMenu_CellContextMenu.
@Test
@SuppressWarnings("unchecked")
public void onContextMenu_CellContextMenu() {
final GuidedDecisionTableView.Presenter dtPresenter = makeDecisionTable();
final GridData uiModel = dtPresenter.getView().getModel();
final GridColumn uiColumn = new BaseGridColumn(mock(GridColumn.HeaderMetaData.class), mock(GridColumnRenderer.class), 100.0);
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, never()).show(any(Integer.class), any(Integer.class));
verify(cellContextMenu, times(1)).show(any(Integer.class), any(Integer.class));
}
Aggregations