use of org.olat.portfolio.model.structel.EPAbstractMap in project openolat by klemens.
the class EPTOCController method refreshAddElements.
/**
* refreshing the add elements link to actual structure
* @param ureq
* @param struct maybe null -> hiding the add-button
*/
private void refreshAddElements(UserRequest ureq, PortfolioStructure struct) {
tocV.remove(tocV.getComponent("addElement"));
removeAsListenerAndDispose(addElCtrl);
if (struct != null) {
addElCtrl = new EPAddElementsController(ureq, getWindowControl(), struct);
if (struct instanceof EPPage) {
if (secCallback.canAddStructure()) {
addElCtrl.setShowLink(EPAddElementsController.ADD_STRUCTUREELEMENT);
}
if (secCallback.canAddArtefact()) {
addElCtrl.setShowLink(EPAddElementsController.ADD_ARTEFACT);
}
} else if (struct instanceof EPAbstractMap) {
if (secCallback.canAddPage()) {
addElCtrl.setShowLink(EPAddElementsController.ADD_PAGE);
}
} else {
// its a structure element
if (secCallback.canAddArtefact()) {
addElCtrl.setShowLink(EPAddElementsController.ADD_ARTEFACT);
}
}
listenTo(addElCtrl);
tocV.put("addElement", addElCtrl.getInitialComponent());
}
}
use of org.olat.portfolio.model.structel.EPAbstractMap in project openolat by klemens.
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.structel.EPAbstractMap in project openolat by klemens.
the class EPCollectStepForm04 method formOK.
/**
* @see org.olat.core.gui.control.generic.wizard.StepFormBasicController#formOK(org.olat.core.gui.UserRequest)
*/
@Override
protected void formOK(UserRequest ureq) {
PortfolioStructure selectedPortfolioStructure = preSelectedStructure;
TreeNode node = mapsTreeController == null ? null : mapsTreeController.getSelectedNode();
if (node != null) {
Object obj = node.getUserObject();
if (obj == null) {
selectedPortfolioStructure = null;
} else if (obj instanceof PortfolioStructure && !(obj instanceof EPAbstractMap)) {
selectedPortfolioStructure = (PortfolioStructure) obj;
}
}
if (selectedPortfolioStructure != null) {
ePFMgr.setUsersLastUsedPortfolioStructure(getIdentity(), selectedPortfolioStructure);
}
if (isUsedInStepWizzard()) {
addToRunContext("selectedStructure", selectedPortfolioStructure);
fireEvent(ureq, StepsEvent.ACTIVATE_NEXT);
} else {
if (selectedPortfolioStructure != null && !selectedPortfolioStructure.getKey().equals(oldStructure.getKey())) {
ePFMgr.moveArtefactFromStructToStruct(artefact, oldStructure, selectedPortfolioStructure);
// refresh ui
fireEvent(ureq, new EPStructureChangeEvent(EPStructureChangeEvent.CHANGED, selectedPortfolioStructure));
}
}
}
Aggregations