use of org.olat.core.gui.components.tree.TreeEvent in project OpenOLAT by OpenOLAT.
the class RunMainController method doNext.
private void doNext(UserRequest ureq) {
List<TreeNode> flatList = new ArrayList<>();
TreeNode currentNode = luTree.getSelectedNode();
TreeHelper.makeTreeFlat(luTree.getTreeModel().getRootNode(), flatList);
int index = flatList.indexOf(currentNode);
if (index >= 0 && index + 1 < flatList.size()) {
TreeNode nextNode = flatList.get(index + 1);
TreeEvent tev = new TreeEvent(MenuTree.COMMAND_TREENODE_CLICKED, nextNode.getIdent());
doNodeClick(ureq, tev);
}
}
use of org.olat.core.gui.components.tree.TreeEvent in project OpenOLAT by OpenOLAT.
the class CPDisplayController method activate.
@Override
public void activate(UserRequest ureq, List<ContextEntry> entries, StateEntry state) {
if (entries == null || entries.isEmpty())
return;
Long id = entries.get(0).getOLATResourceable().getResourceableId();
TreeNode newNode = null;
if (id != null && id.longValue() > 0l) {
newNode = ctm.getNodeById(id.toString());
}
if (newNode == null) {
String path = BusinessControlFactory.getInstance().getPath(entries.get(0));
newNode = ctm.lookupTreeNodeByHref(path);
}
if (newNode != null) {
selectTreeNode(ureq, newNode);
switchToPage(ureq, new TreeEvent(TreeEvent.COMMAND_TREENODES_SELECTED, newNode.getIdent()));
}
}
use of org.olat.core.gui.components.tree.TreeEvent in project OpenOLAT by OpenOLAT.
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());
}
}
}
}
use of org.olat.core.gui.components.tree.TreeEvent in project OpenOLAT by OpenOLAT.
the class GenericMainController method event.
@Override
protected void event(UserRequest ureq, Component source, Event event) {
if (source == olatMenuTree) {
if (event instanceof TreeEvent && event.getCommand().equals(MenuTree.COMMAND_TREENODE_CLICKED)) {
TreeEvent te = (TreeEvent) event;
if (te.getSubCommand() != null) {
// filter open/close events
} else {
// process menu commands
TreeNode selTreeNode = olatMenuTree.getSelectedNode();
// cleanup old content controller (never null)
removeAsListenerAndDispose(contentCtr);
// create new content controller
// Following cases:
// 1a) Simple Action Extension using only ureq and windowControl ->
// handled by default implementation of createController
// 1b) Specialised Action Extension which needs some more internals ->
// handled by the class extending GenericMainController, by overwriting
// createController
// 2) uobject is something special which needs evaluation by class
// extending GenericMainController
Object uobject = selTreeNode.getUserObject();
TreeNode delegatee = selTreeNode.getDelegate();
if (delegatee != null) {
olatMenuTree.setSelectedNode(delegatee);
}
contentCtr = getContentCtr(uobject, ureq);
listenTo(contentCtr);
Component resComp = contentCtr.getInitialComponent();
content.setContent(resComp);
addToHistory(ureq, contentCtr);
}
} else {
// the action was not allowed anymore
// display an empty field (empty panel)
content.setContent(null);
}
} else {
logWarn("Unhandled olatMenuTree event: " + event.getCommand(), null);
}
}
use of org.olat.core.gui.components.tree.TreeEvent in project OpenOLAT by OpenOLAT.
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);
}
}
Aggregations