use of org.kie.workbench.common.stunner.core.client.shape.view.HasEventHandlers in project kie-wb-common by kiegroup.
the class LienzoSelectionControl method onRegister.
@Override
protected void onRegister(final Element element) {
super.onRegister(element);
final Shape<?> shape = getSelectionControl().getCanvas().getShape(element.getUUID());
if (null != shape) {
final ShapeView shapeView = shape.getShapeView();
if (shapeView instanceof HasEventHandlers) {
final HasEventHandlers hasEventHandlers = (HasEventHandlers) shapeView;
if (hasEventHandlers.supports(ViewEventType.MOUSE_CLICK)) {
final MouseClickHandler clickHandler = new MouseClickHandler() {
@Override
public void handle(final MouseClickEvent event) {
if (event.isButtonLeft() || event.isButtonRight()) {
singleSelect(element);
}
}
};
hasEventHandlers.addHandler(ViewEventType.MOUSE_CLICK, clickHandler);
registerHandler(shape.getUUID(), clickHandler);
}
}
}
}
use of org.kie.workbench.common.stunner.core.client.shape.view.HasEventHandlers in project kie-wb-common by kiegroup.
the class ResizeControlImpl method registerResizeHandlers.
@SuppressWarnings("unchecked")
private void registerResizeHandlers(final Element element, final Shape<?> shape) {
if (shape.getShapeView() instanceof HasEventHandlers) {
final HasEventHandlers hasEventHandlers = (HasEventHandlers) shape.getShapeView();
final ResizeHandler resizeHandler = new ResizeHandler() {
@Override
public void start(final ResizeEvent event) {
}
@Override
public void handle(final ResizeEvent event) {
}
@Override
public void end(final ResizeEvent event) {
LOGGER.log(Level.FINE, "Shape [" + element.getUUID() + "] resized to size {" + event.getWidth() + ", " + event.getHeight() + "] " + "& Coordinates [" + event.getX() + ", " + event.getY() + "]");
final Shape shape = canvasHandler.getCanvas().getShape(element.getUUID());
final double x = shape.getShapeView().getShapeX();
final double y = shape.getShapeView().getShapeY();
final CommandResult<CanvasViolation> result = doResize(element, x + event.getX(), y + event.getY(), event.getWidth(), event.getHeight());
if (CommandUtils.isError(result)) {
LOGGER.log(Level.WARNING, "Command failed at resize end [result=" + result + "]");
}
}
};
hasEventHandlers.addHandler(ViewEventType.RESIZE, resizeHandler);
registerHandler(element.getUUID(), resizeHandler);
}
}
use of org.kie.workbench.common.stunner.core.client.shape.view.HasEventHandlers 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.HasEventHandlers in project kie-wb-common by kiegroup.
the class AbstractCanvasHandlerRegistrationControl method doDeregisterHandler.
private void doDeregisterHandler(final Shape shape, final ViewHandler<?> handler) {
if (null != shape && null != handler) {
final HasEventHandlers hasEventHandlers = (HasEventHandlers) shape.getShapeView();
hasEventHandlers.removeHandler(handler);
handlers.remove(shape.getUUID());
disabledHandlers.remove(shape.getUUID());
}
}
use of org.kie.workbench.common.stunner.core.client.shape.view.HasEventHandlers 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);
}
}
}
Aggregations