use of org.olat.core.gui.components.tree.TreeEvent in project OpenOLAT by OpenOLAT.
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 OpenOLAT.
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 OpenOLAT.
the class QuestionPoolMainEditorController method event.
@Override
protected void event(UserRequest ureq, Component source, Event event) {
if (menuTree == source) {
if (event instanceof TreeDropEvent) {
TreeDropEvent e = (TreeDropEvent) event;
String targetId = e.getTargetNodeId();
String dropId = e.getDroppedNodeId();
// drop id w_o_fi1000002357-4
doDrop(ureq, targetId, dropId);
} else if (event instanceof TreeEvent) {
TreeEvent te = (TreeEvent) event;
if (MenuTree.COMMAND_TREENODE_CLICKED.equals(te.getCommand())) {
TreeNode node = menuTree.getTreeModel().getNodeById(te.getNodeId());
doSelectControllerTreeNode(ureq, node, null, null);
}
}
}
}
use of org.olat.core.gui.components.tree.TreeEvent in project openolat by klemens.
the class WikiMainController method event.
@Override
public void event(UserRequest ureq, Controller source, Event event) {
Wiki wiki = getWiki();
if (wiki == null) {
mainPanel.setContent(createVelocityContainer("deleted"));
return;
}
// reload page from cache
WikiPage page = wiki.getPage(pageId, true);
// set recent page id to the page currently used
this.pageId = page.getPageId();
if (event instanceof TreeEvent) {
TreeEvent te = (TreeEvent) event;
String nodeId = te.getNodeId();
if (navAZNode.getIdent().equals(nodeId)) {
openAtoZPage(ureq, wiki);
} else if (navChangesNode.getIdent().equals(nodeId)) {
openLastChangesPage(ureq, wiki);
} else if (navMainPageNode.getIdent().equals(nodeId)) {
page = openIndexPage(ureq, wiki);
} else if (wikiMenuNode.getIdent().equals(nodeId)) {
page = openPage(ureq, WikiPage.WIKI_MENU_PAGE, wiki);
} else {
TreeNode node = wikiMenuModel.getNodeById(nodeId);
if (node != null && node.getUserObject() instanceof String) {
String link = (String) node.getUserObject();
page = openPage(ureq, link, wiki);
}
}
if (page != null) {
this.pageId = page.getPageId();
}
} else if (source == versioningTableCtr) {
/**
***********************************************************************
* history table events
***********************************************************************
*/
if (event.getCommand().equals(Table.COMMANDLINK_ROWACTION_CLICKED)) {
TableEvent te = (TableEvent) event;
if (te.getActionId().equals(ACTION_COMPARE)) {
selectedPage = versioningTableModel.getObject(te.getRowId());
diffs = wiki.getDiff(page, selectedPage.getVersion() - 1, selectedPage.getVersion());
versioningContent.contextPut("diffs", diffs);
versioningContent.remove(wikiVersionDisplayComp);
versioningContent.contextPut("page", selectedPage);
} else if (te.getActionId().equals(ACTION_SHOW)) {
versioningContent.contextRemove("diffs");
selectedPage = versioningTableModel.getObject(te.getRowId());
selectedPage = wiki.loadVersion(selectedPage, selectedPage.getVersion());
wikiVersionDisplayComp.setWikiContent(selectedPage.getContent());
wikiVersionDisplayComp.setImageMapperUri(ureq, wikiContainer);
versioningContent.put("versionDisplay", wikiVersionDisplayComp);
versioningContent.contextPut("page", selectedPage);
}
}
} else if (source == wikiUploadFileCtr) {
if (event.getCommand().equals(FolderEvent.UPLOAD_EVENT)) {
FolderEvent fEvent = (FolderEvent) event;
createMediaMetadataFile(fEvent.getFilename(), ureq.getIdentity().getKey());
updateFileAndLinkList(wiki);
}
cmc.deactivate();
cleanUp();
} else if (source == removePageDialogCtr) {
if (DialogBoxUIFactory.isOkEvent(event)) {
wiki.removePage(page);
breadcrumpDropdown.removeComponent(page.getPageName());
WikiManager.getInstance().deleteWikiPage(ores, page);
page = wiki.getPage(WikiPage.WIKI_INDEX_PAGE);
updatePageContext(ureq, page);
tabs.setSelectedPane(ureq, 0);
}
} else if (source == mediaTableCtr) {
if (event.getCommand().equals(Table.COMMANDLINK_ROWACTION_CLICKED)) {
TableEvent te = (TableEvent) event;
if (te.getActionId().equals(ACTION_DELETE_MEDIA)) {
List<MediaFileElement> list = new ArrayList<MediaFileElement>(1);
list.add(mediaFilesTableModel.getObject(te.getRowId()));
deleteMediaFile(list, ureq);
} else if (te.getActionId().equals(ACTION_SHOW_MEDIA)) {
// show a selected file from the media folder
MediaFileElement element = mediaFilesTableModel.getObject(te.getRowId());
if (isImage(element.getFilename())) {
// show images inline
// as modal overlay
imageDisplay.contextPut("mediaElement", element);
imageDisplay.contextPut("imageUri", wikiArticleComp.getImageBaseUri());
removeAsListenerAndDispose(cmc);
cmc = new CloseableModalController(getWindowControl(), translate("close"), imageDisplay);
listenTo(cmc);
cmc.activate();
} else {
deliverMediaFile(ureq, element.getFilename());
}
}
} else if (event.getCommand().equals(Table.COMMAND_MULTISELECT)) {
TableMultiSelectEvent tmse = (TableMultiSelectEvent) event;
if (tmse.getAction().equals(ACTION_DELETE_MEDIAS)) {
deleteMediaFile(mediaFilesTableModel.getObjects(tmse.getSelection()), ureq);
updateFileAndLinkList(wiki);
}
}
} else if (source == archiveWikiDialogCtr) {
if (DialogBoxUIFactory.isOkEvent(event)) {
WikiToCPResource rsrc = new WikiToCPResource(ores, getIdentity(), getTranslator());
ureq.getDispatchResult().setResultingMediaResource(rsrc);
}
} else if (source == createArticleForm) {
calloutCtrl.deactivate();
String query = createArticleForm.getQuery();
if (!StringHelper.containsNonWhitespace(query)) {
query = WikiPage.WIKI_INDEX_PAGE;
}
page = wiki.findPage(query);
pageId = page.getPageId();
if (page.getPageName().equals(Wiki.NEW_PAGE)) {
setTabsEnabled(false);
}
page.incrementViewCount();
updatePageContext(ureq, page);
if (!page.getPageName().startsWith("O_")) {
Link pageLink = LinkFactory.createToolLink(page.getPageName(), "select-page", page.getPageName(), this);
breadcrumpDropdown.addComponent(pageLink);
}
tabs.setSelectedPane(ureq, 0);
} else if (source == wikiEditForm) {
// set recent page id to the page currently used
this.pageId = page.getPageId();
boolean wantPreview = false;
boolean wantSave = false;
boolean wantClose = false;
if (event == Event.CANCELLED_EVENT) {
wantClose = true;
} else if (event == Event.DONE_EVENT) {
wantSave = true;
} else if (event.getCommand().equals("save.and.close")) {
wantClose = true;
wantSave = true;
event = Event.DONE_EVENT;
} else if (event.getCommand().equals("preview")) {
wantPreview = true;
event = Event.DONE_EVENT;
} else if (event.getCommand().equals("delete.page")) {
String msg = translate("question", page.getPageName());
removePageDialogCtr = activateOkCancelDialog(ureq, null, msg, removePageDialogCtr);
return;
} else if (event.getCommand().equals("media.upload")) {
doUploadFiles(ureq);
return;
} else if (event.getCommand().equals("manage.media")) {
doManageMedias(ureq, wiki);
return;
}
boolean dirty = !wikiEditForm.getWikiContent().equals(page.getContent());
if (wantPreview) {
WikiPage preview = new WikiPage("temp");
preview.setContent(wikiEditForm.getWikiContent());
wikiVersionDisplayComp.setWikiContent(preview.getContent());
editContent.put("versionDisplay", wikiVersionDisplayComp);
}
if (wantSave && dirty) {
editContent.contextPut("isDirty", Boolean.valueOf(false));
page.setContent(wikiEditForm.getWikiContent());
page.setModifyAuthor(getIdentity().getKey().longValue());
page.setUpdateComment(wikiEditForm.getUpdateComment());
if (page.getInitalAuthor() == 0)
page.setInitalAuthor(getIdentity().getKey().longValue());
// changed
if (page.getPageName().equals(WikiPage.WIKI_MENU_PAGE)) {
updateWikiMenu(wiki);
}
WikiManager.getInstance().saveWikiPage(ores, page, true, wiki);
// inform subscription context about changes
NotificationsManager.getInstance().markPublisherNews(subsContext, ureq.getIdentity(), true);
updatePageContext(ureq, page);
}
if (dirty && wantPreview && !wantSave) {
// wikiEditForm.setDirty(true);
editContent.contextPut("isDirty", Boolean.valueOf(dirty));
}
if (wantClose) {
tabs.setSelectedPane(ureq, 0);
doReleaseEditLock();
return;
}
}
}
use of org.olat.core.gui.components.tree.TreeEvent in project openolat by klemens.
the class EPTOCController 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
protected void event(UserRequest ureq, Component source, Event event) {
if (source instanceof Link) {
Link link = (Link) source;
if (link.getCommand().equals(DELETE_LINK_CMD)) {
if (artefactClicked != null) {
AbstractArtefact artefact = artefactClicked;
PortfolioStructure parentStruct = getArtefactParentStruct(artefactClicked);
ePFMgr.removeArtefactFromStructure(artefact, parentStruct);
// refresh the view
fireEvent(ureq, Event.CHANGED_EVENT);
} else if (structureClicked != null) {
if ((structureClicked instanceof EPPage) && !(structureClicked instanceof EPAbstractMap)) {
PortfolioStructure ps = structureClicked;
while (ePFMgr.loadStructureParent(ps) != null) {
ps = ePFMgr.loadStructureParent(ps);
}
int childPages = ePFMgr.countStructureChildren(ps);
if (childPages > 1) {
eSTMgr.removeStructureRecursively(structureClicked);
// refresh the view
fireEvent(ureq, Event.CHANGED_EVENT);
} else {
showError("last.page.not.deletable");
}
} else if (structureClicked instanceof EPStructureElement && !(structureClicked instanceof EPAbstractMap)) {
// structures should always be deletable
eSTMgr.removeStructureRecursively(structureClicked);
// refresh the view
fireEvent(ureq, Event.CHANGED_EVENT);
} else {
showInfo("element.not.deletable");
}
}
}
} else if (source == treeCtr) {
if (event instanceof TreeEvent) {
TreeEvent te = (TreeEvent) event;
if (MenuTree.COMMAND_TREENODE_CLICKED.equals(te.getCommand())) {
doSelectTreeElement(ureq, te);
}
} else if (event instanceof TreeDropEvent) {
TreeDropEvent te = (TreeDropEvent) event;
doDrop(ureq, te.getDroppedNodeId(), te.getTargetNodeId(), te.isAsChild());
}
}
}
Aggregations