Search in sources :

Example 46 with TreeEvent

use of org.olat.core.gui.components.tree.TreeEvent in project openolat by klemens.

the class StatisticCourseNodesController method event.

@Override
protected void event(UserRequest ureq, Component source, Event event) {
    if (source == courseTree) {
        if (event instanceof TreeEvent) {
            TreeEvent te = (TreeEvent) event;
            if (MenuTree.COMMAND_TREENODE_CLICKED.equals(te.getCommand())) {
                String ident = te.getNodeId();
                TreeNode selectedNode = courseTree.getTreeModel().getNodeById(ident);
                doSelectNode(ureq, selectedNode);
            }
        }
    }
}
Also used : TreeEvent(org.olat.core.gui.components.tree.TreeEvent) GenericTreeNode(org.olat.core.gui.components.tree.GenericTreeNode) TreeNode(org.olat.core.gui.components.tree.TreeNode)

Example 47 with TreeEvent

use of org.olat.core.gui.components.tree.TreeEvent in project openolat by klemens.

the class CPTreeController method doDrop.

private void doDrop(UserRequest ureq, String droppedNodeId, String targetNodeId, boolean asChild) {
    TreeNode droppedNode = treeModel.getNodeById(droppedNodeId);
    TreeNode targetNode = treeModel.getNodeById(targetNodeId);
    String droppedNodeIdent = treeModel.getIdentifierForNodeID(droppedNodeId);
    String targetNodeIdent = treeModel.getIdentifierForNodeID(targetNodeId);
    CPManager cpMgm = CPManager.getInstance();
    if (asChild) {
        cpMgm.moveElement(cp, droppedNodeIdent, targetNodeIdent, 0);
        cpMgm.writeToFile(cp);
    } else if (targetNode.getParent() == null) {
    // root -> do nothing
    } else {
        TreeNode parentTargetNode = (TreeNode) targetNode.getParent();
        int index = TreeHelper.indexOf(targetNode, parentTargetNode);
        boolean sibling = droppedNode.getParent().equals(parentTargetNode);
        if (sibling) {
            int droppedCurentIndex = TreeHelper.indexOf(targetNode, parentTargetNode);
            if (droppedCurentIndex < index) {
                index = index - 2;
            }
        }
        if (index < 0) {
            index = 0;
        }
        String parentTargetNodeIdent = treeModel.getIdentifierForNodeID(parentTargetNode.getIdent());
        cpMgm.moveElement(cp, droppedNodeIdent, parentTargetNodeIdent, index + 1);
        cpMgm.writeToFile(cp);
    }
    selectTreeNodeById(droppedNodeIdent);
    updateTree();
    fireEvent(ureq, new TreeEvent(TreeEvent.COMMAND_TREENODE_CLICKED, droppedNodeIdent));
}
Also used : TreeEvent(org.olat.core.gui.components.tree.TreeEvent) TreeNode(org.olat.core.gui.components.tree.TreeNode) CPManager(org.olat.ims.cp.CPManager)

Example 48 with TreeEvent

use of org.olat.core.gui.components.tree.TreeEvent in project openolat by klemens.

the class QTI21RuntimeStatisticsController method event.

@Override
protected void event(UserRequest ureq, Component source, Event event) {
    if (courseTree == source) {
        if (event instanceof TreeEvent) {
            TreeEvent te = (TreeEvent) event;
            if (MenuTree.COMMAND_TREENODE_CLICKED.equals(te.getCommand())) {
                String ident = te.getNodeId();
                TreeNode selectedNode = courseTree.getTreeModel().getNodeById(ident);
                doSelectNode(ureq, selectedNode);
            }
        }
    }
}
Also used : TreeEvent(org.olat.core.gui.components.tree.TreeEvent) TreeNode(org.olat.core.gui.components.tree.TreeNode)

Example 49 with TreeEvent

use of org.olat.core.gui.components.tree.TreeEvent in project openolat by klemens.

the class AssessmentTestComposerController method event.

