use of org.knime.workbench.editor2.commands.InsertNodeCommand in project knime-core by knime.
the class NewWorkflowContainerEditPolicy method handleNodeDrop.
/**
* @param manager the workflow manager
* @param factory the ndoe factory
* @param request the drop request
*/
private Command handleNodeDrop(final WorkflowManager manager, final NodeFactory<? extends NodeModel> factory, final CreateDropRequest request) {
RequestType requestType = request.getRequestType();
Point location = request.getLocation();
boolean snapToGrid = WorkflowEditor.getActiveEditorSnapToGrid();
if (requestType.equals(RequestType.CREATE)) {
// create a new node
return new CreateNodeCommand(manager, factory, location, snapToGrid);
} else {
AbstractEditPart editPart = request.getEditPart();
if (requestType.equals(RequestType.INSERT)) {
// insert new node into connection
InsertNodeCommand insertCommand = new InsertNodeCommand(manager, factory, location, snapToGrid, (ConnectionContainerEditPart) editPart);
if (request.createSpace()) {
CreateSpaceAction csa = new CreateSpaceAction((WorkflowEditor) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor(), request.getDirection(), request.getDistance());
return insertCommand.chain(csa.createCompoundCommand(csa.selectedParts()));
} else {
return insertCommand;
}
} else if (requestType.equals(RequestType.REPLACE)) {
// replace node with a node
return new ReplaceNodeCommand(manager, factory, location, snapToGrid, (NodeContainerEditPart) editPart);
} else {
return null;
}
}
}
Aggregations