use of org.kie.workbench.common.stunner.core.client.shape.view.ShapeView in project kie-wb-common by kiegroup.
the class CanvasInPlaceTextEditorControlImpl method register.
@Override
public void register(final Element element) {
if (checkNotRegistered(element)) {
final Shape<?> shape = getShape(element.getUUID());
if (null != shape) {
final ShapeView shapeView = shape.getShapeView();
if (shapeView instanceof HasEventHandlers) {
final HasEventHandlers hasEventHandlers = (HasEventHandlers) shapeView;
if (hasEventHandlers.supports(ViewEventType.TEXT_DBL_CLICK)) {
final TextDoubleClickHandler clickHandler = new TextDoubleClickHandler() {
@Override
public void handle(final TextDoubleClickEvent event) {
CanvasInPlaceTextEditorControlImpl.this.show(element, event.getClientX(), event.getClientY());
}
};
hasEventHandlers.addHandler(ViewEventType.TEXT_DBL_CLICK, clickHandler);
registerHandler(shape.getUUID(), clickHandler);
// Change mouse cursor, if shape supports it.
if (hasEventHandlers.supports(ViewEventType.TEXT_ENTER) && hasEventHandlers.supports(ViewEventType.TEXT_EXIT)) {
final TextEnterHandler enterHandler = new TextEnterHandler() {
@Override
public void handle(TextEnterEvent event) {
canvasHandler.getAbstractCanvas().getView().setCursor(AbstractCanvas.Cursors.TEXT);
}
};
hasEventHandlers.addHandler(ViewEventType.TEXT_ENTER, enterHandler);
registerHandler(shape.getUUID(), enterHandler);
final TextExitHandler exitHandler = new TextExitHandler() {
@Override
public void handle(TextExitEvent event) {
canvasHandler.getAbstractCanvas().getView().setCursor(AbstractCanvas.Cursors.AUTO);
}
};
hasEventHandlers.addHandler(ViewEventType.TEXT_EXIT, exitHandler);
registerHandler(shape.getUUID(), exitHandler);
}
}
}
}
}
}
use of org.kie.workbench.common.stunner.core.client.shape.view.ShapeView in project kie-wb-common by kiegroup.
the class BPMNViewHandlersTest method testFontHandler.
@Test
@SuppressWarnings("unchecked")
public void testFontHandler() {
final FontHandler<BPMNViewDefinition, ShapeView> fontHandler = new BPMNShapeViewHandlers.FontHandlerBuilder<>().build();
final StartNoneEvent bean = new StartNoneEvent.StartNoneEventBuilder().build();
bean.getFontSet().getFontColor().setValue("fontColor");
bean.getFontSet().getFontFamily().setValue("fontFamily");
bean.getFontSet().getFontSize().setValue(12d);
bean.getFontSet().getFontBorderColor().setValue("borderColor");
bean.getFontSet().getFontBorderSize().setValue(8d);
fontHandler.handle(bean, view);
verify(view, times(1)).setTitleFontColor(eq("fontColor"));
verify(view, times(1)).setTitleFontFamily(eq("fontFamily"));
verify(view, times(1)).setTitleFontSize(eq(12d));
verify(view, times(1)).setTitleStrokeColor(eq("borderColor"));
verify(view, times(1)).setTitleStrokeWidth(eq(8d));
}
use of org.kie.workbench.common.stunner.core.client.shape.view.ShapeView in project kie-wb-common by kiegroup.
the class BPMNViewHandlersTest method testViewHandler.
@Test
@SuppressWarnings("unchecked")
public void testViewHandler() {
final ViewAttributesHandler<BPMNViewDefinition, ShapeView> fontHandler = new BPMNShapeViewHandlers.ViewAttributesHandlerBuilder<>().build();
final StartNoneEvent bean = new StartNoneEvent.StartNoneEventBuilder().build();
bean.getBackgroundSet().getBgColor().setValue("bgColor");
bean.getBackgroundSet().getBorderColor().setValue("borderColor");
bean.getBackgroundSet().getBorderSize().setValue(5d);
fontHandler.handle(bean, view);
verify(view, times(1)).setFillGradient(any(HasFillGradient.Type.class), eq("bgColor"), anyString());
verify(view, times(1)).setStrokeColor(eq("borderColor"));
verify(view, times(1)).setStrokeWidth(eq(5d));
}
Aggregations