use of org.drools.workbench.screens.scenariosimulation.client.domelements.CollectionEditorDOMElement in project drools-wb by kiegroup.
the class CollectionEditorSingletonDOMElementFactoryTest method registerHandlers.
@Test
public void registerHandlers() {
CollectionEditorDOMElement collectionEditorDOMElementMock = mock(CollectionEditorDOMElement.class);
collectionEditorSingletonDOMElementFactorySpy.registerHandlers(collectionEditorViewImpl, collectionEditorDOMElementMock);
ArgumentCaptor<CloseCompositeEventHandler> closeHandler = ArgumentCaptor.forClass(CloseCompositeEventHandler.class);
verify(collectionEditorViewImpl, times(1)).addCloseCompositeEventHandler(closeHandler.capture());
closeHandler.getValue().onEvent(mock(CloseCompositeEvent.class));
verify(collectionEditorSingletonDOMElementFactorySpy).destroyResources();
verify(scenarioGridLayerMock).batch();
verify(scenarioGridPanelMock).setFocus(eq(true));
verify(collectionEditorDOMElementMock).stopEditingMode();
reset(collectionEditorSingletonDOMElementFactorySpy);
reset(scenarioGridLayerMock);
reset(scenarioGridPanelMock);
ArgumentCaptor<SaveEditorEventHandler> saveHandler = ArgumentCaptor.forClass(SaveEditorEventHandler.class);
verify(collectionEditorViewImpl, times(1)).addSaveEditorEventHandler(saveHandler.capture());
saveHandler.getValue().onEvent(mock(SaveEditorEvent.class));
verify(collectionEditorSingletonDOMElementFactorySpy).flush();
verify(scenarioGridLayerMock).batch();
verify(scenarioGridPanelMock).setFocus(eq(true));
}
use of org.drools.workbench.screens.scenariosimulation.client.domelements.CollectionEditorDOMElement in project drools-wb by kiegroup.
the class CollectionEditorSingletonDOMElementFactory method createDomElement.
@Override
public CollectionEditorDOMElement createDomElement(final GridLayer gridLayer, final GridWidget gridWidget) {
if (this.widget != null) {
this.widget.close();
}
this.widget = createWidget();
/* Don't propagate MouseWheel and RightClick events to the Grid */
this.widget.addDomHandler(MouseWheelEvent::stopPropagation, MouseWheelEvent.getType());
this.widget.addDomHandler(event -> {
event.stopPropagation();
event.preventDefault();
}, ContextMenuEvent.getType());
this.widget.addDomHandler(ClickEvent::stopPropagation, ClickEvent.getType());
this.widget.addDomHandler(KeyDownEvent::stopPropagation, KeyDownEvent.getType());
final AbstractScesimGridModel<? extends AbstractScesimModel, ? extends AbstractScesimData> model = ((ScenarioGrid) gridWidget).getModel();
final GridData.SelectedCell selectedCellsOrigin = model.getSelectedCellsOrigin();
final Optional<GridColumn<?>> selectedColumn = model.getColumns().stream().filter(col -> col.getIndex() == selectedCellsOrigin.getColumnIndex()).findFirst();
selectedColumn.ifPresent(col -> {
final int actualIndex = model.getColumns().indexOf(col);
final FactMapping factMapping = model.getAbstractScesimModel().get().getScesimModelDescriptor().getFactMappingByIndex(actualIndex);
setCollectionEditorStructureData(this.widget, factMapping);
this.e = createDomElementInternal(widget, gridLayer, gridWidget);
});
return e;
}
Aggregations