use of org.olat.portfolio.model.structel.EPPage 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.EPPage 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.EPPage in project openolat by klemens.
the class EPStructureManager method createPortfolioPage.
/**
* Create a page element
* @param title
* @param description
* @return The structure element
*/
protected PortfolioStructure createPortfolioPage(PortfolioStructure root, String title, String description) {
EPPage el = new EPPage();
el.setRoot((EPStructureElement) root);
if (root != null && root.getRootMap() == null && root instanceof PortfolioStructureMap) {
el.setRootMap((PortfolioStructureMap) root);
} else if (root != null) {
el.setRootMap(root.getRootMap());
}
return fillStructureElement(el, title, description);
}
use of org.olat.portfolio.model.structel.EPPage in project openolat by klemens.
the class EPFrontendManager method createAndPersistPortfolioPage.
/**
* create a page
* @param root
* @param title
* @param description
* @return
*/
public PortfolioStructure createAndPersistPortfolioPage(PortfolioStructure root, String title, String description) {
EPPage newPage = (EPPage) structureManager.createPortfolioPage(root, title, description);
if (root != null)
structureManager.addStructureToStructure(root, newPage, -1);
structureManager.savePortfolioStructure(newPage);
return newPage;
}
use of org.olat.portfolio.model.structel.EPPage in project openolat by klemens.
the class EPMapViewController method event.
/**
* @see org.olat.core.gui.control.DefaultController#event(org.olat.core.gui.UserRequest, org.olat.core.gui.control.Controller, org.olat.core.gui.control.Event)
*/
@Override
protected void event(UserRequest ureq, Controller source, Event event) {
super.event(ureq, source, event);
if (event instanceof EPStructureChangeEvent && event.getCommand().equals(EPStructureChangeEvent.ADDED)) {
EPStructureChangeEvent changeEvent = (EPStructureChangeEvent) event;
PortfolioStructure structure = changeEvent.getPortfolioStructure();
// don't do reloadMapAndRefreshUI(ureq) here; no db-commit yet! no refresh -> stale object!
if (structure instanceof EPPage) {
// jump to the edit mode for new pages
initOrUpdateEditMode(ureq, structure);
}
} else if (event instanceof EPStructureEvent && event.getCommand().equals(EPStructureEvent.CHANGE)) {
// reload map
reloadMapAndRefreshUI(ureq);
} else if (source == editCtrl && event.equals(Event.CHANGED_EVENT)) {
// refresh view on changes in TOC or style
reloadMapAndRefreshUI(ureq);
PortfolioStructure selectedPage = editCtrl.getSelectedStructure();
initOrUpdateEditMode(ureq, selectedPage);
} else if (source == confirmationSubmissionCtr) {
if (DialogBoxUIFactory.isYesEvent(event)) {
doSubmitAssess(ureq);
}
}
// fire to multiple maps controller, so it can refresh itself!
fireEvent(ureq, event);
}
Aggregations