@Test public void createDomElement() { when(scenarioGridModelMock.getSelectedCellsOrigin()).thenReturn(new GridData.SelectedCell(0, 0)); when(factMappingMock.getExpressionAlias()).thenReturn(MAP_CLASS_NAME); when(factMappingMock.getClassName()).thenReturn(MAP_CLASS_NAME); collectionEditorSingletonDOMElementFactorySpy.createDomElement(scenarioGridLayerMock, scenarioGridMock); verify(collectionEditorViewImpl, times(1)).addDomHandler(isA(MouseWheelHandler.class), eq(MouseWheelEvent.getType())); verify(collectionEditorViewImpl, times(1)).addDomHandler(isA(ContextMenuHandler.class), eq(ContextMenuEvent.getType())); }
@Override public CollectionEditorDOMElement createDomElement(final GridLayer gridLayer, final GridWidget gridWidget) { if (this.widget != null) { this.widget.close(); } this.widget = createWidget(); 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; }
CollectionEditorSingletonDOMElementFactory extends BaseSingletonDOMElementFactory<String, CollectionViewImpl, CollectionEditorDOMElement> { @Override public CollectionEditorDOMElement createDomElement(final GridLayer gridLayer, final GridWidget gridWidget) { if (this.widget != null) { this.widget.close(); } this.widget = createWidget(); 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; } }
CollectionEditorSingletonDOMElementFactory extends BaseSingletonDOMElementFactory<String, CollectionViewImpl, CollectionEditorDOMElement> { @Override public CollectionEditorDOMElement createDomElement(final GridLayer gridLayer, final GridWidget gridWidget) { if (this.widget != null) { this.widget.close(); } this.widget = createWidget(); 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; } CollectionEditorSingletonDOMElementFactory(final GridLienzoPanel gridPanel,
                                                      final GridLayer gridLayer,
                                                      final GridWidget gridWidget,
                                                      final ScenarioSimulationContext scenarioSimulationContext,
                                                      final ViewsProvider viewsProvider); }
CollectionEditorSingletonDOMElementFactory extends BaseSingletonDOMElementFactory<String, CollectionViewImpl, CollectionEditorDOMElement> { @Override public CollectionEditorDOMElement createDomElement(final GridLayer gridLayer, final GridWidget gridWidget) { if (this.widget != null) { this.widget.close(); } this.widget = createWidget(); 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; } CollectionEditorSingletonDOMElementFactory(final GridLienzoPanel gridPanel,
                                                      final GridLayer gridLayer,
                                                      final GridWidget gridWidget,
                                                      final ScenarioSimulationContext scenarioSimulationContext,
                                                      final ViewsProvider viewsProvider); @Override CollectionViewImpl createWidget(); @Override CollectionEditorDOMElement createDomElement(final GridLayer gridLayer,
                                                       final GridWidget gridWidget); @Override CollectionEditorDOMElement createDomElementInternal(final CollectionViewImpl collectionEditorView,
                                                               final GridLayer gridLayer,
                                                               final GridWidget gridWidget); @Override void registerHandlers(final CollectionViewImpl widget, final CollectionEditorDOMElement widgetDomElement); }
CollectionEditorSingletonDOMElementFactory extends BaseSingletonDOMElementFactory<String, CollectionViewImpl, CollectionEditorDOMElement> { @Override public CollectionEditorDOMElement createDomElement(final GridLayer gridLayer, final GridWidget gridWidget) { if (this.widget != null) { this.widget.close(); } this.widget = createWidget(); 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; } CollectionEditorSingletonDOMElementFactory(final GridLienzoPanel gridPanel,
                                                      final GridLayer gridLayer,
                                                      final GridWidget gridWidget,
                                                      final ScenarioSimulationContext scenarioSimulationContext,
                                                      final ViewsProvider viewsProvider); @Override CollectionViewImpl createWidget(); @Override CollectionEditorDOMElement createDomElement(final GridLayer gridLayer,
                                                       final GridWidget gridWidget); @Override CollectionEditorDOMElement createDomElementInternal(final CollectionViewImpl collectionEditorView,
                                                               final GridLayer gridLayer,
                                                               final GridWidget gridWidget); @Override void registerHandlers(final CollectionViewImpl widget, final CollectionEditorDOMElement widgetDomElement);  }