@Override
protected void event(UserRequest ureq, Component source, Event event) {
    if (menuTree == source) {
        if (event instanceof TreeEvent) {
            TreeEvent te = (TreeEvent) event;
            String cmd = te.getCommand();
            if (MenuTree.COMMAND_TREENODE_CLICKED.equals(cmd)) {
                TreeNode selectedNode = menuTree.getTreeModel().getNodeById(te.getNodeId());
                partEditorFactory(ureq, selectedNode);
            }
        } else if (event.getCommand().equals(MenuTree.COMMAND_TREENODE_DROP)) {
            TreeDropEvent tde = (TreeDropEvent) event;
            doDrop(ureq, tde.getDroppedNodeId(), tde.getTargetNodeId(), tde.isAsChild());
        }
    } else if (newSectionLink == source) {
        doNewSection(ureq, menuTree.getSelectedNode());
    } else if (newTestPartLink == source) {
        doNewTestPart(ureq);
    } else if (newSingleChoiceLink == source) {
        doNewAssessmentItem(ureq, menuTree.getSelectedNode(), new SingleChoiceAssessmentItemBuilder(translate("new.sc"), translate("new.answer"), qtiService.qtiSerializer()));
    } else if (newMultipleChoiceLink == source) {
        doNewAssessmentItem(ureq, menuTree.getSelectedNode(), new MultipleChoiceAssessmentItemBuilder(translate("new.mc"), translate("new.answer"), qtiService.qtiSerializer()));
    } else if (newKPrimLink == source) {
        doNewAssessmentItem(ureq, menuTree.getSelectedNode(), new KPrimAssessmentItemBuilder(translate("new.kprim"), translate("new.answer"), qtiService.qtiSerializer()));
    } else if (newMatchLink == source) {
        doNewAssessmentItem(ureq, menuTree.getSelectedNode(), new MatchAssessmentItemBuilder(translate("new.match"), QTI21Constants.CSS_MATCH_MATRIX, qtiService.qtiSerializer()));
    } else if (newMatchDragAndDropLink == source) {
        doNewAssessmentItem(ureq, menuTree.getSelectedNode(), new MatchAssessmentItemBuilder(translate("new.matchdraganddrop"), QTI21Constants.CSS_MATCH_DRAG_AND_DROP, qtiService.qtiSerializer()));
    } else if (newMatchTrueFalseLink == source) {
        doNewAssessmentItem(ureq, menuTree.getSelectedNode(), new MatchAssessmentItemBuilder(translate("new.matchtruefalse"), QTI21Constants.CSS_MATCH_TRUE_FALSE, translate("match.unanswered"), translate("match.true"), translate("match.false"), qtiService.qtiSerializer()));
    } else if (newFIBLink == source) {
        doNewAssessmentItem(ureq, menuTree.getSelectedNode(), new FIBAssessmentItemBuilder(translate("new.fib"), EntryType.text, qtiService.qtiSerializer()));
    } else if (newNumericalLink == source) {
        doNewAssessmentItem(ureq, menuTree.getSelectedNode(), new FIBAssessmentItemBuilder(translate("new.fib.numerical"), EntryType.numerical, qtiService.qtiSerializer()));
    } else if (newHotspotLink == source) {
        doNewAssessmentItem(ureq, menuTree.getSelectedNode(), new HotspotAssessmentItemBuilder(translate("new.hotspot"), qtiService.qtiSerializer()));
    } else if (newHottextLink == source) {
        doNewAssessmentItem(ureq, menuTree.getSelectedNode(), new HottextAssessmentItemBuilder(translate("new.hottext"), translate("new.hottext.start"), translate("new.hottext.text"), qtiService.qtiSerializer()));
    } else if (newEssayLink == source) {
        doNewAssessmentItem(ureq, menuTree.getSelectedNode(), new EssayAssessmentItemBuilder(translate("new.essay"), qtiService.qtiSerializer()));
    } else if (newUploadLink == source) {
        doNewAssessmentItem(ureq, menuTree.getSelectedNode(), new UploadAssessmentItemBuilder(translate("new.upload"), qtiService.qtiSerializer()));
    } else if (newDrawingLink == source) {
        doNewAssessmentItem(ureq, menuTree.getSelectedNode(), new DrawingAssessmentItemBuilder(translate("new.drawing"), qtiService.qtiSerializer()));
    } else if (importFromPoolLink == source) {
        doSelectQItem(ureq);
    } else if (importFromTableLink == source) {
        doImportTable(ureq);
    } else if (exportToPoolLink == source) {
        doExportPool();
    } else if (exportToDocxLink == source) {
        doExportDocx(ureq);
    } else if (deleteLink == source) {
        doConfirmDelete(ureq);
    } else if (copyLink == source) {
        doCopy(ureq);
    } else if (reloadInCacheLink == source) {
        doForceReloadFiles(ureq);
    }
}
Also used : HottextAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.HottextAssessmentItemBuilder) SingleChoiceAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.SingleChoiceAssessmentItemBuilder) EssayAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.EssayAssessmentItemBuilder) MultipleChoiceAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.MultipleChoiceAssessmentItemBuilder) MatchAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.MatchAssessmentItemBuilder) TreeEvent(org.olat.core.gui.components.tree.TreeEvent) FIBAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.FIBAssessmentItemBuilder) KPrimAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.KPrimAssessmentItemBuilder) TreeNode(org.olat.core.gui.components.tree.TreeNode) GenericTreeNode(org.olat.core.gui.components.tree.GenericTreeNode) HotspotAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.HotspotAssessmentItemBuilder) TreeDropEvent(org.olat.core.gui.components.tree.TreeDropEvent) UploadAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.UploadAssessmentItemBuilder) DrawingAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.DrawingAssessmentItemBuilder)

