use of org.kie.workbench.common.stunner.core.client.shape.Shape in project kie-wb-common by kiegroup.
the class ShapeDefFunctionalFactoryTest method testCreateShapeForDef1.
@Test
@SuppressWarnings("unchecked")
public void testCreateShapeForDef1() {
this.tested.set(TestShapeDefType1.class, shapeDef1FactoryFunction);
final Shape shape = this.tested.newShape(definitionBean, shapeDef1);
assertNotNull(shape);
assertEquals(shape1, shape);
}
use of org.kie.workbench.common.stunner.core.client.shape.Shape in project kie-wb-common by kiegroup.
the class ShapeDefFunctionalFactoryTest method testCreateShapeForDef2.
@Test
@SuppressWarnings("unchecked")
public void testCreateShapeForDef2() {
this.tested.set(TestShapeDefType2.class, shapeDef2FactoryFunction);
final Shape shape = this.tested.newShape(definitionBean, shapeDef2);
assertNotNull(shape);
assertEquals(shape2, shape);
}
use of org.kie.workbench.common.stunner.core.client.shape.Shape in project kie-wb-common by kiegroup.
the class AbstractCanvasHandler method register.
/**
* It does:
* - Registers a new graph element into the structure
* - Creates the shape for the element to register, using the given shape factory.
* @param factory The shape factory to use.
* @param candidate The graph element to register.
* @param fireEvents If canvas and canvas handled registration events must be fired.
*/
@SuppressWarnings("unchecked")
public void register(final ShapeFactory<Object, Shape> factory, final Element<View<?>> candidate, final boolean fireEvents) {
assert factory != null && candidate != null;
final Shape shape = factory.newShape(candidate.getContent().getDefinition());
// Set the same identifier as the graph element's one.
if (null == shape.getUUID()) {
shape.setUUID(candidate.getUUID());
}
register(shape, candidate, fireEvents);
}
use of org.kie.workbench.common.stunner.core.client.shape.Shape in project kie-wb-common by kiegroup.
the class BaseCanvasHandler method dock.
@Override
public void dock(final Element parent, final Element child) {
if (!isCanvasRoot(parent)) {
final Shape parentShape = getCanvas().getShape(parent.getUUID());
final Shape childShape = getCanvas().getShape(child.getUUID());
getCanvas().dock(parentShape, childShape);
}
}
use of org.kie.workbench.common.stunner.core.client.shape.Shape in project kie-wb-common by kiegroup.
the class BaseCanvasHandler method removeChild.
@Override
@SuppressWarnings("unchecked")
public void removeChild(final Element parent, final Element child) {
final String parentUUID = parent.getUUID();
final String childUUID = child.getUUID();
final Shape childShape = getCanvas().getShape(childUUID);
if (!isCanvasRoot(parentUUID)) {
final Shape parentShape = getCanvas().getShape(parentUUID);
getCanvas().deleteChildShape(parentShape, childShape);
} else {
// -- Special case when parent is the canvas root --
// Ensure the shape is removed from the layer, but no need to deregister any
// handlers ( f.i. using canvas#removeShape() method ).
getCanvas().getLayer().removeShape(childShape.getShapeView());
}
}
Aggregations