use of org.olat.course.nodes.CourseNode in project OpenOLAT by OpenOLAT.
the class EditorMainController method event.
/**
* @see org.olat.core.gui.control.DefaultController#event(org.olat.core.gui.UserRequest,
* org.olat.core.gui.control.Controller, org.olat.core.gui.control.Event)
*/
@Override
public void event(UserRequest ureq, Controller source, Event event) {
try {
ICourse course = CourseFactory.getCourseEditSession(ores.getResourceableId());
if (source == nodeEditCntrllr) {
// event from the tabbed pane (any tab)
if (event == NodeEditController.NODECONFIG_CHANGED_EVENT) {
// if the user changed the name of the node, we need to update the tree also.
// the event is too generic to find out what happened -> update tree in all cases (applies to ajax mode only)
menuTree.setDirty(true);
cetm.nodeConfigChanged(menuTree.getSelectedNode());
CourseFactory.saveCourseEditorTreeModel(course.getResourceableId());
euce.getCourseEditorEnv().validateCourse();
StatusDescription[] courseStatus = euce.getCourseEditorEnv().getCourseStatus();
updateCourseStatusMessages(ureq.getLocale(), courseStatus);
}
} else if (source == statusCtr) {
if (event.getCommand().startsWith(NLS_START_HELP_WIZARD)) {
doStartHelpWizard(ureq, event);
}
calloutCtrl.deactivate();
cleanUp();
} else if (source == chooseNodeTypeCtr) {
cmc.deactivate();
String cmd = event.getCommand();
if (cmd.startsWith(TB_ACTION)) {
CourseNode newNode = chooseNodeTypeCtr.getCreatedNode();
cleanUp();
doInsert(ureq, newNode);
} else if (CMD_MULTI_SP.equals(cmd)) {
cleanUp();
launchSinglePagesWizard(ureq, course);
} else if (CMD_MULTI_CHECKLIST.equals(cmd)) {
cleanUp();
launchChecklistsWizard(ureq);
}
} else if (source == publishStepsController) {
getWindowControl().pop();
Object requestOnClose = publishStepsController.getRunContext().get("requestOnClose");
removeAsListenerAndDispose(publishStepsController);
publishStepsController = null;
// reset to root node... may have published a deleted node -> this
// resets the view
// else Event.DONE -> nothing changed / else Event.CANCELLED -> cancelled wizard
updateAfterPublishing(ureq, course, event == Event.CHANGED_EVENT);
if (Boolean.TRUE.equals(requestOnClose)) {
fireEvent(ureq, Event.DONE_EVENT);
}
} else if (source == quickPublishCtr) {
if (event == Event.CANCELLED_EVENT) {
cmc.deactivate();
fireEvent(ureq, Event.DONE_EVENT);
} else if (event == MANUAL_PUBLISH) {
cmc.deactivate();
launchPublishingWizard(ureq, course, true);
} else if (event == Event.CHANGED_EVENT) {
updateAfterPublishing(ureq, course, event == Event.CHANGED_EVENT);
cleanUpNodeController();
cmc.deactivate();
fireEvent(ureq, Event.DONE_EVENT);
}
} else if (source == previewController) {
if (event == Event.DONE_EVENT) {
// no need to deactivate preview controller, already done internally
removeAsListenerAndDispose(previewController);
previewController = null;
}
} else if (source == checklistWizard) {
if (event == Event.CANCELLED_EVENT || event == Event.DONE_EVENT || event == Event.CHANGED_EVENT) {
getWindowControl().pop();
removeAsListenerAndDispose(checklistWizard);
checklistWizard = null;
if (event == Event.DONE_EVENT || event == Event.CHANGED_EVENT) {
menuTree.setDirty(true);
CourseFactory.saveCourseEditorTreeModel(course.getResourceableId());
euce.getCourseEditorEnv().validateCourse();
StatusDescription[] courseStatus = euce.getCourseEditorEnv().getCourseStatus();
updateCourseStatusMessages(ureq.getLocale(), courseStatus);
}
}
} else if (source == cmc) {
cleanUp();
} else if (source == moveCopyController) {
cmc.deactivate();
if (event == Event.DONE_EVENT) {
// setDirty when moving
menuTree.setDirty(true);
// Repositioning to move/copy course node
String nodeId = moveCopyController.getCopyNodeId();
if (nodeId != null) {
menuTree.setSelectedNodeId(nodeId);
euce.getCourseEditorEnv().setCurrentCourseNodeId(nodeId);
CourseNode copyNode = cetm.getCourseNode(nodeId);
initNodeEditor(ureq, copyNode);
}
euce.getCourseEditorEnv().validateCourse();
StatusDescription[] courseStatus = euce.getCourseEditorEnv().getCourseStatus();
updateCourseStatusMessages(ureq.getLocale(), courseStatus);
} else if (event == Event.FAILED_EVENT) {
getWindowControl().setError("Error in copy of subtree.");
} else if (event == Event.CANCELLED_EVENT) {
// user canceled
}
// aggressive clean-up
cleanUp();
} else if (source == deleteDialogController) {
removeAsListenerAndDispose(deleteDialogController);
deleteDialogController = null;
if (DialogBoxUIFactory.isYesEvent(event)) {
// delete confirmed
String ident = menuTree.getSelectedNode().getIdent();
// udpate the current node in the course editor environment
doDelete(course, ident);
} else {
tabbedNodeConfig.setVisible(true);
}
} else if (source == multiSPChooserCtr) {
cmc.deactivate();
removeAsListenerAndDispose(cmc);
removeAsListenerAndDispose(multiSPChooserCtr);
cmc = null;
if (event == Event.CHANGED_EVENT) {
menuTree.setDirty(true);
euce.getCourseEditorEnv().validateCourse();
StatusDescription[] courseStatus = euce.getCourseEditorEnv().getCourseStatus();
updateCourseStatusMessages(ureq.getLocale(), courseStatus);
}
} else if (source == alternateCtr) {
cmc.deactivate();
if (event == Event.DONE_EVENT) {
CourseNode chosenNode = alternateCtr.getCourseNode();
String selectAlternative = alternateCtr.getSelectedAlternative();
doCreateAlternateBuildingBlock(ureq, course, chosenNode, selectAlternative);
}
removeAsListenerAndDispose(cmc);
removeAsListenerAndDispose(alternateCtr);
cmc = null;
alternateCtr = null;
}
} catch (RuntimeException e) {
log.warn(RELEASE_LOCK_AT_CATCH_EXCEPTION + " [in event(UserRequest,Controller,Event)]", e);
this.dispose();
throw e;
}
}
use of org.olat.course.nodes.CourseNode in project OpenOLAT by OpenOLAT.
the class EditorMainController method doCreateAlternateBuildingBlock.
/**
* The following operation are done:
* <ul>
* <li>create a new instance of the replacement type
* <li>add the new element below the original element
* <li>copy the element title, description and the generic configuration options
* <li>copy the access, visibility and scoring rules (easy and expert)
* <li>optionally copy some other configuration if this is possible at all
* <li>move all child elements from the original to the replacement element
* <li>mark the original element as deleted
* </ul>
*
* @param chosenNode
* @param selectAlternative
*/
private void doCreateAlternateBuildingBlock(UserRequest ureq, ICourse course, CourseNode chosenNode, String selectAlternative) {
if (!StringHelper.containsNonWhitespace(selectAlternative))
return;
// create the alternative node
CourseNodeConfiguration newConfig = CourseNodeFactory.getInstance().getCourseNodeConfiguration(selectAlternative);
CourseNode newNode = newConfig.getInstance();
// copy configurations
chosenNode.copyConfigurationTo(newNode, course);
// insert the node
CourseEditorTreeNode cetn = (CourseEditorTreeNode) cetm.getNodeById(chosenNode.getIdent());
CourseEditorTreeNode parentNode = (CourseEditorTreeNode) cetn.getParent();
int position = cetn.getPosition() + 1;
CourseEditorTreeNode newCetn = course.getEditorTreeModel().insertCourseNodeAt(newNode, parentNode.getCourseNode(), position);
doInsert(ureq, newNode);
// copy the children
while (cetn.getChildCount() > 0) {
CourseEditorTreeNode childNode = (CourseEditorTreeNode) cetn.getChildAt(0);
newCetn.addChild(childNode);
}
// set all dirty
TreeVisitor tv = new TreeVisitor(new Visitor() {
public void visit(INode node) {
((CourseEditorTreeNode) node).setDirty(true);
}
}, newCetn, true);
tv.visitAll();
// mark as deleted
doDelete(course, chosenNode.getIdent());
// save
CourseFactory.saveCourseEditorTreeModel(course.getResourceableId());
}
use of org.olat.course.nodes.CourseNode in project OpenOLAT by OpenOLAT.
the class EditorMainController method event.
/**
* @see org.olat.core.gui.control.DefaultController#event(org.olat.core.gui.UserRequest,
* org.olat.core.gui.components.Component, org.olat.core.gui.control.Event)
*/
@Override
public void event(UserRequest ureq, Component source, Event event) {
try {
ICourse course = CourseFactory.getCourseEditSession(ores.getResourceableId());
if (source == menuTree) {
if (event.getCommand().equals(MenuTree.COMMAND_TREENODE_CLICKED)) {
// goto node in edit mode
TreeEvent te = (TreeEvent) event;
String nodeId = te.getNodeId();
updateViewForSelectedNodeId(ureq, nodeId);
} else if (event.getCommand().equals(MenuTree.COMMAND_TREENODE_DROP)) {
TreeDropEvent te = (TreeDropEvent) event;
dropNodeAsChild(ureq, course, te.getDroppedNodeId(), te.getTargetNodeId(), te.isAsChild(), te.isAtTheEnd());
}
} else if (source == main) {
if (event.getCommand().startsWith(NLS_START_HELP_WIZARD)) {
doStartHelpWizard(ureq, event);
}
} else if (source == undelButton) {
doUndelete(ureq, course);
} else if (source == alternativeLink) {
CourseNode chosenNode = (CourseNode) alternativeLink.getUserObject();
askForAlternative(ureq, chosenNode);
} else if (previewLink == source) {
launchPreview(ureq, course);
} else if (publishLink == source) {
launchPublishingWizard(ureq, course, false);
} else if (closeLink == source) {
doReleaseEditLock();
fireEvent(ureq, Event.DONE_EVENT);
} else if (createNodeLink == source) {
doOpenNodeTypeChooser(ureq);
} else if (deleteNodeLink == source) {
doDeleteNode(ureq);
} else if (moveNodeLink == source) {
doMove(ureq, course, false);
} else if (copyNodeLink == source) {
doMove(ureq, course, true);
} else if (statusLink == source) {
doOpenStatusOverview(ureq);
}
} catch (RuntimeException e) {
log.warn(RELEASE_LOCK_AT_CATCH_EXCEPTION + " [in event(UserRequest,Component,Event)]", e);
dispose();
throw e;
}
}
use of org.olat.course.nodes.CourseNode in project OpenOLAT by OpenOLAT.
the class MoveCopySubtreeController method recursiveCopy.
private void recursiveCopy(CourseEditorTreeNode copyFrom2, CourseEditorTreeNode insertParent, int pos, boolean firstIteration, ICourse course) {
// create copy of course node
CourseNode copyOfNode = copyFrom2.getCourseNode().createInstanceForCopy(firstIteration, course, getIdentity());
copyNodeId = copyOfNode.getIdent();
// Insert at desired position
course.getEditorTreeModel().insertCourseNodeAt(copyOfNode, insertParent.getCourseNode(), pos);
CourseEditorTreeNode insertedEditorTreeNode = course.getEditorTreeModel().getCourseEditorNodeById(copyOfNode.getIdent());
for (int i = 0; i < copyFrom2.getChildCount(); i++) {
recursiveCopy(course.getEditorTreeModel().getCourseEditorNodeById(copyFrom2.getChildAt(i).getIdent()), insertedEditorTreeNode, i, false, course);
}
}
use of org.olat.course.nodes.CourseNode in project OpenOLAT by OpenOLAT.
the class GTANotifications method getItems.
public List<SubscriptionListItem> getItems() {
Publisher p = subscriber.getPublisher();
ICourse course = CourseFactory.loadCourse(p.getResId());
CourseNode node = course.getRunStructure().getNode(p.getSubidentifier());
RepositoryEntry entry = course.getCourseEnvironment().getCourseGroupManager().getCourseEntry();
if (entry.getRepositoryEntryStatus().isClosed() || entry.getRepositoryEntryStatus().isUnpublished()) {
return Collections.emptyList();
}
if (entry != null && node instanceof GTACourseNode) {
gtaNode = (GTACourseNode) node;
displayName = entry.getDisplayname();
courseEnv = course.getCourseEnvironment();
taskList = gtaManager.getTaskList(entry, gtaNode);
if (GTAType.group.name().equals(gtaNode.getModuleConfiguration().getStringValue(GTACourseNode.GTASK_TYPE))) {
createBusinessGroupsSubscriptionInfo(subscriber.getIdentity());
} else {
createIndividualSubscriptionInfo(subscriber.getIdentity());
}
}
return items;
}
Aggregations