use of org.knime.workbench.editor2.commands.ChangeWorkflowPortBarCommand in project knime-core by knime.
the class NewWorkflowXYLayoutPolicy method createChangeConstraintCommand.
/**
* Creates command to move / resize <code>NodeContainer</code> components on
* the project's client area.
*
* {@inheritDoc}
*/
@Override
protected Command createChangeConstraintCommand(final EditPart child, final Object constraint) {
// only rectangular constraints are supported
if (!(constraint instanceof Rectangle)) {
return null;
}
Command command = null;
Rectangle rect = ((Rectangle) constraint).getCopy();
if (child.getModel() instanceof NodeContainerUI) {
NodeContainerUI container = (NodeContainerUI) child.getModel();
if (!Wrapper.wraps(container, NodeContainer.class)) {
// not supported for others than ordinary NodeContainers
return null;
}
NodeContainerEditPart nodePart = (NodeContainerEditPart) child;
command = new ChangeNodeBoundsCommand(Wrapper.unwrapNC(container), (NodeContainerFigure) nodePart.getFigure(), rect);
} else if (child instanceof AbstractWorkflowPortBarEditPart) {
command = new ChangeWorkflowPortBarCommand((AbstractWorkflowPortBarEditPart) child, rect);
} else if (child instanceof AnnotationEditPart) {
AnnotationEditPart annoPart = (AnnotationEditPart) child;
// TODO the workflow annotation could know what its WFM is?
WorkflowRootEditPart root = (WorkflowRootEditPart) annoPart.getParent();
WorkflowManagerUI wm = root.getWorkflowManager();
if (!Wrapper.wraps(wm, WorkflowManager.class)) {
// not supported for others than an ordinary workflow manager
return null;
}
command = new ChangeAnnotationBoundsCommand(Wrapper.unwrapWFM(wm), annoPart, rect);
}
return command;
}
Aggregations