use of org.olat.portfolio.model.artefacts.AbstractArtefact in project OpenOLAT by OpenOLAT.
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());
}
}
}
use of org.olat.portfolio.model.artefacts.AbstractArtefact in project OpenOLAT by OpenOLAT.
the class EPTOCController method doDrop.
private void doDrop(UserRequest ureq, String droppedNodeId, String targetNodeId, boolean asChild) {
TreeNode droppedNode = treeCtr.getTreeModel().getNodeById(droppedNodeId);
TreeNode targetNode = treeCtr.getTreeModel().getNodeById(targetNodeId);
if (droppedNode == null || targetNode == null)
return;
Object droppedObj = droppedNode.getUserObject();
Object droppedParentObj = null;
if (droppedNode.getParent() != null) {
droppedParentObj = ((TreeNode) droppedNode.getParent()).getUserObject();
}
Object targetObj = targetNode.getUserObject();
Object targetParentObj = null;
if (targetNode.getParent() != null) {
targetParentObj = ((TreeNode) targetNode.getParent()).getUserObject();
}
if (droppedObj instanceof AbstractArtefact) {
AbstractArtefact artefact = (AbstractArtefact) droppedObj;
if (checkArtefactTarget(artefact, targetObj)) {
moveArtefactToNewParent(ureq, artefact, droppedParentObj, targetObj);
} else if (targetParentObj != null && targetParentObj.equals(droppedParentObj)) {
reorder(ureq, artefact, (TreeNode) targetNode.getParent(), targetObj);
}
} else if (droppedObj instanceof PortfolioStructure) {
PortfolioStructure droppedStruct = (PortfolioStructure) droppedObj;
if (checkStructureTarget(droppedStruct, droppedParentObj, targetObj, targetParentObj, asChild)) {
if (asChild) {
int newPos = TreeHelper.indexOfByUserObject(targetObj, (TreeNode) targetNode.getParent());
moveStructureToNewParent(ureq, droppedStruct, droppedParentObj, targetObj, newPos);
} else if (droppedParentObj != null && targetParentObj != null && droppedParentObj.equals(targetParentObj)) {
int newPos = TreeHelper.indexOfByUserObject(targetObj, (TreeNode) targetNode.getParent());
moveStructureToNewParent(ureq, droppedStruct, droppedParentObj, targetParentObj, newPos);
} else {
int newPos = TreeHelper.indexOfByUserObject(targetObj, (TreeNode) targetNode.getParent());
moveStructureToNewParent(ureq, droppedStruct, droppedParentObj, targetParentObj, newPos);
}
}
}
}
use of org.olat.portfolio.model.artefacts.AbstractArtefact in project OpenOLAT by OpenOLAT.
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>");
}
}
use of org.olat.portfolio.model.artefacts.AbstractArtefact in project OpenOLAT by OpenOLAT.
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 OpenOLAT.
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);
}
}
Aggregations