use of org.olat.core.gui.components.link.Link in project openolat by klemens.
the class CatalogNodeController method event.
@Override
public void event(UserRequest ureq, Component source, Event event) {
if (source instanceof Link) {
Link link = (Link) source;
if ("select_node".equals(link.getCommand())) {
Long categoryNodeKey = (Long) link.getUserObject();
CatalogEntry entry = catalogManager.getCatalogNodeByKey(categoryNodeKey);
selectCatalogEntry(ureq, entry);
}
} else if ("img_select".equals(event.getCommand())) {
String node = ureq.getParameter("node");
if (StringHelper.isLong(node)) {
try {
Long categoryNodeKey = new Long(node);
CatalogEntry entry = catalogManager.getCatalogNodeByKey(categoryNodeKey);
selectCatalogEntry(ureq, entry);
} catch (NumberFormatException e) {
logWarn("Not a valid long: " + node, e);
}
}
}
}
use of org.olat.core.gui.components.link.Link in project openolat by klemens.
the class CatalogNodeManagerController method loadNodesChildren.
protected void loadNodesChildren() {
List<CatalogEntry> childCe = catalogManager.getNodesChildrenOf(catalogEntry);
Collections.sort(childCe, new CatalogEntryComparator(getLocale()));
List<String> subCategories = new ArrayList<>();
int count = 0;
for (CatalogEntry entry : childCe) {
if (entry.getType() == CatalogEntry.TYPE_NODE) {
String cmpId = "cat_" + (++count);
VFSLeaf img = catalogManager.getImage(entry);
if (img != null) {
String imgId = "image_" + count;
flc.contextPut(imgId, img.getName());
}
flc.contextPut("k" + cmpId, entry.getKey());
String title = StringHelper.escapeHtml(entry.getName());
Link link = LinkFactory.createCustomLink(cmpId, "select_node", cmpId, Link.LINK + Link.NONTRANSLATED, flc.getFormItemComponent(), this);
link.setIconLeftCSS("o_icon o_icon_catalog_sub");
link.setCustomDisplayText(title);
link.setUserObject(entry.getKey());
subCategories.add(Integer.toString(count));
String titleId = "title_" + count;
flc.contextPut(titleId, title);
}
}
flc.contextPut("subCategories", subCategories);
}
use of org.olat.core.gui.components.link.Link in project openolat by klemens.
the class CreateTestTargetController method event.
@Override
protected void event(UserRequest ureq, Component source, Event event) {
if (source == formatQti12 || source == formatQti21) {
Link link = (Link) source;
String format = (String) link.getUserObject();
ExportFormatOptions exportFormat = getExportFormat(format);
fireEvent(ureq, new ExportFormatSelectionEvent(exportFormat));
}
}
use of org.olat.core.gui.components.link.Link in project openolat by klemens.
the class WikiMainController method event.
@Override
public void event(UserRequest ureq, Component source, Event event) {
String command = event.getCommand();
setTabsEnabled(true);
// to make shure we use the lateste page, reload from cache
Wiki wiki = getWiki();
if (wiki == null) {
mainPanel.setContent(createVelocityContainer("deleted"));
return;
}
WikiPage page = null;
// FIXME:gs images and media should also be wiki pages -> see jamwiki
if (!(event instanceof RequestNewPageEvent) && !(event instanceof RequestMediaEvent) && !(event instanceof RequestImageEvent)) {
page = wiki.getPage(pageId, true);
// set recent page id to the page currently used
if (page != null) {
pageId = page.getPageId();
}
}
if (source == content) {
// noting yet
} else if (source == tabs) {
/**
***********************************************************************
* tabbed pane events
***********************************************************************
*/
TabbedPaneChangedEvent tabEvent = (TabbedPaneChangedEvent) event;
Component comp = tabEvent.getNewComponent();
String compName = comp.getComponentName();
selectTab(ureq, command, compName, page, wiki);
} else if (source == wikiArticleComp) {
/**
***********************************************************************
* wiki component events
***********************************************************************
*/
if (event instanceof RequestPageEvent) {
RequestPageEvent pageEvent = (RequestPageEvent) event;
page = openPage(ureq, pageEvent.getCommand(), wiki);
} else if (event instanceof RequestNewPageEvent) {
page = handleRequestNewPageEvent(ureq, (RequestNewPageEvent) event, wiki);
} else if (event instanceof ErrorEvent) {
showWarning(event.getCommand());
} else if (event instanceof RequestMediaEvent) {
deliverMediaFile(ureq, event.getCommand());
} else if (event instanceof RequestImageEvent) {
// instead of linking to the image-view-page itself
if (isImageDetailView) {
page = wiki.getPage(pageId, true);
updatePageContext(ureq, page);
isImageDetailView = false;
} else {
final WikiPage imagePage = new WikiPage(event.getCommand());
imagePage.setContent("[[Image:" + event.getCommand() + "]]");
articleContent.contextPut("page", imagePage);
wikiArticleComp.setWikiContent(imagePage.getContent());
setTabsEnabled(false);
isImageDetailView = true;
}
}
} else if (source == navigationContent) {
/**
***********************************************************************
* article container events
***********************************************************************
*/
if (command.equals(ACTION_EDIT_MENU)) {
page = wiki.getPage(WikiPage.WIKI_MENU_PAGE);
updateFileAndLinkList(wiki);
tryToSetEditLock(page, ureq, ores);
updatePageContext(ureq, page);
tabs.setSelectedPane(ureq, 2);
}
} else if (source == toMainPageLink) {
// home link
page = openIndexPage(ureq, wiki);
} else if (source == a2zLink) {
openAtoZPage(ureq, wiki);
} else if (source == changesLink) {
openLastChangesPage(ureq, wiki);
} else if (source == editMenuButton) {
page = wiki.getPage(WikiPage.WIKI_MENU_PAGE);
updateFileAndLinkList(wiki);
tryToSetEditLock(page, ureq, ores);
updatePageContext(ureq, page);
// wikiEditForm.setPage(page);
tabs.setSelectedPane(ureq, 2);
} else if (source == archiveLink) {
// archive a snapshot of the wiki in the users personal folder
archiveWikiDialogCtr = activateOkCancelDialog(ureq, null, translate("archive.question"), archiveWikiDialogCtr);
return;
} else if (source == createLink) {
removeAsListenerAndDispose(calloutCtrl);
removeAsListenerAndDispose(createArticleForm);
createArticleForm = new WikiArticleSearchForm(ureq, getWindowControl());
listenTo(createArticleForm);
calloutCtrl = new CloseableCalloutWindowController(ureq, getWindowControl(), createArticleForm.getInitialComponent(), createLink, "", true, null);
listenTo(calloutCtrl);
calloutCtrl.activate();
} else if (source == versioningContent) {
// nothing to do
} else if (source == editContent) {
// nothing to do
} else if (source == closePreviewButton) {
editContent.remove(wikiVersionDisplayComp);
} else if (source == revertVersionButton) {
wikiEditForm.setPage(selectedPage);
tabs.setSelectedPane(ureq, 2);
tryToSetEditLock(page, ureq, ores);
} else if (source instanceof Link && "select-page".equals(command)) {
String name = source.getComponentName();
page = openPage(ureq, name, wiki);
}
// set recent page id to the page currently used
if (page != null) {
this.pageId = page.getPageId();
}
}
use of org.olat.core.gui.components.link.Link in project openolat by klemens.
the class WikiMainController method openPage.
private WikiPage openPage(UserRequest ureq, String name, Wiki wiki) {
WikiPage page = wiki.getPage(name, true);
page.incrementViewCount();
updatePageContext(ureq, page);
Link pageLink = LinkFactory.createToolLink(page.getPageName(), "select-page", page.getPageName(), this);
breadcrumpDropdown.addComponent(pageLink);
setTabsEnabled(true);
tabs.setSelectedPane(ureq, 0);
return page;
}
Aggregations