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);
}
}
}
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();
}
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();
}
}
}
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();
}
}
}
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);
}
Aggregations