Search in sources :

Example 1 with ExpressionGridCache

use of org.kie.workbench.common.dmn.client.widgets.grid.ExpressionGridCache in project kie-wb-common by kiegroup.

the class ExpressionEditorTest method setUp.

@Before
@SuppressWarnings("unchecked")
public void setUp() throws Exception {
    this.decision = new Decision();
    this.expressionGridCache = new ExpressionGridCacheImpl();
    this.definitions = new Definitions();
    this.definitions.setName(new Name(DRG_NAME));
    testedEditor = spy(new ExpressionEditor(view, decisionNavigator, dmnGraphUtils, dmnDiagramsSession, drdNameChanger));
    testedEditor.bind(dmnSession);
    when(session.getCanvasControl(eq(ExpressionGridCache.class))).thenReturn(expressionGridCache);
    when(dmnGraphUtils.getModelDefinitions()).thenReturn(definitions);
    when(dmnDiagramsSession.getCurrentDMNDiagramElement()).thenReturn(Optional.of(dmnDiagramElement));
}
Also used : Definitions(org.kie.workbench.common.dmn.api.definition.model.Definitions) ExpressionGridCacheImpl(org.kie.workbench.common.dmn.client.widgets.grid.ExpressionGridCacheImpl) ExpressionGridCache(org.kie.workbench.common.dmn.client.widgets.grid.ExpressionGridCache) Decision(org.kie.workbench.common.dmn.api.definition.model.Decision) Name(org.kie.workbench.common.dmn.api.property.dmn.Name) HasName(org.kie.workbench.common.dmn.api.definition.HasName) Before(org.junit.Before)

Example 2 with ExpressionGridCache

use of org.kie.workbench.common.dmn.client.widgets.grid.ExpressionGridCache in project kie-wb-common by kiegroup.

the class UndefinedExpressionGrid method onExpressionTypeChanged.