Example 50 with TreeEvent

use of org.olat.core.gui.components.tree.TreeEvent in project openolat by klemens.

the class DocumentPoolMainController method event.

@Override
protected void event(UserRequest ureq, Component source, Event event) {
    if (taxonomyTree == source) {
        if (event instanceof TreeEvent) {
            TreeEvent te = (TreeEvent) event;
            if (MenuTree.COMMAND_TREENODE_CLICKED.equals(te.getCommand())) {
                TaxonomyTreeNode node = (TaxonomyTreeNode) taxonomyTree.getTreeModel().getNodeById(te.getNodeId());
                doSelect(ureq, node);
            }
        }
    } else if (content == source) {
        if (event instanceof PopEvent) {
            PopEvent popEvent = (PopEvent) event;
            if (popEvent.getController() instanceof DocumentPoolLevelController) {
                DocumentPoolLevelController taxonomyLevelCtrl = (DocumentPoolLevelController) popEvent.getController();
                TaxonomyLevel level = taxonomyLevelCtrl.getTaxonomyLevel();
                TaxonomyTreeNode node = (TaxonomyTreeNode) TreeHelper.findNodeByUserObject(level, taxonomyTree.getTreeModel().getRootNode());
                TaxonomyTreeNode parentNode = (TaxonomyTreeNode) node.getParent();
                if (parentNode == null) {
                    doSelectTaxonomy(ureq);
                    taxonomyTree.setSelectedNode(taxonomyTree.getTreeModel().getRootNode());
                } else {
                    doSelect(ureq, parentNode);
                    taxonomyTree.setSelectedNode(parentNode);
                }
            } else if (popEvent.getUserObject() instanceof TaxonomyTreeNode) {
                TaxonomyTreeNode node = (TaxonomyTreeNode) popEvent.getUserObject();
                doSelect(ureq, node);
                taxonomyTree.setSelectedNode(node);
            } else if (popEvent.getController() instanceof DocumentDirectoryController) {
                // pop the templates
                taxonomyTree.setSelectedNode(taxonomyTree.getTreeModel().getRootNode());
            }
        }
    }
}
Also used : TreeEvent(org.olat.core.gui.components.tree.TreeEvent) TaxonomyLevel(org.olat.modules.taxonomy.TaxonomyLevel) TaxonomyTreeNode(org.olat.modules.taxonomy.model.TaxonomyTreeNode) PopEvent(org.olat.core.gui.components.stack.PopEvent)

Aggregations

TreeEvent (org.olat.core.gui.components.tree.TreeEvent)50 TreeNode (org.olat.core.gui.components.tree.TreeNode)32 GenericTreeNode (org.olat.core.gui.components.tree.GenericTreeNode)14 TreeDropEvent (org.olat.core.gui.components.tree.TreeDropEvent)12 CourseNode (org.olat.course.nodes.CourseNode)10 ArrayList (java.util.ArrayList)8 Event (org.olat.core.gui.control.Event)6 Component (org.olat.core.gui.components.Component)4 Link (org.olat.core.gui.components.link.Link)4 GenericTreeModel (org.olat.core.gui.components.tree.GenericTreeModel)4 CloseableModalController (org.olat.core.gui.control.generic.closablewrapper.CloseableModalController)4 STCourseNode (org.olat.course.nodes.STCourseNode)4 AbstractArtefact (org.olat.portfolio.model.artefacts.AbstractArtefact)4 PortfolioStructure (org.olat.portfolio.model.structel.PortfolioStructure)4 List (java.util.List)2 FolderEvent (org.olat.core.commons.modules.bc.FolderEvent)2 NewInlineUriEvent (org.olat.core.gui.components.htmlsite.NewInlineUriEvent)2 OlatCmdEvent (org.olat.core.gui.components.htmlsite.OlatCmdEvent)2 PopEvent (org.olat.core.gui.components.stack.PopEvent)2 TableEvent (org.olat.core.gui.components.table.TableEvent)2