Search in sources :

Example 1 with WiresBaseTreeNode

use of org.uberfire.ext.wires.core.trees.client.shapes.WiresBaseTreeNode in project drools-wb by kiegroup.

the class GuidedDecisionTreeWidget method processChildren.

private void processChildren(final Node node, final WiresBaseTreeNode uiNode, final boolean isReadOnly) {
    uiNode.setSelectionManager(this);
    uiNode.setShapesManager(this);
    uiNode.setLayoutManager(layoutManager);
    if (uiNode instanceof BaseGuidedDecisionTreeShape) {
        ((BaseGuidedDecisionTreeShape) uiNode).setPresenter(presenter);
    }
    canvasLayer.add(uiNode);
    shapesInCanvas.add(uiNode);
    final Iterator<Node> itr = node.iterator();
    while (itr.hasNext()) {
        final Node child = itr.next();
        WiresBaseTreeNode uiChildNode = null;
        if (child instanceof TypeNode) {
            uiChildNode = typeNodeFactory.getShape((TypeNode) child, isReadOnly);
        } else if (child instanceof ConstraintNode) {
            uiChildNode = constraintNodeFactory.getShape((ConstraintNode) child, isReadOnly);
        } else if (child instanceof ActionInsertNode) {
            uiChildNode = actionInsertNodeFactory.getShape((ActionInsertNode) child, isReadOnly);
        } else if (child instanceof ActionUpdateNode) {
            uiChildNode = actionUpdateNodeFactory.getShape((ActionUpdateNode) child, isReadOnly);
        } else if (child instanceof ActionRetractNode) {
            uiChildNode = actionRetractNodeFactory.getShape((ActionRetractNode) child, isReadOnly);
        }
        if (uiChildNode != null) {
            uiNode.addChildNode(uiChildNode);
            processChildren(child, uiChildNode, isReadOnly);
        }
    }
}
Also used : ActionInsertNode(org.drools.workbench.models.guided.dtree.shared.model.nodes.ActionInsertNode) ConstraintNode(org.drools.workbench.models.guided.dtree.shared.model.nodes.ConstraintNode) WiresBaseTreeNode(org.uberfire.ext.wires.core.trees.client.shapes.WiresBaseTreeNode) ActionUpdateNode(org.drools.workbench.models.guided.dtree.shared.model.nodes.ActionUpdateNode) ActionRetractNode(org.drools.workbench.models.guided.dtree.shared.model.nodes.ActionRetractNode) WiresBaseTreeNode(org.uberfire.ext.wires.core.trees.client.shapes.WiresBaseTreeNode) TypeNode(org.drools.workbench.models.guided.dtree.shared.model.nodes.TypeNode) Node(org.drools.workbench.models.guided.dtree.shared.model.nodes.Node) ActionUpdateNode(org.drools.workbench.models.guided.dtree.shared.model.nodes.ActionUpdateNode) ActionInsertNode(org.drools.workbench.models.guided.dtree.shared.model.nodes.ActionInsertNode) ConstraintNode(org.drools.workbench.models.guided.dtree.shared.model.nodes.ConstraintNode) ActionRetractNode(org.drools.workbench.models.guided.dtree.shared.model.nodes.ActionRetractNode) TypeNode(org.drools.workbench.models.guided.dtree.shared.model.nodes.TypeNode) BaseGuidedDecisionTreeShape(org.drools.workbench.screens.guided.dtree.client.widget.shapes.BaseGuidedDecisionTreeShape)

Example 2 with WiresBaseTreeNode

use of org.uberfire.ext.wires.core.trees.client.shapes.WiresBaseTreeNode 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 3 with WiresBaseTreeNode

use of org.uberfire.ext.wires.core.trees.client.shapes.WiresBaseTreeNode in project drools-wb by kiegroup.

the class ActionUpdateShape method setParentNode.

@Override
public void setParentNode(final WiresBaseTreeNode parent) {
    super.setParentNode(parent);
    // Set binding to first bound parent TypeNode
    if (parent instanceof BaseGuidedDecisionTreeShape) {
        Node node = ((BaseGuidedDecisionTreeShape) parent).getModelNode();
        while (node != null) {
            if (node instanceof TypeNode) {
                final TypeNode tn = (TypeNode) node;
                if (tn.isBound()) {
                    getModelNode().setBoundNode(tn);
                    setNodeLabel(getNodeLabel());
                    break;
                }
            }
            node = node.getParent();
        }
    }
}
Also used : Node(org.drools.workbench.models.guided.dtree.shared.model.nodes.Node) WiresBaseTreeNode(org.uberfire.ext.wires.core.trees.client.shapes.WiresBaseTreeNode) TypeNode(org.drools.workbench.models.guided.dtree.shared.model.nodes.TypeNode) ActionUpdateNode(org.drools.workbench.models.guided.dtree.shared.model.nodes.ActionUpdateNode) TypeNode(org.drools.workbench.models.guided.dtree.shared.model.nodes.TypeNode)

Example 4 with WiresBaseTreeNode

use of org.uberfire.ext.wires.core.trees.client.shapes.WiresBaseTreeNode in project drools-wb by kiegroup.

the class ActionRetractShape method setParentNode.

