use of org.olat.portfolio.model.artefacts.AbstractArtefact in project OpenOLAT by OpenOLAT.
the class EPMultipleArtefactPreviewController method activate.
@Override
public void activate(UserRequest ureq, List<ContextEntry> entries, StateEntry state) {
if (entries == null || entries.isEmpty())
return;
OLATResourceable ores = entries.get(0).getOLATResourceable();
if ("AbstractArtefact".equals(ores.getResourceableTypeName())) {
Long resId = ores.getResourceableId();
int index = 0;
for (AbstractArtefact artefact : artefactsFullList) {
if (artefact.getKey().equals(resId) || artefact.getResourceableId().equals(resId)) {
int rest = (index % artefactsPerPage);
int page = (index - rest) / artefactsPerPage;
preparePaging(ureq, page + 1);
break;
}
index++;
}
}
}
use of org.olat.portfolio.model.artefacts.AbstractArtefact in project OpenOLAT by OpenOLAT.
the class EPMultipleArtefactsAsTableController method activate.
@Override
public void activate(UserRequest ureq, List<ContextEntry> entries, StateEntry state) {
if (entries == null || entries.isEmpty())
return;
OLATResourceable ores = entries.get(0).getOLATResourceable();
if ("AbstractArtefact".equals(ores.getResourceableTypeName())) {
Long resId = ores.getResourceableId();
ArtefactTableDataModel model = (ArtefactTableDataModel) artefactListTblCtrl.getTableDataModel();
for (int i = 0; i < model.getRowCount(); i++) {
AbstractArtefact artefact = model.getObject(i);
if (artefact.getKey().equals(resId)) {
int artefactsPerPage = artefactListTblCtrl.getPageSize();
int rest = (i % artefactsPerPage);
int page = (i - rest) / artefactsPerPage;
artefactListTblCtrl.setPage(new Integer(page + 1));
break;
}
}
}
}
use of org.olat.portfolio.model.artefacts.AbstractArtefact in project OpenOLAT by OpenOLAT.
the class EPTagBrowseController method getRealArtefactTags.
// filter available tags for such of non-existing artefacts
private List<String> getRealArtefactTags() {
allUsersArtefacts = ePFMgr.getArtefactPoolForUser(getIdentity());
if (allUsersArtefacts == null)
return new ArrayList<String>();
HashSet<String> realTags = new HashSet<String>();
for (AbstractArtefact abstractArtefact : allUsersArtefacts) {
List<String> thisTags = ePFMgr.getArtefactTags(abstractArtefact);
realTags.addAll(thisTags);
}
List<String> res = new ArrayList<String>();
res.addAll(realTags);
return res;
}
use of org.olat.portfolio.model.artefacts.AbstractArtefact in project OpenOLAT by OpenOLAT.
the class EPTagBrowseController method recalculateTagCloud.
private List<AbstractArtefact> recalculateTagCloud() {
List<String> selectedTags = getSelectedTags();
if (selectedTags.isEmpty()) {
for (Link tagLink : tagLinks) {
TagWrapper tagWrapper = (TagWrapper) tagLink.getUserObject();
tagLink.setCustomEnabledLinkCSS(inactiveCSS);
tagLink.setEnabled(true);
tagWrapper.setState(TagState.possible);
}
return allUsersArtefacts;
}
EPArtefactTagCloud artefactsAndTags = ePFMgr.getArtefactsAndTagCloud(getIdentity(), selectedTags);
List<AbstractArtefact> filteredArtefacts = artefactsAndTags.getArtefacts();
Set<String> newTags = artefactsAndTags.getTags();
if (newTags != null && !newTags.isEmpty()) {
for (Link tagLink : tagLinks) {
TagWrapper tagWrapper = (TagWrapper) tagLink.getUserObject();
String tag = tagWrapper.getTag();
switch(tagWrapper.getState()) {
case selected:
tagLink.setCustomEnabledLinkCSS(activeCSS);
tagLink.setEnabled(true);
break;
case possible:
if (!newTags.contains(tag)) {
tagWrapper.setState(TagState.unpossible);
tagLink.setEnabled(false);
} else {
tagLink.setCustomEnabledLinkCSS(inactiveCSS);
tagLink.setEnabled(true);
}
break;
case unpossible:
if (newTags.contains(tag)) {
tagWrapper.setState(TagState.possible);
tagLink.setCustomEnabledLinkCSS(inactiveCSS);
tagLink.setEnabled(true);
} else {
tagLink.setEnabled(false);
}
break;
}
}
}
return filteredArtefacts;
}
use of org.olat.portfolio.model.artefacts.AbstractArtefact in project OpenOLAT by OpenOLAT.
the class EPMultipleArtefactSmallReadOnlyPreviewController method init.
private void init(UserRequest ureq) {
if (artefactCtrls != null)
disposeArtefactControllers();
if (optionLinkCtrls != null)
disposeOptionLinkControllers();
optionLinkCtrls = new ArrayList<Controller>();
artefactCtrls = new ArrayList<Controller>();
List<List<Panel>> artefactCtrlCompLines = new ArrayList<List<Panel>>();
List<Panel> artefactCtrlCompLine = new ArrayList<Panel>();
int i = 1;
for (AbstractArtefact artefact : artefacts) {
EPArtefactHandler<?> artHandler = portfolioModule.getArtefactHandler(artefact.getResourceableTypeName());
Controller artCtrl;
// check for special art-display:
boolean special = artHandler.isProvidingSpecialMapViewController();
if (special) {
artCtrl = artHandler.getSpecialMapViewController(ureq, getWindowControl(), artefact);
if (artCtrl != null) {
// add the optionsLink to the artefact
EPArtefactViewOptionsLinkController optionsLinkCtrl = new EPArtefactViewOptionsLinkController(ureq, getWindowControl(), artefact, secCallback, struct);
vC.put("optionsLink" + i, optionsLinkCtrl.getInitialComponent());
listenTo(optionsLinkCtrl);
optionLinkCtrls.add(optionsLinkCtrl);
}
} else {
artCtrl = new EPArtefactViewReadOnlyController(ureq, getWindowControl(), artefact, struct, secCallback, true);
}
if (artCtrl != null) {
artefactCtrls.add(artCtrl);
Component artefactCtrlComponent = artCtrl.getInitialComponent();
listenTo(artCtrl);
Panel namedPanel = new Panel("artCtrl" + i);
namedPanel.setContent(artefactCtrlComponent);
if (special) {
if (!artefactCtrlCompLine.isEmpty()) {
artefactCtrlCompLines.add(artefactCtrlCompLine);
}
artefactCtrlCompLines.add(Collections.singletonList(namedPanel));
artefactCtrlCompLine = new ArrayList<Panel>();
} else {
if (artefactCtrlCompLine.size() == 3) {
if (!artefactCtrlCompLine.isEmpty()) {
artefactCtrlCompLines.add(artefactCtrlCompLine);
}
artefactCtrlCompLine = new ArrayList<Panel>();
}
artefactCtrlCompLine.add(namedPanel);
}
vC.put("artCtrl" + i, namedPanel);
if (special) {
// need a flag in a lopp for the velociy template
vC.put("specialartCtrl" + i, artefactCtrlComponent);
}
i++;
}
}
if (!artefactCtrlCompLine.isEmpty()) {
artefactCtrlCompLines.add(artefactCtrlCompLine);
}
vC.contextPut("artefactCtrlCompLines", artefactCtrlCompLines);
}
Aggregations