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);
}
}
}
}
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));
}
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);
}
}
}
}
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);
}
}
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());
}
}
}
}
Aggregations