public void onExpressionTypeChanged(final ExpressionType type) {
    final Optional<Expression> expression = expressionEditorDefinitionsSupplier.get().stream().filter(e -> e.getType().equals(type)).map(ExpressionEditorDefinition::getModelClass).findFirst().get();
    final Optional<ExpressionEditorDefinition<Expression>> expressionEditorDefinition = expressionEditorDefinitionsSupplier.get().getExpressionEditorDefinition(expression);
    expressionEditorDefinition.ifPresent(ed -> {
        sessionCommandManager.execute((AbstractCanvasHandler) sessionManager.getCurrentSession().getCanvasHandler(), new SetCellValueCommand(parent, nodeUUID, hasExpression, () -> expression, expressionGridCache, (editor) -> {
            resize(BaseExpressionGrid.RESIZE_EXISTING);
            editor.ifPresent(BaseExpressionGrid::selectFirstCell);
        }, () -> {
            resize(BaseExpressionGrid.RESIZE_EXISTING_MINIMUM);
            selectCell(0, 0, false, false);
        }, () -> {
            Optional<BaseExpressionGrid<? extends Expression, ? extends GridData, ? extends BaseUIModelMapper>> editor = Optional.empty();
            if (nodeUUID.isPresent()) {
                final String uuid = nodeUUID.get();
                editor = expressionGridCache.getExpressionGrid(uuid);
            }
            if (!editor.isPresent()) {
                ed.enrich(nodeUUID, hasExpression, expression);
                editor = ed.getEditor(parent, nodeUUID, hasExpression, hasName, isOnlyVisualChangeAllowed, nesting);
            }
            return editor;
        }));
    });
}
Also used : CellEditorControlsView(org.kie.workbench.common.dmn.client.widgets.grid.controls.container.CellEditorControlsView) DMNGridData(org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridData) DefinitionUtils(org.kie.workbench.common.stunner.core.util.DefinitionUtils) ExpressionEditorDefinition(org.kie.workbench.common.dmn.client.editors.expressions.types.ExpressionEditorDefinition) DelegatingGridWidgetCellSelectorMouseEventHandler(org.kie.workbench.common.dmn.client.widgets.grid.handlers.DelegatingGridWidgetCellSelectorMouseEventHandler) BaseDelegatingExpressionGrid(org.kie.workbench.common.dmn.client.widgets.grid.BaseDelegatingExpressionGrid) HasListSelectorControl(org.kie.workbench.common.dmn.client.widgets.grid.controls.list.HasListSelectorControl) ListSelectorView(org.kie.workbench.common.dmn.client.widgets.grid.controls.list.ListSelectorView) BaseExpressionGrid(org.kie.workbench.common.dmn.client.widgets.grid.BaseExpressionGrid) DMNGridLayer(org.kie.workbench.common.dmn.client.widgets.layer.DMNGridLayer) ExpressionType(org.kie.workbench.common.dmn.client.editors.expressions.types.ExpressionType) BaseExpressionGridRenderer(org.kie.workbench.common.dmn.client.widgets.grid.BaseExpressionGridRenderer) GridSelectionManager(org.uberfire.ext.wires.core.grids.client.widget.layer.GridSelectionManager) ExpressionEditorDefinitions(org.kie.workbench.common.dmn.client.editors.expressions.types.ExpressionEditorDefinitions) Supplier(java.util.function.Supplier) ArrayList(java.util.ArrayList) ExpressionEditorChanged(org.kie.workbench.common.dmn.client.widgets.grid.model.ExpressionEditorChanged) RefreshFormPropertiesEvent(org.kie.workbench.common.stunner.forms.client.event.RefreshFormPropertiesEvent) ReadOnlyProvider(org.kie.workbench.common.stunner.core.client.ReadOnlyProvider) HasExpression(org.kie.workbench.common.dmn.api.definition.HasExpression) DMNGridColumn(org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridColumn) GridCellTuple(org.kie.workbench.common.dmn.client.widgets.grid.model.GridCellTuple) NodeMouseEventHandler(org.uberfire.ext.wires.core.grids.client.widget.grid.NodeMouseEventHandler) SessionManager(org.kie.workbench.common.stunner.core.client.api.SessionManager) BaseUIModelMapper(org.kie.workbench.common.dmn.client.widgets.grid.model.BaseUIModelMapper) Event(javax.enterprise.event.Event) DMNGridPanel(org.kie.workbench.common.dmn.client.widgets.panel.DMNGridPanel) EventPropagationMode(com.ait.lienzo.shared.core.types.EventPropagationMode) UndefinedExpressionSelectorPopoverView(org.kie.workbench.common.dmn.client.editors.expressions.types.undefined.selector.UndefinedExpressionSelectorPopoverView) TranslationService(org.jboss.errai.ui.client.local.spi.TranslationService) ExpressionGridCache(org.kie.workbench.common.dmn.client.widgets.grid.ExpressionGridCache) AbstractCanvasHandler(org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvasHandler) GridData(org.uberfire.ext.wires.core.grids.client.model.GridData) SessionCommandManager(org.kie.workbench.common.stunner.core.client.command.SessionCommandManager) DomainObject(org.kie.workbench.common.stunner.core.domainobject.DomainObject) SetCellValueCommand(org.kie.workbench.common.dmn.client.commands.expressions.types.undefined.SetCellValueCommand) DMNModelInstrumentedBase(org.kie.workbench.common.dmn.api.definition.model.DMNModelInstrumentedBase) HasName(org.kie.workbench.common.dmn.api.definition.HasName) GridPinnedModeManager(org.uberfire.ext.wires.core.grids.client.widget.layer.pinning.GridPinnedModeManager) List(java.util.List) DomainObjectSelectionEvent(org.kie.workbench.common.stunner.core.client.canvas.event.selection.DomainObjectSelectionEvent) DefaultCanvasCommandFactory(org.kie.workbench.common.dmn.client.commands.factory.DefaultCanvasCommandFactory) ExpressionEditorGridRow(org.kie.workbench.common.dmn.client.widgets.grid.model.ExpressionEditorGridRow) Optional(java.util.Optional) DelegatingGridWidgetEditCellMouseEventHandler(org.kie.workbench.common.dmn.client.widgets.grid.handlers.DelegatingGridWidgetEditCellMouseEventHandler) Expression(org.kie.workbench.common.dmn.api.definition.model.Expression) Collections(java.util.Collections) Optional(java.util.Optional) HasExpression(org.kie.workbench.common.dmn.api.definition.HasExpression) Expression(org.kie.workbench.common.dmn.api.definition.model.Expression) ExpressionEditorDefinition(org.kie.workbench.common.dmn.client.editors.expressions.types.ExpressionEditorDefinition) SetCellValueCommand(org.kie.workbench.common.dmn.client.commands.expressions.types.undefined.SetCellValueCommand)

Aggregations

HasName (org.kie.workbench.common.dmn.api.definition.HasName)2 ExpressionGridCache (org.kie.workbench.common.dmn.client.widgets.grid.ExpressionGridCache)2 EventPropagationMode (com.ait.lienzo.shared.core.types.EventPropagationMode)1 ArrayList (java.util.ArrayList)1 Collections (java.util.Collections)1 List (java.util.List)1 Optional (java.util.Optional)1 Supplier (java.util.function.Supplier)1 Event (javax.enterprise.event.Event)1 TranslationService (org.jboss.errai.ui.client.local.spi.TranslationService)1 Before (org.junit.Before)1 HasExpression (org.kie.workbench.common.dmn.api.definition.HasExpression)1 DMNModelInstrumentedBase (org.kie.workbench.common.dmn.api.definition.model.DMNModelInstrumentedBase)1 Decision (org.kie.workbench.common.dmn.api.definition.model.Decision)1 Definitions (org.kie.workbench.common.dmn.api.definition.model.Definitions)1 Expression (org.kie.workbench.common.dmn.api.definition.model.Expression)1 Name (org.kie.workbench.common.dmn.api.property.dmn.Name)1 SetCellValueCommand (org.kie.workbench.common.dmn.client.commands.expressions.types.undefined.SetCellValueCommand)1 DefaultCanvasCommandFactory (org.kie.workbench.common.dmn.client.commands.factory.DefaultCanvasCommandFactory)1 ExpressionEditorDefinition (org.kie.workbench.common.dmn.client.editors.expressions.types.ExpressionEditorDefinition)1