use of org.kie.workbench.common.dmn.client.shape.view.decisionservice.DecisionServiceSVGShapeView in project kie-wb-common by kiegroup.
the class DecisionServiceMoveDividerControlTest method testRegisterDecisionServiceElementDragEnd.
@Test
@SuppressWarnings("unchecked")
public void testRegisterDecisionServiceElementDragEnd() {
final DefinitionManager definitionManager = mock(DefinitionManager.class);
final AdapterManager adapterManager = mock(AdapterManager.class);
final AdapterRegistry adapterRegistry = mock(AdapterRegistry.class);
final PropertyAdapter<Object, Object> propertyAdapter = mock(PropertyAdapter.class);
final DefinitionAdapter<Object> definitionAdapter = mock(DefinitionAdapter.class);
final DecisionServiceDividerLineY dividerLineY = new DecisionServiceDividerLineY();
final Optional dividerYProperty = Optional.of(dividerLineY);
final UpdateElementPropertyCommand updateElementPropertyCommand = mock(UpdateElementPropertyCommand.class);
final DecisionService decisionService = mock(DecisionService.class);
final DecisionServiceSVGShapeView decisionServiceShapeView = mock(DecisionServiceSVGShapeView.class);
final DragEvent dragEvent = mock(DragEvent.class);
when(canvasHandler.getDefinitionManager()).thenReturn(definitionManager);
when(definitionManager.adapters()).thenReturn(adapterManager);
when(adapterManager.registry()).thenReturn(adapterRegistry);
when(adapterManager.forProperty()).thenReturn(propertyAdapter);
when(adapterRegistry.getDefinitionAdapter(Mockito.<Class>any())).thenReturn(definitionAdapter);
when(definitionAdapter.getProperty(decisionService, DIVIDER_Y_PROPERTY_ID)).thenReturn(dividerYProperty);
when(propertyAdapter.getId(dividerLineY)).thenReturn(DIVIDER_Y_PROPERTY_ID);
when(canvasCommandFactory.updatePropertyValue(eq(element), eq(DIVIDER_Y_PROPERTY_ID), Mockito.<Object>any())).thenReturn(updateElementPropertyCommand);
when(definition.getDefinition()).thenReturn(decisionService);
when(shape.getShapeView()).thenReturn(decisionServiceShapeView);
control.register(element);
verify(decisionServiceShapeView).addDividerDragHandler(dragHandlerCaptor.capture());
when(decisionServiceShapeView.getDividerLineY()).thenReturn(DIVIDER_Y);
final DragHandler dragHandler = dragHandlerCaptor.getValue();
dragHandler.end(dragEvent);
verify(canvasCommandFactory).updatePropertyValue(eq(element), eq(DIVIDER_Y_PROPERTY_ID), eq(DIVIDER_Y));
verify(commandManager).execute(eq(canvasHandler), eq(updateElementPropertyCommand));
}
use of org.kie.workbench.common.dmn.client.shape.view.decisionservice.DecisionServiceSVGShapeView in project kie-wb-common by kiegroup.
the class DecisionServiceMoveDividerControl method register.
@Override
@SuppressWarnings("unchecked")
public void register(final Element element) {
if (checkNotRegistered(element)) {
final Object definition = ((Definition) element.getContent()).getDefinition();
if (!isDecisionServiceDefinition(definition)) {
return;
}
final Canvas<?> canvas = canvasHandler.getCanvas();
final Shape<?> shape = canvas.getShape(element.getUUID());
final ShapeView<?> shapeView = shape.getShapeView();
if (!isDecisionServiceShapeView(shapeView)) {
return;
}
final DecisionServiceSVGShapeView decisionServiceShapeView = (DecisionServiceSVGShapeView) shapeView;
final DragHandler dragHandler = new DragHandler() {
@Override
public void end(final DragEvent event) {
final CommandResult<CanvasViolation> result = doMoveDivider(element, decisionServiceShapeView.getDividerLineY());
if (CommandUtils.isError(result)) {
LOGGER.log(Level.WARNING, "Command failed at resize end [result=" + result + "]");
}
}
};
decisionServiceShapeView.addDividerDragHandler(dragHandler);
registerHandler(element.getUUID(), dragHandler);
}
}
use of org.kie.workbench.common.dmn.client.shape.view.decisionservice.DecisionServiceSVGShapeView in project kie-wb-common by kiegroup.
the class DMNDecisionServiceSVGMutableShapeImpl method applyCustomProperties.
@Override
protected void applyCustomProperties(final Node<View<DecisionService>, Edge> element, final MutationContext mutationContext) {
final DecisionService instance = getDefinition(element);
final DecisionServiceSVGShapeView decisionServiceSVGShapeView = (DecisionServiceSVGShapeView) getShapeView();
decisionServiceSVGShapeView.setDividerLineY(instance.getDividerLineY().getValue());
}
use of org.kie.workbench.common.dmn.client.shape.view.decisionservice.DecisionServiceSVGShapeView in project kie-wb-common by kiegroup.
the class DecisionServiceMoveDividerControlTest method testRegisterDecisionServiceElement.
@Test
@SuppressWarnings("unchecked")
public void testRegisterDecisionServiceElement() {
final DecisionService decisionService = mock(DecisionService.class);
final DecisionServiceSVGShapeView decisionServiceShapeView = mock(DecisionServiceSVGShapeView.class);
when(definition.getDefinition()).thenReturn(decisionService);
when(shape.getShapeView()).thenReturn(decisionServiceShapeView);
control.register(element);
verify(control).registerHandler(Mockito.<String>any(), Mockito.<ViewHandler>any());
}
Aggregations