Search in sources :

Example 1 with ShapeDeletedEvent

use of org.uberfire.ext.wires.core.api.events.ShapeDeletedEvent in project drools-wb by kiegroup.

the class GuidedDecisionTreeWidget method deleteShape.

@Override
public void deleteShape(final WiresBaseShape shape) {
    if (confirmShapeDeletion()) {
        if (uiRoot != null && uiRoot.equals(shape)) {
            uiRoot = null;
            model.setRoot(null);
            shapeDeletedEvent.fire(new ShapeDeletedEvent(shape));
        } else if (shape instanceof BaseGuidedDecisionTreeShape) {
            final BaseGuidedDecisionTreeShape uiChild = (BaseGuidedDecisionTreeShape) shape;
            if (uiChild.getParentNode() instanceof BaseGuidedDecisionTreeShape) {
                final BaseGuidedDecisionTreeShape uiParent = (BaseGuidedDecisionTreeShape) uiChild.getParentNode();
                uiParent.getModelNode().removeChild(uiChild.getModelNode());
            }
            shapeDeletedEvent.fire(new ShapeDeletedEvent(shape));
            layout();
        }
    }
}
Also used : ShapeDeletedEvent(org.uberfire.ext.wires.core.api.events.ShapeDeletedEvent) BaseGuidedDecisionTreeShape(org.drools.workbench.screens.guided.dtree.client.widget.shapes.BaseGuidedDecisionTreeShape)

Example 2 with ShapeDeletedEvent

use of org.uberfire.ext.wires.core.api.events.ShapeDeletedEvent in project drools-wb by kiegroup.

the class GuidedDecisionTreeWidgetTest method testDeleteShapeNotConfirmed.

@Test
public void testDeleteShapeNotConfirmed() {
    doReturn(false).when(widget).confirmShapeDeletion();
    final BaseGuidedDecisionTreeShape shapeToDelete = uiRootShape;
    widget.deleteShape(shapeToDelete);
    verify(shapeDeletedEvent, never()).fire(any(ShapeDeletedEvent.class));
    verify(widget, never()).layout();
    assertEquals(uiRootNode, uiModel.getRoot());
}
Also used : BaseGuidedDecisionTreeShape(org.drools.workbench.screens.guided.dtree.client.widget.shapes.BaseGuidedDecisionTreeShape) ShapeDeletedEvent(org.uberfire.ext.wires.core.api.events.ShapeDeletedEvent) Test(org.junit.Test)

Aggregations

BaseGuidedDecisionTreeShape (org.drools.workbench.screens.guided.dtree.client.widget.shapes.BaseGuidedDecisionTreeShape)2 ShapeDeletedEvent (org.uberfire.ext.wires.core.api.events.ShapeDeletedEvent)2 Test (org.junit.Test)1