use of org.kie.workbench.common.stunner.core.command.Command in project kie-wb-common by kiegroup.
the class BaseExpressionGrid method executeRenderQueueCommands.
@Override
protected void executeRenderQueueCommands(final boolean isSelectionLayer) {
final List<Pair<Group, GridRenderer.RendererCommand>> gridLineCommands = new ArrayList<>();
final List<Pair<Group, GridRenderer.RendererCommand>> allOtherCommands = new ArrayList<>();
final List<Pair<Group, GridRenderer.RendererCommand>> selectedCellsCommands = new ArrayList<>();
for (Pair<Group, List<GridRenderer.RendererCommand>> p : renderQueue) {
final Group parent = p.getK1();
final List<GridRenderer.RendererCommand> commands = p.getK2();
for (GridRenderer.RendererCommand command : commands) {
if (command instanceof GridRenderer.RenderSelectedCellsCommand) {
selectedCellsCommands.add(new Pair<>(parent, command));
} else if (command instanceof GridRenderer.RenderHeaderGridLinesCommand) {
gridLineCommands.add(new Pair<>(parent, command));
} else if (command instanceof GridRenderer.RenderBodyGridLinesCommand) {
gridLineCommands.add(new Pair<>(parent, command));
} else {
allOtherCommands.add(new Pair<>(parent, command));
}
}
}
final Predicate<Pair<Group, GridRenderer.RendererCommand>> renderHeader = (p) -> {
final GridRenderer.RendererCommand command = p.getK2();
if (isHeaderHidden()) {
return !(command instanceof GridRenderer.RendererHeaderCommand);
}
return true;
};
renderQueue.clear();
allOtherCommands.stream().filter(renderHeader).forEach(p -> addCommandToRenderQueue(p.getK1(), p.getK2()));
gridLineCommands.stream().filter(renderHeader).forEach(p -> addCommandToRenderQueue(p.getK1(), p.getK2()));
selectedCellsCommands.stream().filter(renderHeader).forEach(p -> addCommandToRenderQueue(p.getK1(), p.getK2()));
super.executeRenderQueueCommands(isSelectionLayer);
}
use of org.kie.workbench.common.stunner.core.command.Command in project kie-wb-common by kiegroup.
the class BaseExpressionGridGeneralTest method doTestSetTypeRefConsumer.
@SuppressWarnings("unchecked")
private void doTestSetTypeRefConsumer() {
grid.setTypeRefConsumer().accept(decision.getVariable(), TYPE_REF);
verify(sessionCommandManager).execute(eq(canvasHandler), commandCaptor.capture());
final Command command = commandCaptor.getValue();
assertThat(command).isInstanceOf(SetTypeRefCommand.class);
command.execute(canvasHandler);
}
use of org.kie.workbench.common.stunner.core.command.Command in project kie-wb-common by kiegroup.
the class BaseExpressionGridGeneralTest method doTestSetValueConsumer.
@SuppressWarnings("unchecked")
private void doTestSetValueConsumer(final boolean updateStunnerTitle, final Class... expectedCommandClasses) {
grid.setValueConsumer(updateStunnerTitle).accept(decision, NAME);
verify(sessionCommandManager).execute(eq(canvasHandler), commandCaptor.capture());
final Command command = commandCaptor.getValue();
GridFactoryCommandUtils.assertCommands(command, expectedCommandClasses);
command.execute(canvasHandler);
}
use of org.kie.workbench.common.stunner.core.command.Command in project kie-wb-common by kiegroup.
the class BaseExpressionGridGeneralTest method doTestClearValueConsumer.
@SuppressWarnings("unchecked")
private void doTestClearValueConsumer(final boolean updateStunnerTitle, final Class... expectedCommandClasses) {
grid.clearValueConsumer(updateStunnerTitle, new Name()).accept(decision);
verify(sessionCommandManager).execute(eq(canvasHandler), commandCaptor.capture());
final Command command = commandCaptor.getValue();
GridFactoryCommandUtils.assertCommands(command, expectedCommandClasses);
command.execute(canvasHandler);
}
use of org.kie.workbench.common.stunner.core.command.Command in project kie-wb-common by kiegroup.
the class LiteralExpressionPMMLDocumentModelGridTest method testNewCellHasValueCommand.
@Test
public void testNewCellHasValueCommand() {
setupGrid(0);
final List<String> parameterNames = asList("param1", "param2");
final String modelName = (String) tupleWithValue.getValue().getValue();
when(pmmlDocumentMetadataProvider.getPMMLDocumentModelParameterNames(eq(DOCUMENT_NAME), eq(modelName))).thenReturn(parameterNames);
final Command command = grid.newCellHasValueCommand().apply(tupleWithValue);
verify(pmmlDocumentMetadataProvider).getPMMLDocumentModelParameterNames(eq(DOCUMENT_NAME), eq(modelName));
GridFactoryCommandUtils.assertCommands(command, SetCellValueCommand.class, SetParametersCommand.class);
final SetParametersCommand setParametersCommand = (SetParametersCommand) ((CompositeCommand) command).getCommands().get(1);
setParametersCommand.execute(canvasHandler);
assertThat(grandParentExpression.getFormalParameter().stream().map(ii -> ii.getName().getValue()).collect(Collectors.toList())).containsExactly("param1", "param2");
}
Aggregations