Search in sources :

Example 6 with MouseClickHandler

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

the class ToolboxControlImpl method register.

@Override
@SuppressWarnings("unchecked")
public void register(final Element element) {
    if (checkNotRegistered(element) && supportsToolbox(element)) {
        final Shape shape = canvasHandler.getCanvas().getShape(element.getUUID());
        final HasEventHandlers hasEventHandlers = (HasEventHandlers) shape.getShapeView();
        if (hasEventHandlers.supports(ViewEventType.MOUSE_CLICK)) {
            final MouseClickHandler clickHandler = new MouseClickHandler() {

                @Override
                public void handle(final MouseClickEvent event) {
                    if (event.isButtonLeft()) {
                        show(element);
                    }
                }
            };
            hasEventHandlers.addHandler(ViewEventType.MOUSE_CLICK, clickHandler);
            registerHandler(element.getUUID(), clickHandler);
        }
    }
}
Also used : Shape(org.kie.workbench.common.stunner.core.client.shape.Shape) MouseClickHandler(org.kie.workbench.common.stunner.core.client.shape.view.event.MouseClickHandler) HasEventHandlers(org.kie.workbench.common.stunner.core.client.shape.view.HasEventHandlers) MouseClickEvent(org.kie.workbench.common.stunner.core.client.shape.view.event.MouseClickEvent)

Aggregations

MouseClickEvent (org.kie.workbench.common.stunner.core.client.shape.view.event.MouseClickEvent)6 MouseClickHandler (org.kie.workbench.common.stunner.core.client.shape.view.event.MouseClickHandler)6 Test (org.junit.Test)3 CanvasSelectionEvent (org.kie.workbench.common.stunner.core.client.canvas.event.selection.CanvasSelectionEvent)3 CanvasClearSelectionEvent (org.kie.workbench.common.stunner.core.client.canvas.event.selection.CanvasClearSelectionEvent)2 HasEventHandlers (org.kie.workbench.common.stunner.core.client.shape.view.HasEventHandlers)2 Layer (org.kie.workbench.common.stunner.core.client.canvas.Layer)1 Shape (org.kie.workbench.common.stunner.core.client.shape.Shape)1 ShapeView (org.kie.workbench.common.stunner.core.client.shape.view.ShapeView)1