@Override
public void setParentNode(final WiresBaseTreeNode parent) {
    super.setParentNode(parent);
    // Set binding to first bound parent TypeNode
    if (parent instanceof BaseGuidedDecisionTreeShape) {
        Node node = ((BaseGuidedDecisionTreeShape) parent).getModelNode();
        while (node != null) {
            if (node instanceof TypeNode) {
                final TypeNode tn = (TypeNode) node;
                if (tn.isBound()) {
                    getModelNode().setBoundNode(tn);
                    setNodeLabel(getNodeLabel());
                    break;
                }
            }
            node = node.getParent();
        }
    }
}
Also used : Node(org.drools.workbench.models.guided.dtree.shared.model.nodes.Node) WiresBaseTreeNode(org.uberfire.ext.wires.core.trees.client.shapes.WiresBaseTreeNode) ActionRetractNode(org.drools.workbench.models.guided.dtree.shared.model.nodes.ActionRetractNode) TypeNode(org.drools.workbench.models.guided.dtree.shared.model.nodes.TypeNode) TypeNode(org.drools.workbench.models.guided.dtree.shared.model.nodes.TypeNode)

Example 5 with WiresBaseTreeNode

use of org.uberfire.ext.wires.core.trees.client.shapes.WiresBaseTreeNode in project drools-wb by kiegroup.

the class BaseGuidedDecisionTreeShape method setupControls.

protected void setupControls() {
    ctrlGroupDeleteIcon = setupControl(GuidedDecisionTreeResources.INSTANCE.images().ctrlDelete(), new Command() {

        @Override
        public void execute() {
            shapesManager.deleteShape(BaseGuidedDecisionTreeShape.this);
        }
    });
    ctrlGroupEditIcon = setupControl(GuidedDecisionTreeResources.INSTANCE.images().ctrlEdit(), new Command() {

        @Override
        public void execute() {
            presenter.editModelNode(BaseGuidedDecisionTreeShape.this.getModelNode(), new Command() {

                @Override
                public void execute() {
                    updateLabels(BaseGuidedDecisionTreeShape.this);
                    BaseGuidedDecisionTreeShape.this.getLayer().batch();
                }

                private void updateLabels(final BaseGuidedDecisionTreeShape parent) {
                    parent.setNodeLabel(parent.getNodeLabel());
                    for (WiresBaseTreeNode child : parent.getChildren()) {
                        if (child instanceof BaseGuidedDecisionTreeShape) {
                            final BaseGuidedDecisionTreeShape cs = (BaseGuidedDecisionTreeShape) child;
                            cs.setNodeLabel(cs.getNodeLabel());
                            updateLabels(cs);
                        }
                    }
                }
            });
        }
    });
    ctrlGroupCollapseIcon = setupControl(GuidedDecisionTreeResources.INSTANCE.images().ctrlCollapse(), new Command() {

        @Override
        public void execute() {
            BaseGuidedDecisionTreeShape.this.collapse(new Command() {

                @Override
                public void execute() {
                // Nothing to do when the animation completes
                }
            });
            final List<Group> controls = new ArrayList<Group>() {

                {
                    add(ctrlGroupDeleteIcon);
                    add(ctrlGroupExpandIcon);
                }
            };
            BaseGuidedDecisionTreeShape.this.setControls(controls);
        }
    });
    ctrlGroupExpandIcon = setupControl(GuidedDecisionTreeResources.INSTANCE.images().ctrlExpand(), new Command() {

        @Override
        public void execute() {
            BaseGuidedDecisionTreeShape.this.expand(new Command() {

                @Override
                public void execute() {
                // Nothing to do when the animation completes
                }
            });
            final List<Group> controls = new ArrayList<Group>() {

                {
                    add(ctrlGroupDeleteIcon);
                    add(ctrlGroupEditIcon);
                    add(ctrlGroupCollapseIcon);
                }
            };
            BaseGuidedDecisionTreeShape.this.setControls(controls);
        }
    });
    controls.add(ctrlGroupDeleteIcon);
    controls.add(ctrlGroupEditIcon);
}
Also used : Group(com.ait.lienzo.client.core.shape.Group) Command(org.uberfire.mvp.Command) WiresBaseTreeNode(org.uberfire.ext.wires.core.trees.client.shapes.WiresBaseTreeNode) ArrayList(java.util.ArrayList)

Aggregations

WiresBaseTreeNode (org.uberfire.ext.wires.core.trees.client.shapes.WiresBaseTreeNode)5 TypeNode (org.drools.workbench.models.guided.dtree.shared.model.nodes.TypeNode)4 Node (org.drools.workbench.models.guided.dtree.shared.model.nodes.Node)3 ActionRetractNode (org.drools.workbench.models.guided.dtree.shared.model.nodes.ActionRetractNode)2 ActionUpdateNode (org.drools.workbench.models.guided.dtree.shared.model.nodes.ActionUpdateNode)2 Group (com.ait.lienzo.client.core.shape.Group)1 Point2D (com.ait.lienzo.client.core.types.Point2D)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 ActionInsertNode (org.drools.workbench.models.guided.dtree.shared.model.nodes.ActionInsertNode)1 ConstraintNode (org.drools.workbench.models.guided.dtree.shared.model.nodes.ConstraintNode)1 BaseGuidedDecisionTreeShape (org.drools.workbench.screens.guided.dtree.client.widget.shapes.BaseGuidedDecisionTreeShape)1 ClearEvent (org.uberfire.ext.wires.core.api.events.ClearEvent)1 WiresBaseShape (org.uberfire.ext.wires.core.api.shapes.WiresBaseShape)1 Rectangle2D (org.uberfire.ext.wires.core.trees.client.layout.treelayout.Rectangle2D)1 Command (org.uberfire.mvp.Command)1