Search in sources :

Example 1 with ClearEvent

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

the class GuidedDecisionTreeWidget method setModel.

public void setModel(final GuidedDecisionTree model, final boolean isReadOnly) {
    this.uiRoot = null;
    this.model = model;
    // Clear existing state
    super.clear();
    clearEvent.fire(new ClearEvent());
    // Walk model creating UIModel
    final TypeNode root = model.getRoot();
    if (root != null) {
        final WiresBaseTreeNode uiRoot = typeNodeFactory.getShape(root, isReadOnly);
        this.uiRoot = uiRoot;
        processChildren(root, uiRoot, isReadOnly);
        final Map<WiresBaseShape, Point2D> layout = layoutManager.getLayoutInformation(uiRoot);
        final Rectangle2D canvasBounds = WiresLayoutUtilities.alignLayoutInCanvas(layout);
        for (Map.Entry<WiresBaseShape, Point2D> e : layout.entrySet()) {
            final Point2D destination = new Point2D(e.getValue().getX(), e.getValue().getY());
            e.getKey().setLocation(destination);
        }
        WiresLayoutUtilities.resizeViewPort(canvasBounds, canvasLayer.getViewport());
    }
    if (shapesInCanvas.isEmpty()) {
        showGettingStartedHint();
    }
    canvasLayer.batch();
}
Also used : WiresBaseShape(org.uberfire.ext.wires.core.api.shapes.WiresBaseShape) Point2D(com.ait.lienzo.client.core.types.Point2D) WiresBaseTreeNode(org.uberfire.ext.wires.core.trees.client.shapes.WiresBaseTreeNode) Rectangle2D(org.uberfire.ext.wires.core.trees.client.layout.treelayout.Rectangle2D) ClearEvent(org.uberfire.ext.wires.core.api.events.ClearEvent) TypeNode(org.drools.workbench.models.guided.dtree.shared.model.nodes.TypeNode) Map(java.util.Map) HashMap(java.util.HashMap)

Example 2 with ClearEvent

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

the class GuidedDecisionTreeWidget method clear.

@Override
public void clear() {
    if (Window.confirm(GuidedDecisionTreeConstants.INSTANCE.confirmDeleteDecisionTree())) {
        super.clear();
        clearEvent.fire(new ClearEvent());
        uiRoot = null;
    }
}
Also used : ClearEvent(org.uberfire.ext.wires.core.api.events.ClearEvent)

Aggregations

ClearEvent (org.uberfire.ext.wires.core.api.events.ClearEvent)2 Point2D (com.ait.lienzo.client.core.types.Point2D)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 TypeNode (org.drools.workbench.models.guided.dtree.shared.model.nodes.TypeNode)1 WiresBaseShape (org.uberfire.ext.wires.core.api.shapes.WiresBaseShape)1 Rectangle2D (org.uberfire.ext.wires.core.trees.client.layout.treelayout.Rectangle2D)1 WiresBaseTreeNode (org.uberfire.ext.wires.core.trees.client.shapes.WiresBaseTreeNode)1