if (te.getCommand().equals(TreeEvent.COMMAND_TREENODE_CLICKED)) {
// user chose a position to insert a new node
String nodeId = te.getNodeId();
TreePosition tp = insertModel.getTreePosition(nodeId);
CourseNode selectedNode = insertModel.getCourseNode(tp.getParentTreeNode());
CourseEditorTreeNode insertParent = course.getEditorTreeModel().getCourseEditorNodeById(selectedNode.getIdent());
// check if insert position is within the to-be-copied tree
if (checkIfIsChild(insertParent, moveCopyFrom)) {
this.showError("movecopynode.error.overlap");
fireEvent(ureq, Event.CANCELLED_EVENT);
return;
}
int insertPos = tp.getChildpos();
if (copy) { // do a copy
// copy subtree and save model
recursiveCopy(moveCopyFrom, insertParent, insertPos, true, CourseFactory.getCourseEditSession(ores.getResourceableId()));
CourseFactory.saveCourseEditorTreeModel(course.getResourceableId());
ThreadLocalUserActivityLogger.log(CourseLoggingAction.COURSE_EDITOR_NODE_COPIED, getClass());
fireEvent(ureq, Event.DONE_EVENT);
} else { // move only
if (insertParent.getIdent().equals(moveCopyFrom.getParent().getIdent())) {
// same parent, adjust insertPos
if (insertPos > moveCopyFrom.getPosition()) insertPos--;
}
insertParent.insert(moveCopyFrom, insertPos);
moveCopyFrom.setDirty(true);
//mark subtree as dirty
TreeVisitor tv = new TreeVisitor( new Visitor() {
public void visit(INode node) {
CourseEditorTreeNode cetn = (CourseEditorTreeNode)node;
cetn.setDirty(true);
}
},moveCopyFrom,true);
tv.visitAll();
CourseFactory.saveCourseEditorTreeModel(course.getResourceableId()); // TODO: pb: Review : Add by chg to FIX OLAT-1662
this.showInfo("movecopynode.info.condmoved");