use of org.olat.core.gui.components.tree.TreeEvent in project OpenOLAT by OpenOLAT.
the class RunMainController method event.
/**
* @see org.olat.core.gui.control.DefaultController#event(org.olat.core.gui.UserRequest,
* org.olat.core.gui.components.Component,
* org.olat.core.gui.control.Event)
*/
@Override
public void event(UserRequest ureq, Component source, Event event) {
if (needsRebuildAfter) {
currentCourseNode = updateAfterChanges(currentCourseNode);
needsRebuildAfter = false;
}
// Links in editTools dropdown
if (nextLink == source) {
doNext(ureq);
} else if (previousLink == source) {
doPrevious(ureq);
} else if (source == luTree) {
if (event.getCommand().equals(MenuTree.COMMAND_TREENODE_CLICKED) || event.getCommand().equals(MenuTree.COMMAND_TREENODE_EXPANDED)) {
TreeEvent tev = (TreeEvent) event;
doNodeClick(ureq, tev);
}
} else if (source == coursemain) {
if ("activateCourseNode".equals(event.getCommand())) {
// Events from the JS function o_activateCourseNode() - activate the given node id
String nodeid = ureq.getParameter("nodeid");
if (nodeid != null) {
CourseNode identNode = course.getRunStructure().getNode(nodeid);
CourseNode node = updateTreeAndContent(ureq, identNode, null);
if (node != null) {
currentCourseNode = node;
} else {
getWindowControl().setWarning(translate("msg.nodenotavailableanymore"));
}
}
}
}
}
use of org.olat.core.gui.components.tree.TreeEvent in project OpenOLAT by OpenOLAT.
the class RunMainController method doPrevious.
private void doPrevious(UserRequest ureq) {
List<TreeNode> flatList = new ArrayList<>();
TreeNode currentNode = luTree.getSelectedNode();
TreeHelper.makeTreeFlat(luTree.getTreeModel().getRootNode(), flatList);
int index = flatList.indexOf(currentNode);
if (index - 1 >= 0 && index - 1 < flatList.size()) {
TreeNode previousNode = flatList.get(index - 1);
TreeEvent tev = new TreeEvent(MenuTree.COMMAND_TREENODE_CLICKED, previousNode.getIdent());
doNodeClick(ureq, tev);
}
}
use of org.olat.core.gui.components.tree.TreeEvent in project OpenOLAT by OpenOLAT.
the class PreviewRunController method event.
/**
* @see org.olat.core.gui.control.DefaultController#event(org.olat.core.gui.UserRequest,
* org.olat.core.gui.components.Component, org.olat.core.gui.control.Event)
*/
@Override
public void event(UserRequest ureq, Component source, Event event) {
if (source == luTree) {
if (event.getCommand().equals(MenuTree.COMMAND_TREENODE_CLICKED)) {
TreeEvent tev = (TreeEvent) event;
// goto node:
// after a click in the tree, evaluate the model anew, set the tree
// model anew, and set the selection of the tree again
NodeClickedRef nclr = navHandler.evaluateJumpToTreeNode(ureq, getWindowControl(), treeModel, tev, this, null, currentNodeController);
if (!nclr.isVisible()) {
getWindowControl().setWarning(translate("warn.notvisible"));
return;
}
if (nclr.isHandledBySubTreeModelListener()) {
// not used:
return;
}
// set the new treemodel
treeModel = nclr.getTreeModel();
luTree.setTreeModel(treeModel);
// set the new tree selection
luTree.setSelectedNodeId(nclr.getSelectedNodeId());
luTree.setOpenNodeIds(nclr.getOpenNodeIds());
// get the controller (in this case it is a preview controller). Dispose only if not already disposed in navHandler.evaluateJumpToTreeNode()
if (nclr.getRunController() != null) {
if (currentNodeController != null && !currentNodeController.isDisposed() && !navHandler.isListening(currentNodeController)) {
currentNodeController.dispose();
}
currentNodeController = nclr.getRunController();
}
CourseNode cn = nclr.getCalledCourseNode();
if (cn != null) {
Condition c = cn.getPreConditionVisibility();
String visibilityExpr = (c.getConditionExpression() == null ? translate("details.visibility.none") : c.getConditionExpression());
detail.contextPut("visibilityExpr", visibilityExpr);
detail.contextPut("coursenode", cn);
currentCourseNode = cn;
}
Component nodeComp = currentNodeController.getInitialComponent();
content.setContent(nodeComp);
}
} else if (source == configButton) {
fireEvent(ureq, new Event("command.config"));
}
}
use of org.olat.core.gui.components.tree.TreeEvent in project OpenOLAT by OpenOLAT.
the class EditorMainController method event.
/**
* @see org.olat.core.gui.control.DefaultController#event(org.olat.core.gui.UserRequest,
* org.olat.core.gui.components.Component, org.olat.core.gui.control.Event)
*/
@Override
public void event(UserRequest ureq, Component source, Event event) {
try {
ICourse course = CourseFactory.getCourseEditSession(ores.getResourceableId());
if (source == menuTree) {
if (event.getCommand().equals(MenuTree.COMMAND_TREENODE_CLICKED)) {
// goto node in edit mode
TreeEvent te = (TreeEvent) event;
String nodeId = te.getNodeId();
updateViewForSelectedNodeId(ureq, nodeId);
} else if (event.getCommand().equals(MenuTree.COMMAND_TREENODE_DROP)) {
TreeDropEvent te = (TreeDropEvent) event;
dropNodeAsChild(ureq, course, te.getDroppedNodeId(), te.getTargetNodeId(), te.isAsChild(), te.isAtTheEnd());
}
} else if (source == main) {
if (event.getCommand().startsWith(NLS_START_HELP_WIZARD)) {
doStartHelpWizard(ureq, event);
}
} else if (source == undelButton) {
doUndelete(ureq, course);
} else if (source == alternativeLink) {
CourseNode chosenNode = (CourseNode) alternativeLink.getUserObject();
askForAlternative(ureq, chosenNode);
} else if (previewLink == source) {
launchPreview(ureq, course);
} else if (publishLink == source) {
launchPublishingWizard(ureq, course, false);
} else if (closeLink == source) {
doReleaseEditLock();
fireEvent(ureq, Event.DONE_EVENT);
} else if (createNodeLink == source) {
doOpenNodeTypeChooser(ureq);
} else if (deleteNodeLink == source) {
doDeleteNode(ureq);
} else if (moveNodeLink == source) {
doMove(ureq, course, false);
} else if (copyNodeLink == source) {
doMove(ureq, course, true);
} else if (statusLink == source) {
doOpenStatusOverview(ureq);
}
} catch (RuntimeException e) {
log.warn(RELEASE_LOCK_AT_CATCH_EXCEPTION + " [in event(UserRequest,Component,Event)]", e);
dispose();
throw e;
}
}
use of org.olat.core.gui.components.tree.TreeEvent in project OpenOLAT by OpenOLAT.
the class CPEditMainController method event.
@Override
protected void event(UserRequest ureq, Controller source, Event event) {
if (source == treeCtr) {
if (event instanceof TreeEvent) {
TreeEvent te = (TreeEvent) event;
String nodeId = te.getNodeId();
contentCtr.displayPage(ureq, nodeId);
} else if (event.getCommand().equals("New Page")) {
String newIdentifier = treeCtr.addNewHTMLPage();
contentCtr.displayPageWithMetadataEditor(ureq, newIdentifier);
} else if (event instanceof NewCPPageEvent) {
contentCtr.displayPageWithMetadataEditor(ureq, ((NewCPPageEvent) event).getCPPage().getIdentifier());
}
} else if (source == contentCtr) {
// event from contentController
if (event instanceof NewCPPageEvent) {
NewCPPageEvent ncpEvent = (NewCPPageEvent) event;
CPPage page = ncpEvent.getCPPage();
if (event.getCommand().equals("New Page Saved")) {
String newNodeID = treeCtr.addPage(page);
contentCtr.newPageAdded(newNodeID);
treeCtr.updatePage(page);
} else if (event.getCommand().equals("Page Saved")) {
treeCtr.updatePage(page);
// Title could have changed -> dirty view
treeCtr.getInitialComponent().setDirty(true);
}
} else if (event.getCommand().equals("Page loaded")) {
CPPage page = contentCtr.getCurrentPage();
if (page != null) {
treeCtr.selectTreeNodeByCPPage(page);
}
}
}
}
Aggregations