Search in sources :

Example 1 with TextDoubleClickEvent

use of org.kie.workbench.common.stunner.core.client.shape.view.event.TextDoubleClickEvent 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);
                    }
                }
            }
        }
    }
}
Also used : TextEnterEvent(org.kie.workbench.common.stunner.core.client.shape.view.event.TextEnterEvent) TextEnterHandler(org.kie.workbench.common.stunner.core.client.shape.view.event.TextEnterHandler) TextDoubleClickEvent(org.kie.workbench.common.stunner.core.client.shape.view.event.TextDoubleClickEvent) TextExitHandler(org.kie.workbench.common.stunner.core.client.shape.view.event.TextExitHandler) HasEventHandlers(org.kie.workbench.common.stunner.core.client.shape.view.HasEventHandlers) ShapeView(org.kie.workbench.common.stunner.core.client.shape.view.ShapeView) TextExitEvent(org.kie.workbench.common.stunner.core.client.shape.view.event.TextExitEvent) TextDoubleClickHandler(org.kie.workbench.common.stunner.core.client.shape.view.event.TextDoubleClickHandler)

Example 2 with TextDoubleClickEvent

use of org.kie.workbench.common.stunner.core.client.shape.view.event.TextDoubleClickEvent in project kie-wb-common by kiegroup.

the class WiresTextDecorator method registerDoubleClickHandler.

private void registerDoubleClickHandler() {
    HandlerRegistration registration = text.addNodeMouseDoubleClickHandler(event -> {
        if (null != textDblClickEventViewHandler) {
            eventHandlerManager.get().skipClickHandler();
            final TextDoubleClickEvent e = new TextDoubleClickEvent(event.getX(), event.getY(), event.getMouseEvent().getClientX(), event.getMouseEvent().getClientY());
            textDblClickEventViewHandler.handle(e);
            eventHandlerManager.get().restoreClickHandler();
        }
    });
    eventHandlerManager.get().addHandlersRegistration(ViewEventType.TEXT_DBL_CLICK, registration);
}
Also used : HandlerRegistration(com.google.gwt.event.shared.HandlerRegistration) TextDoubleClickEvent(org.kie.workbench.common.stunner.core.client.shape.view.event.TextDoubleClickEvent)

Aggregations

TextDoubleClickEvent (org.kie.workbench.common.stunner.core.client.shape.view.event.TextDoubleClickEvent)2 HandlerRegistration (com.google.gwt.event.shared.HandlerRegistration)1 HasEventHandlers (org.kie.workbench.common.stunner.core.client.shape.view.HasEventHandlers)1 ShapeView (org.kie.workbench.common.stunner.core.client.shape.view.ShapeView)1 TextDoubleClickHandler (org.kie.workbench.common.stunner.core.client.shape.view.event.TextDoubleClickHandler)1 TextEnterEvent (org.kie.workbench.common.stunner.core.client.shape.view.event.TextEnterEvent)1 TextEnterHandler (org.kie.workbench.common.stunner.core.client.shape.view.event.TextEnterHandler)1 TextExitEvent (org.kie.workbench.common.stunner.core.client.shape.view.event.TextExitEvent)1 TextExitHandler (org.kie.workbench.common.stunner.core.client.shape.view.event.TextExitHandler)1