use of org.olat.portfolio.model.artefacts.AbstractArtefact in project openolat by klemens.
the class EPTOCController method doSelectTreeElement.
private void doSelectTreeElement(UserRequest ureq, TreeEvent te) {
TreeNode selectedNode = treeCtr.getTreeModel().getNodeById(te.getNodeId());
Object userObj = selectedNode.getUserObject();
if (userObj instanceof PortfolioStructure) {
// structure clicked
structureClicked = (PortfolioStructure) userObj;
refreshAddElements(ureq, structureClicked);
delButton.setVisible(true);
// send event to load this page
fireEvent(ureq, new EPStructureChangeEvent(EPStructureChangeEvent.SELECTED, structureClicked));
} else if (userObj instanceof AbstractArtefact) {
// artefact clicked
Object parentObj = ((TreeNode) selectedNode.getParent()).getUserObject();
if (parentObj instanceof PortfolioStructure) {
artefactClicked = (AbstractArtefact) userObj;
PortfolioStructure structure = (PortfolioStructure) parentObj;
refreshAddElements(ureq, null);
delButton.setVisible(true);
fireEvent(ureq, new EPArtefactClicked(ARTEFACT_NODE_CLICKED, structure));
}
} else {
// root tree node clicked, no add/delete link
delButton.setVisible(false);
refreshAddElements(ureq, null);
fireEvent(ureq, new Event(ARTEFACT_NODE_CLICKED));
}
}
use of org.olat.portfolio.model.artefacts.AbstractArtefact in project openolat by klemens.
the class EPTOCTreeModel method checkArtefactTarget.
private boolean checkArtefactTarget(Object droppedParentObj, AbstractArtefact artefact, Object targetObj, Object targetParentObj, boolean sibling) {
PortfolioStructure newParStruct;
if (targetObj instanceof EPAbstractMap) {
return false;
} else if (targetObj instanceof PortfolioStructure) {
newParStruct = (PortfolioStructure) targetObj;
} else if (sibling) {
if (targetObj instanceof AbstractArtefact && targetParentObj instanceof PortfolioStructure) {
if (droppedParentObj != null && droppedParentObj.equals(targetParentObj)) {
// reorder
return true;
} else {
newParStruct = (PortfolioStructure) targetParentObj;
}
} else {
return false;
}
} else {
return false;
}
boolean sameTarget = ePFMgr.isArtefactInStructure(artefact, newParStruct);
if (sameTarget) {
return false;
}
return true;
}
use of org.olat.portfolio.model.artefacts.AbstractArtefact in project openolat by klemens.
the class EPMultipleArtefactPreviewController method preparePaging.
private void preparePaging(UserRequest ureq, int actualPage) {
int nrOfArtefacts = artefactsFullList.size();
vC.contextPut("artefactAmnt", Integer.toString(nrOfArtefacts));
if (nrOfArtefacts > artefactsPerPage) {
int divRest = (nrOfArtefacts % artefactsPerPage);
int nrOfPages = (nrOfArtefacts / artefactsPerPage) + (divRest > 0 ? 1 : 0);
ArrayList<Link> pageLinkList = new ArrayList<Link>();
for (int i = 1; i < nrOfPages + 1; i++) {
Link pageLink = LinkFactory.createCustomLink("pageLink" + i, "pageLink" + i, String.valueOf(i), Link.LINK + Link.NONTRANSLATED, vC, this);
pageLink.setUserObject(i);
if (actualPage == i)
pageLink.setEnabled(false);
pageLinkList.add(pageLink);
}
int fromIndex = (actualPage - 1) * artefactsPerPage;
int toIndex = actualPage * artefactsPerPage;
if (toIndex > nrOfArtefacts)
toIndex = nrOfArtefacts;
List<AbstractArtefact> artefactsToShow = artefactsFullList.subList(fromIndex, toIndex);
vC.contextPut("pageLinkList", pageLinkList);
initOrUpdateArtefactControllers(ureq, artefactsToShow);
} else {
// no paging needed
vC.contextRemove("pageLinkList");
initOrUpdateArtefactControllers(ureq, artefactsFullList);
}
}
use of org.olat.portfolio.model.artefacts.AbstractArtefact in project openolat by klemens.
the class EPMultipleArtefactPreviewController method initOrUpdateArtefactControllers.
/**
* @param ureq
* @param wControl
* @param artefacts
*/
private void initOrUpdateArtefactControllers(UserRequest ureq, List<AbstractArtefact> artefacts) {
vC.contextPut("artefacts", artefacts);
if (artefactCtrls != null)
disposeArtefactControllers();
artefactCtrls = new ArrayList<Controller>();
ArrayList<Component> artefactCtrlComps = new ArrayList<Component>();
int i = 1;
getArtefactAttributeDisplayConfig(ureq.getIdentity());
if (artefacts != null) {
for (AbstractArtefact abstractArtefact : artefacts) {
Controller artCtrl = new EPArtefactViewController(ureq, getWindowControl(), abstractArtefact, artAttribConfig, artefactChooseMode, false, true);
artefactCtrls.add(artCtrl);
Component artefactCtrlComponent = artCtrl.getInitialComponent();
listenTo(artCtrl);
artefactCtrlComps.add(artefactCtrlComponent);
vC.put("artCtrl" + i, artefactCtrlComponent);
i++;
}
}
vC.contextPut("artefactCtrlComps", artefactCtrlComps);
}
use of org.olat.portfolio.model.artefacts.AbstractArtefact in project openolat by klemens.
the class ArtefactTypeImageCellRenderer method render.
/**
* @see org.olat.core.gui.components.table.CustomCellRenderer#render(org.olat.core.gui.render.StringOutput, org.olat.core.gui.render.Renderer, java.lang.Object, java.util.Locale, int, java.lang.String)
*/
@Override
public void render(StringOutput sb, Renderer renderer, Object val, Locale locale, int alignment, String action) {
if (val instanceof AbstractArtefact) {
AbstractArtefact artefact = (AbstractArtefact) val;
EPArtefactHandler<?> artHandler = portfolioModule.getArtefactHandler(artefact.getResourceableTypeName());
Translator handlerTrans = artHandler.getHandlerTranslator(translator);
String handlerClass = PortfolioFilterController.HANDLER_PREFIX + artHandler.getClass().getSimpleName() + PortfolioFilterController.HANDLER_TITLE_SUFFIX;
String artType = handlerTrans.translate(handlerClass);
String artIcon = artefact.getIcon();
sb.append("<i class='o_icon o_icon-lg ").append(artIcon).append("' title=\"").append(artType).append("\"> </i>");
}
}
Aggregations