use of org.olat.core.gui.components.tree.TreeEvent in project OpenOLAT by OpenOLAT.
the class CPDisplayController 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 == cpTree) {
// TreeEvent.dito...
if (event.getCommand().equals(MenuTree.COMMAND_TREENODE_CLICKED)) {
TreeEvent te = (TreeEvent) event;
switchToPage(ureq, te);
}
} else if (source == cpComponent) {
if (event instanceof NewInlineUriEvent) {
NewInlineUriEvent nue = (NewInlineUriEvent) event;
// adjust the tree selection to the current choice if found
selectTreeNode(ureq, nue.getNewUri());
}
} else if (source == nextLink) {
TreeNode nextUri = (TreeNode) nextLink.getUserObject();
switchToPage(ureq, nextUri);
if (cpTree != null) {
cpTree.setSelectedNode(nextUri);
}
fireEvent(ureq, new TreeNodeEvent(nextUri));
} else if (source == previousLink) {
TreeNode previousUri = (TreeNode) previousLink.getUserObject();
if (cpTree != null) {
cpTree.setSelectedNode(previousUri);
}
switchToPage(ureq, previousUri);
fireEvent(ureq, new TreeNodeEvent(previousUri));
} else if (source == printLink) {
selectPagesToPrint(ureq);
}
}
use of org.olat.core.gui.components.tree.TreeEvent in project OpenOLAT by OpenOLAT.
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 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 klemens.
the class CPTreeController method event.
/**
* Event-handling from components
*/
protected void event(UserRequest ureq, Component source, Event event) {
if (source == importLink) {
uploadCtr = new CPFileImportController(ureq, getWindowControl(), cp, currentPage);
listenTo(uploadCtr);
String title = translate("cpfileuploadcontroller.form.title");
cmc = new CloseableModalController(getWindowControl(), translate("close"), uploadCtr.getInitialComponent(), true, title);
listenTo(cmc);
cmc.activate();
} else if (source == newLink) {
fireEvent(ureq, new Event("New Page"));
} else if (source == copyLink) {
if (currentPage.isOrgaPage()) {
showInfo("cptreecontroller.orga.cannot.be.copied");
} else {
String newIdentifier = copyPage(currentPage);
contentCtr.displayPageWithMetadataEditor(ureq, newIdentifier);
}
} else if (source == deleteLink) {
if (currentPage.isOrgaPage()) {
showInfo("cptreecontroller.orga.cannot.be.deleted");
} else {
List<String> buttonLables = new ArrayList<String>();
buttonLables.add(translate("cptreecontrolller.delete.items.and.files"));
buttonLables.add(translate("cptreecontrolller.delete.items.only"));
buttonLables.add(translate("cancel"));
dialogCtr = DialogBoxUIFactory.createGenericDialog(ureq, getWindowControl(), translate("cptreecontroller.q_delete_title"), translate("cptreecontroller.q_delete_text", getCurrentPageInfoStringHTML()), buttonLables);
listenTo(dialogCtr);
dialogCtr.activate();
}
} else if (source == treeCtr) {
if (event instanceof TreeEvent) {
TreeEvent te = (TreeEvent) event;
String selectedNodeID = treeModel.getIdentifierForNodeID(te.getNodeId());
currentPage = new CPPage(selectedNodeID, cp);
fireEvent(ureq, new TreeEvent(TreeEvent.COMMAND_TREENODE_CLICKED, selectedNodeID));
} else if (event instanceof TreeDropEvent) {
TreeDropEvent te = (TreeDropEvent) event;
doDrop(ureq, te.getDroppedNodeId(), te.getTargetNodeId(), te.isAsChild());
}
}
}
use of org.olat.core.gui.components.tree.TreeEvent in project openolat by klemens.
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