Search in sources :

Example 71 with CourseEditorTreeNode

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;
}
Also used : CourseEditorTreeNode(org.olat.course.tree.CourseEditorTreeNode)

Example 72 with CourseEditorTreeNode

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();
}
Also used : CloseableModalController(org.olat.core.gui.control.generic.closablewrapper.CloseableModalController) VFSContainer(org.olat.core.util.vfs.VFSContainer) CourseEditorTreeNode(org.olat.course.tree.CourseEditorTreeNode)

Example 73 with CourseEditorTreeNode

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);
}
Also used : TreeVisitor(org.olat.core.util.tree.TreeVisitor) INode(org.olat.core.util.nodes.INode) TreeVisitor(org.olat.core.util.tree.TreeVisitor) Visitor(org.olat.core.util.tree.Visitor) CourseEditorTreeNode(org.olat.course.tree.CourseEditorTreeNode) CourseNode(org.olat.course.nodes.CourseNode)

Example 74 with CourseEditorTreeNode

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++;
    }
}
Also used : CourseEditorTreeNode(org.olat.course.tree.CourseEditorTreeNode) ArrayList(java.util.ArrayList) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer) ICourse(org.olat.course.ICourse) CourseNode(org.olat.course.nodes.CourseNode) FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink) Property(org.olat.properties.Property) CoursePropertyManager(org.olat.course.properties.CoursePropertyManager)

Example 75 with CourseEditorTreeNode

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();
}
Also used : TreeVisitor(org.olat.core.util.tree.TreeVisitor) TreeVisitor(org.olat.core.util.tree.TreeVisitor) Visitor(org.olat.core.util.tree.Visitor) CourseEditorTreeNode(org.olat.course.tree.CourseEditorTreeNode) Structure(org.olat.course.Structure)

Aggregations

CourseEditorTreeNode (org.olat.course.tree.CourseEditorTreeNode)88 CourseNode (org.olat.course.nodes.CourseNode)54 ICourse (org.olat.course.ICourse)38 CourseEditorTreeModel (org.olat.course.tree.CourseEditorTreeModel)24 INode (org.olat.core.util.nodes.INode)22 Test (org.junit.Test)20 RepositoryEntry (org.olat.repository.RepositoryEntry)18 Identity (org.olat.core.id.Identity)14 TreeVisitor (org.olat.core.util.tree.TreeVisitor)14 Visitor (org.olat.core.util.tree.Visitor)14 CourseNodeVO (org.olat.restapi.support.vo.CourseNodeVO)12 TreeNode (org.olat.core.gui.components.tree.TreeNode)10 STCourseNode (org.olat.course.nodes.STCourseNode)10 ArrayList (java.util.ArrayList)9 File (java.io.File)8 URI (java.net.URI)8 HttpResponse (org.apache.http.HttpResponse)8 HttpPut (org.apache.http.client.methods.HttpPut)8 Structure (org.olat.course.Structure)8 BCCourseNode (org.olat.course.nodes.BCCourseNode)8