Search in sources :

Example 1 with CollectionEditorDOMElement

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));
}
Also used : SaveEditorEventHandler(org.drools.workbench.screens.scenariosimulation.client.handlers.SaveEditorEventHandler) SaveEditorEvent(org.drools.workbench.screens.scenariosimulation.client.events.SaveEditorEvent) CloseCompositeEvent(org.drools.workbench.screens.scenariosimulation.client.events.CloseCompositeEvent) CollectionEditorDOMElement(org.drools.workbench.screens.scenariosimulation.client.domelements.CollectionEditorDOMElement) CloseCompositeEventHandler(org.drools.workbench.screens.scenariosimulation.client.handlers.CloseCompositeEventHandler) Test(org.junit.Test)

Example 2 with CollectionEditorDOMElement

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;
}
Also used : RULE(org.drools.scenariosimulation.api.model.ScenarioSimulationModel.Type.RULE) ContextMenuEvent(com.google.gwt.event.dom.client.ContextMenuEvent) ScenarioSimulationModel(org.drools.scenariosimulation.api.model.ScenarioSimulationModel) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) GridColumn(org.uberfire.ext.wires.core.grids.client.model.GridColumn) HashMap(java.util.HashMap) CollectionEditorDOMElement(org.drools.workbench.screens.scenariosimulation.client.domelements.CollectionEditorDOMElement) ScenarioSimulationContext(org.drools.workbench.screens.scenariosimulation.client.commands.ScenarioSimulationContext) AbstractScesimModel(org.drools.scenariosimulation.api.model.AbstractScesimModel) GridLienzoPanel(org.uberfire.ext.wires.core.grids.client.widget.layer.impl.GridLienzoPanel) CollectionViewImpl(org.drools.workbench.screens.scenariosimulation.client.collectioneditor.CollectionViewImpl) VALUE(org.drools.scenariosimulation.api.utils.ConstantsHolder.VALUE) ScenarioSimulationSharedUtils(org.drools.scenariosimulation.api.utils.ScenarioSimulationSharedUtils) Map(java.util.Map) AbstractScesimGridModel(org.drools.workbench.screens.scenariosimulation.client.models.AbstractScesimGridModel) ViewsProvider(org.drools.workbench.screens.scenariosimulation.client.utils.ViewsProvider) KeyDownEvent(com.google.gwt.event.dom.client.KeyDownEvent) ScenarioSimulationUtils(org.drools.workbench.screens.scenariosimulation.client.utils.ScenarioSimulationUtils) BaseSingletonDOMElementFactory(org.uberfire.ext.wires.core.grids.client.widget.dom.single.impl.BaseSingletonDOMElementFactory) ScenarioSimulationUtils.isSimpleJavaType(org.drools.workbench.screens.scenariosimulation.client.utils.ScenarioSimulationUtils.isSimpleJavaType) ScenarioGrid(org.drools.workbench.screens.scenariosimulation.client.widgets.ScenarioGrid) MouseWheelEvent(com.google.gwt.event.dom.client.MouseWheelEvent) GridData(org.uberfire.ext.wires.core.grids.client.model.GridData) Collectors(java.util.stream.Collectors) GridWidget(org.uberfire.ext.wires.core.grids.client.widget.grid.GridWidget) GridLayer(org.uberfire.ext.wires.core.grids.client.widget.layer.GridLayer) List(java.util.List) FactMapping(org.drools.scenariosimulation.api.model.FactMapping) Optional(java.util.Optional) AbstractScesimData(org.drools.scenariosimulation.api.model.AbstractScesimData) FactMapping(org.drools.scenariosimulation.api.model.FactMapping) KeyDownEvent(com.google.gwt.event.dom.client.KeyDownEvent) MouseWheelEvent(com.google.gwt.event.dom.client.MouseWheelEvent) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) ScenarioGrid(org.drools.workbench.screens.scenariosimulation.client.widgets.ScenarioGrid) GridData(org.uberfire.ext.wires.core.grids.client.model.GridData) GridColumn(org.uberfire.ext.wires.core.grids.client.model.GridColumn)

Aggregations

CollectionEditorDOMElement (org.drools.workbench.screens.scenariosimulation.client.domelements.CollectionEditorDOMElement)2 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)1 ContextMenuEvent (com.google.gwt.event.dom.client.ContextMenuEvent)1 KeyDownEvent (com.google.gwt.event.dom.client.KeyDownEvent)1 MouseWheelEvent (com.google.gwt.event.dom.client.MouseWheelEvent)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 Optional (java.util.Optional)1 Collectors (java.util.stream.Collectors)1 AbstractScesimData (org.drools.scenariosimulation.api.model.AbstractScesimData)1 AbstractScesimModel (org.drools.scenariosimulation.api.model.AbstractScesimModel)1 FactMapping (org.drools.scenariosimulation.api.model.FactMapping)1 ScenarioSimulationModel (org.drools.scenariosimulation.api.model.ScenarioSimulationModel)1 RULE (org.drools.scenariosimulation.api.model.ScenarioSimulationModel.Type.RULE)1 VALUE (org.drools.scenariosimulation.api.utils.ConstantsHolder.VALUE)1 ScenarioSimulationSharedUtils (org.drools.scenariosimulation.api.utils.ScenarioSimulationSharedUtils)1 CollectionViewImpl (org.drools.workbench.screens.scenariosimulation.client.collectioneditor.CollectionViewImpl)1 ScenarioSimulationContext (org.drools.workbench.screens.scenariosimulation.client.commands.ScenarioSimulationContext)1 CloseCompositeEvent (org.drools.workbench.screens.scenariosimulation.client.events.CloseCompositeEvent)1