use of org.olat.course.tree.CourseEditorTreeNode in project openolat by klemens.
the class CourseEditorEnvImpl method existsNode.
/**
* @see org.olat.course.editor.CourseEditorEnv#existsNode(java.lang.String)
*/
public boolean existsNode(String nodeId) {
CourseEditorTreeNode cen = cetm.getCourseEditorNodeById(nodeId);
boolean retVal = cen != null && !cen.isDeleted();
return retVal;
}
use of org.olat.course.tree.CourseEditorTreeNode in project openolat by klemens.
the class EditorMainController method launchSinglePagesWizard.
private void launchSinglePagesWizard(UserRequest ureq, ICourse course) {
removeAsListenerAndDispose(multiSPChooserCtr);
removeAsListenerAndDispose(cmc);
VFSContainer rootContainer = course.getCourseEnvironment().getCourseFolderContainer();
CourseEditorTreeNode selectedNode = (CourseEditorTreeNode) menuTree.getSelectedNode();
multiSPChooserCtr = new MultiSPController(ureq, getWindowControl(), rootContainer, ores, selectedNode);
listenTo(multiSPChooserCtr);
cmc = new CloseableModalController(getWindowControl(), translate("close"), multiSPChooserCtr.getInitialComponent(), true, translate("multi.sps.title"));
listenTo(cmc);
cmc.activate();
}
use of org.olat.course.tree.CourseEditorTreeNode in project openolat by klemens.
the class EditorMainController method dropNodeAsChild.
private void dropNodeAsChild(UserRequest ureq, ICourse course, String droppedNodeId, String targetNodeId, boolean asChild, boolean atTheEnd) {
// setDirty when moving
menuTree.setDirty(true);
CourseNode droppedNode = cetm.getCourseNode(droppedNodeId);
int position;
CourseEditorTreeNode insertParent;
if (asChild) {
insertParent = cetm.getCourseEditorNodeById(targetNodeId);
position = atTheEnd ? -1 : 0;
} else {
CourseEditorTreeNode selectedNode = cetm.getCourseEditorNodeById(targetNodeId);
if (selectedNode.getParent() == null) {
// root node
insertParent = selectedNode;
position = 0;
} else {
insertParent = course.getEditorTreeModel().getCourseEditorNodeById(selectedNode.getParent().getIdent());
position = 0;
for (position = insertParent.getChildCount(); position-- > 0; ) {
if (insertParent.getChildAt(position).getIdent().equals(selectedNode.getIdent())) {
position++;
break;
}
}
}
}
CourseEditorTreeNode moveFrom = course.getEditorTreeModel().getCourseEditorNodeById(droppedNode.getIdent());
// check if an ancestor is not dropped on a child
if (course.getEditorTreeModel().checkIfIsChild(insertParent, moveFrom)) {
showError("movecopynode.error.overlap");
fireEvent(ureq, Event.CANCELLED_EVENT);
return;
}
// don't generate red screen for that. If the position is too high -> add the node at the end
if (position >= insertParent.getChildCount()) {
position = -1;
}
try {
if (position >= 0) {
insertParent.insert(moveFrom, position);
} else {
insertParent.addChild(moveFrom);
}
} catch (IndexOutOfBoundsException e) {
logError("", e);
// reattach the node as security, if not, the node is lost
insertParent.addChild(moveFrom);
}
moveFrom.setDirty(true);
// mark subtree as dirty
TreeVisitor tv = new TreeVisitor(new Visitor() {
public void visit(INode node) {
CourseEditorTreeNode cetn = (CourseEditorTreeNode) node;
cetn.setDirty(true);
}
}, moveFrom, true);
tv.visitAll();
CourseFactory.saveCourseEditorTreeModel(course.getResourceableId());
showInfo("movecopynode.info.condmoved");
ThreadLocalUserActivityLogger.log(CourseLoggingAction.COURSE_EDITOR_NODE_MOVED, getClass());
euce.getCourseEditorEnv().validateCourse();
StatusDescription[] courseStatus = euce.getCourseEditorEnv().getCourseStatus();
updateCourseStatusMessages(ureq.getLocale(), courseStatus);
}
use of org.olat.course.tree.CourseEditorTreeNode in project openolat by klemens.
the class CustomDBController method updateDBList.
private void updateDBList(FormItemContainer formLayout) {
ICourse course = CourseFactory.loadCourse(courseKey);
CoursePropertyManager cpm = course.getCourseEnvironment().getCoursePropertyManager();
CourseNode rootNode = ((CourseEditorTreeNode) course.getEditorTreeModel().getRootNode()).getCourseNode();
Property p = cpm.findCourseNodeProperty(rootNode, null, null, CustomDBMainController.CUSTOM_DB);
List<String> databases = new ArrayList<>();
if (p != null && p.getTextValue() != null) {
String[] dbs = p.getTextValue().split(":");
for (String db : dbs) {
databases.add(db);
}
}
List<String> currentlyUsed = courseDbManager.getUsedCategories(course);
for (String db : currentlyUsed) {
if (!databases.contains(db)) {
databases.add(db);
}
}
int count = 0;
for (String db : databases) {
if (!StringHelper.containsNonWhitespace(db))
continue;
uifactory.addStaticExampleText("category_" + count, "customDb.category", db, formLayout);
String url = Settings.getServerContextPathURI() + RestSecurityHelper.SUB_CONTEXT + "/repo/courses/" + courseKey + "/db/" + db;
uifactory.addStaticExampleText("url_" + count, "customDb.url", url, formLayout);
final FormLayoutContainer buttonLayout = FormLayoutContainer.createButtonLayout("buttonLayout_" + count, getTranslator());
formLayout.add(buttonLayout);
FormLink resetDb = uifactory.addFormLink("db-reset_" + count, "customDb.reset", "customDb.reset", buttonLayout, Link.BUTTON_SMALL);
resetDb.setUserObject(db);
resetDb.setVisible(!readOnly);
resetDbs.add(resetDb);
FormLink deleteDb = uifactory.addFormLink("db-delete_" + count, "delete", "delete", buttonLayout, Link.BUTTON_SMALL);
deleteDb.setUserObject(db);
deleteDb.setVisible(!readOnly);
deleteDbs.add(deleteDb);
FormLink exportDb = uifactory.addFormLink("db-export_" + count, "customDb.export", "customDb.export", buttonLayout, Link.BUTTON_SMALL);
exportDb.setUserObject(db);
exportDbs.add(exportDb);
count++;
}
}
use of org.olat.course.tree.CourseEditorTreeNode in project openolat by klemens.
the class PublishProcess method calculatePublishSet.
/**
* @param nodesIdsToPublish
* @param resultingCourseRun
* @param editorModelDeletedNodes
* @param editorModelInsertedNodes
* @param editorModelModifiedNodes
*/
private void calculatePublishSet(List<String> nodesIdsToPublish) {
/*
* START NEW STYLE PUBLISH ................................................. -
* visit each node (breadth first) - if node is selected to be published ->
* publish and take into account if the node exists already in the
* runstructure (keep ident or not). And also if node should get deleted add
* it to a list of nodes to be deleted. This is needed for a later clean-up
* and archive. ............................. - if node is not selected to
* be published, but exists already in the runstructure it must be added to
* the tmp-runstructure as it is in the existing runstructure.
* ..................................................
*/
// start point for node publish visitor
CourseEditorTreeNode editorRoot = (CourseEditorTreeNode) editorTreeModel.getRootNode();
// the active runstructure and the new created runstructure
Structure existingCourseRun = course.getRunStructure();
// breadth first!
boolean visitChildrenFirst = false;
/*
* the tree is visited and the book keeping lists are filled. the visitor
* itself does not delete or modify neither runstructure nor editor tree
* model. The whole complexity of published is encapsulated in the visitor.
*/
Visitor nodePublishV = new NodePublishVisitor(editorRoot, nodesIdsToPublish, existingCourseRun);
TreeVisitor tv = new TreeVisitor(nodePublishV, editorRoot, visitChildrenFirst);
tv.visitAll();
}
Aggregations