@SuppressWarnings("unchecked") public Canvas addChild(final Shape parent, final Shape child) { getView().addChild(parent.getShapeView(), child.getShapeView()); return this; }
@SuppressWarnings("unchecked") public Canvas dock(final Shape parent, final Shape child) { getView().dock(parent.getShapeView(), child.getShapeView()); return this; }
@SuppressWarnings("unchecked") public CaseManagementCanvas addChild(final Shape parent, final Shape child, final int index) { ((CaseManagementCanvasView) getView()).addChildShape(parent.getShapeView(), child.getShapeView(), index); return this; }
@Override protected void clearShapes() { // the child shapes are not ordered // clear the child shapes recursively in the right order shapes.values().stream().filter(s -> { CaseManagementShapeView view = (CaseManagementShapeView) s.getShapeView(); return !(view.getParent() instanceof CaseManagementShapeView); }).collect(Collectors.toList()).forEach(this::clearShape); shapes.clear(); }
private boolean setShapeEditMode(final boolean editMode) { final Shape<?> shape = getShape(this.uuid); if (null != shape) { final HasTitle hasTitle = (HasTitle) shape.getShapeView(); final double alpha = editMode ? SHAPE_EDIT_ALPHA : SHAPE_NOT_EDIT_ALPHA; shape.getShapeView().setFillAlpha(alpha); hasTitle.setTitleAlpha(alpha); return true; } return false; }
@Override @SuppressWarnings("unchecked") public void removeChild(final S child) { final V view = getCompositeShapeView(); children.remove(child); view.removeChild(child.getShapeView()); }
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()); } }
private void clearShape(Shape shape) { CaseManagementShapeView view = (CaseManagementShapeView) shape.getShapeView(); List<Shape> childShapes = view.getChildShapes().toList().stream() .map(v -> shapes.get(((CaseManagementShapeView) v).getUUID())).collect(Collectors.toList()); deleteShape(shape); childShapes.forEach(this::clearShape); }
@Override @SuppressWarnings("unchecked") public void addChild(final S child, final Layout layout) { final V view = getCompositeShapeView(); children.add(child); view.addChild(child.getShapeView(), layout); }
@Override @SuppressWarnings("unchecked") public void addChild(final S child, final Layout layout) { final HasChildren<ShapeView<?>> view = (HasChildren<ShapeView<?>>) getShapeView(); view.addChild(child.getShapeView(), layout); children.add(child); }
private void doDeregisterHandler(final Shape shape, final ViewHandler<?> handler) { if (null != shape && null != handler) { final HasEventHandlers hasEventHandlers = (HasEventHandlers) shape.getShapeView(); hasEventHandlers.removeHandler(handler); disabledHandlers.putIfAbsent(shape.getUUID(), new HashSet<>()); disabledHandlers.get(shape.getUUID()).add(handler); } } }
@Override public DragProxy<AbstractCanvas, Shape<?>, DragProxyCallback> show(final Shape<?> item, final int x, final int y, final DragProxyCallback callback) { clear(); shapeViewDragProxyFactory.show(item.getShapeView(), x, y, callback); return this; }
@SuppressWarnings("unchecked") public Canvas deleteShapeFromView(final Shape shape) { getView().delete(shape.getShapeView()); return this; }
private static void moveShapeToTop(final AbstractCanvasHandler canvasHandler, final String uuid) { final Shape shape = canvasHandler.getCanvas().getShape(uuid); if (null != shape) { shape.getShapeView().moveToTop(); } } }
@Override public V init(final ActionsToolbox toolbox) { return init(toolbox, (WiresCanvas) toolbox.getCanvas(), (WiresShape) toolbox.getShape().getShapeView()); }
private void updateDockedNodesPosition(CompositeCommand.Builder<AbstractCanvasHandler, CanvasViolation> commandBuilder, Node<View<?>, Edge> node) { GraphUtils.getDockedNodes(node) .stream() .forEach(docked -> { final Shape shape = canvasHandler.getCanvas().getShape(docked.getUUID()); final double dockedX = shape.getShapeView().getShapeX(); final double dockedY = shape.getShapeView().getShapeY(); commandBuilder.addCommand(canvasCommandFactory.updatePosition(docked, new Point2D(dockedX, dockedY))); }); }
@Before public void setup() { when(canvasHandler.getCanvas()).thenReturn(canvas); when(shape.getShapeView()).thenReturn(shapeView); event = new CanvasFocusedShapeEvent(canvasHandler, uuid); }
@SuppressWarnings("unchecked") public Canvas addShapeIntoView(final Shape shape) { if (shape.getUUID() == null) { shape.setUUID(UUID.uuid()); } getView().add(shape.getShapeView()); return this; }
@SuppressWarnings("unchecked") private void assertShapeConstruction(final BPMNDefinition definition, final Consumer<Shape> o) { when(definitionAdapter.getId(eq(definition))).thenReturn(DefinitionId.build(definition.getClass().getName())); final Shape<? extends ShapeView> shape = factory.newShape(definition); assertNotNull(shape); assertNotNull(shape.getShapeView()); o.accept(shape); }
@Test public void checkCMDiagram() { assertShapeConstruction(new CaseManagementDiagram(), (shape) -> { assertNotNull(shape.getShapeView()); assertTrue(shape instanceof CaseManagementShape); assertTrue(shape.getShapeView() instanceof CaseManagementDiagramShapeView); assertSame(((CaseManagementShapeView) shape.getShapeView()).getPrimitive(), rectangleShape); }); assertShapeGlyph(new CaseManagementDiagram()); }