use of org.olat.portfolio.model.structel.PortfolioStructure in project OpenOLAT by OpenOLAT.
the class EPTOCReadOnlyController method buildTOCModel.
/**
* builds the tocList recursively containing artefacts, pages and
* struct-Elements
*
* @param pStruct
* @param tocList
* list with TOCElement's to use in velocity
* @param level
* @param withArtefacts
* set false, to skip artefacts
*/
private void buildTOCModel(PortfolioStructure pStruct, List<TOCElement> tocList, int level) {
level++;
if (displayArtefactsInTOC) {
List<AbstractArtefact> artList = ePFMgr.getArtefacts(pStruct);
if (artList != null && artList.size() != 0) {
for (AbstractArtefact artefact : artList) {
String key = String.valueOf(artefact.getKey());
String title = StringHelper.escapeHtml(artefact.getTitle());
Link iconLink = LinkFactory.createCustomLink("arte_" + key, LINK_CMD_OPEN_ARTEFACT, "", Link.NONTRANSLATED, vC, this);
iconLink.setIconRightCSS("o_icon o_icon_start");
iconLink.setUserObject(pStruct);
Link titleLink = LinkFactory.createCustomLink("arte_t_" + key, LINK_CMD_OPEN_ARTEFACT, title, Link.NONTRANSLATED, vC, this);
titleLink.setUserObject(pStruct);
TOCElement actualTOCEl = new TOCElement(level, "artefact", titleLink, iconLink, null, null);
tocList.add(actualTOCEl);
}
}
}
List<PortfolioStructure> childs = ePFMgr.loadStructureChildren(pStruct);
if (childs != null && childs.size() != 0) {
for (PortfolioStructure portfolioStructure : childs) {
String type = "";
if (portfolioStructure instanceof EPPage) {
type = CONST_FOR_VC_STYLE_PAGE;
} else {
// a structure element
type = CONST_FOR_VC_STYLE_STRUCT;
}
String key = String.valueOf(portfolioStructure.getKey());
String title = StringHelper.escapeHtml(portfolioStructure.getTitle());
Link iconLink = LinkFactory.createCustomLink("portstruct" + key, LINK_CMD_OPEN_STRUCT, "", Link.NONTRANSLATED, vC, this);
iconLink.setIconRightCSS("o_icon o_icon_start");
iconLink.setUserObject(portfolioStructure);
Link titleLink = LinkFactory.createCustomLink("portstruct_t_" + key, LINK_CMD_OPEN_STRUCT, title, Link.NONTRANSLATED, vC, this);
titleLink.setUserObject(portfolioStructure);
Link commentLink = null;
if (portfolioStructure instanceof EPPage && secCallback.canCommentAndRate()) {
UserCommentsCount comments = getUserCommentsCount(portfolioStructure);
String count = comments == null ? "0" : comments.getCount().toString();
String label = translate("commentLink", new String[] { count });
commentLink = LinkFactory.createCustomLink("commentLink" + key, LINK_CMD_OPEN_COMMENTS, label, Link.NONTRANSLATED, vC, this);
commentLink.setIconLeftCSS("o_icon o_icon_comments");
commentLink.setUserObject(portfolioStructure);
}
// prefetch children to keep reference on them
List<TOCElement> tocChildList = new ArrayList<TOCElement>();
buildTOCModel(portfolioStructure, tocChildList, level);
TOCElement actualTOCEl = new TOCElement(level, type, titleLink, iconLink, commentLink, tocChildList);
tocList.add(actualTOCEl);
if (tocChildList.size() != 0) {
tocList.addAll(tocChildList);
}
}
}
}
use of org.olat.portfolio.model.structel.PortfolioStructure in project OpenOLAT by OpenOLAT.
the class EPMapViewController method view.
public void view(UserRequest ureq) {
PortfolioStructure currentEditedStructure = null;
if (editCtrl != null) {
removeAsListenerAndDispose(editCtrl);
mainVc.remove(editCtrl.getInitialComponent());
currentEditedStructure = editCtrl.getSelectedStructure();
}
initForm(ureq);
editMode = EditMode.view;
if (editButton != null) {
editButton.setCustomDisplayText(translate("map.editButton.on"));
}
if (currentEditedStructure != null && pageCtrl != null) {
EPPage page = getSelectedPage(currentEditedStructure);
if (page != null) {
pageCtrl.selectPage(ureq, page);
addToHistory(ureq, page, null);
}
}
}
use of org.olat.portfolio.model.structel.PortfolioStructure in project OpenOLAT by OpenOLAT.
the class EPMapViewController method edit.
public void edit(UserRequest ureq) {
if (canEditStructure()) {
removeAsListenerAndDispose(editCtrl);
PortfolioStructure selectedPage = null;
if (pageCtrl != null) {
selectedPage = pageCtrl.getSelectedPage();
}
initOrUpdateEditMode(ureq, selectedPage);
editMode = EditMode.editor;
}
}
use of org.olat.portfolio.model.structel.PortfolioStructure in project OpenOLAT by OpenOLAT.
the class EPMapViewController method initForm.
protected void initForm(UserRequest ureq) {
Identity ownerIdentity = ePFMgr.getFirstOwnerIdentity(map);
if (ownerIdentity != null) {
DisplayPortraitController portraitCtr = new DisplayPortraitController(ureq, getWindowControl(), ownerIdentity, false, true, true, false);
mainVc.put("ownerportrait", portraitCtr.getInitialComponent());
}
mainVc.contextPut("map", map);
mainVc.contextPut("style", ePFMgr.getValidStyleName(map));
mainVc.remove(mainVc.getComponent("map.editButton"));
if (secCallback.canEditStructure()) {
editButton = LinkFactory.createButton("map.editButton", mainVc, this);
editButton.setElementCssClass("o_sel_ep_edit_map");
editButton.setIconLeftCSS("o_icon o_icon-fw o_icon_edit");
if (editMode == EditMode.view) {
editButton.setCustomDisplayText(translate("map.editButton.on"));
} else {
editButton.setCustomDisplayText(translate("map.editButton.off"));
}
}
if (back) {
backLink = LinkFactory.createLinkBack(mainVc, this);
}
mainVc.remove(mainVc.getComponent("map.submit.assess"));
if (secCallback.canSubmitAssess() && !StructureStatusEnum.CLOSED.equals(map.getStatus())) {
submitAssessLink = LinkFactory.createButtonSmall("map.submit.assess", mainVc, this);
}
if (map instanceof EPStructuredMap) {
EPTargetResource resource = ((EPStructuredMap) map).getTargetResource();
RepositoryEntry repoEntry = repositoryManager.lookupRepositoryEntry(resource.getOLATResourceable(), false);
if (repoEntry != null) {
mainVc.contextPut("courseName", StringHelper.escapeHtml(repoEntry.getDisplayname()));
String url = Settings.getServerContextPathURI();
url += "/url/RepositoryEntry/" + repoEntry.getKey() + "/CourseNode/" + resource.getSubPath();
mainVc.contextPut("courseLink", url);
}
}
mainVc.remove(mainVc.getComponent("addButton"));
if (secCallback.canAddPage() && !StructureStatusEnum.CLOSED.equals(map.getStatus())) {
EPAddElementsController addButton = new EPAddElementsController(ureq, getWindowControl(), map);
if (secCallback.canAddPage()) {
addButton.setShowLink(EPAddElementsController.ADD_PAGE);
}
mainVc.put("addButton", addButton.getInitialComponent());
listenTo(addButton);
}
mainVc.contextPut("closed", Boolean.valueOf((StructureStatusEnum.CLOSED.equals(map.getStatus()))));
List<PortfolioStructure> pageList = ePFMgr.loadStructureChildren(map);
if (pageList != null && pageList.size() != 0) {
// prepare to paint pages also
removeAsListenerAndDispose(pageCtrl);
pageCtrl = new EPMultiplePageController(ureq, getWindowControl(), pageList, secCallback);
mainVc.put("pagesCtrl", pageCtrl.getInitialComponent());
listenTo(pageCtrl);
} else if (mainVc.getComponent("pagesCtrl") != null) {
mainVc.remove(mainVc.getComponent("pagesCtrl"));
}
}
use of org.olat.portfolio.model.structel.PortfolioStructure in project OpenOLAT by OpenOLAT.
the class EPMultiplePageController method setAndInitTOCPage.
/**
* @param ureq
*/
private void setAndInitTOCPage(UserRequest ureq) {
// this is the toc
if (tocPageCtrl == null) {
PageTab page = pageList.get(0);
PortfolioStructure map = ePFMgr.loadStructureParent(page);
tocPageCtrl = new EPTOCReadOnlyController(ureq, getWindowControl(), map, secCallback);
listenTo(tocPageCtrl);
} else {
tocPageCtrl.refreshTOC(ureq);
}
disableLINK_LC(false);
disableLink_TOC(true);
currentActivePageCtrl = tocPageCtrl;
addToHistory(ureq, OresHelper.createOLATResourceableType("TOC"), null);
}
Aggregations