use of org.olat.modules.portfolio.ui.model.PortfolioElementRow in project openolat by klemens.
the class PageListDataModel method sort.
@Override
public void sort(SortKey orderBy) {
PageListSortableDataModelDelegate sorter = new PageListSortableDataModelDelegate(orderBy, this, locale);
List<PortfolioElementRow> rows;
try {
rows = sorter.sort();
} catch (IllegalArgumentException e) {
log.error("Cannot sort with: " + orderBy, e);
return;
}
// This say where is the link to create a new entry
// if a section has assignments, it's at the end of
// the section. If there isn't any assignment, it
// under the section.
boolean lastNewEntry = false;
PortfolioElementRow previousRow = null;
for (PortfolioElementRow row : rows) {
if (row.isSection()) {
if (lastNewEntry && previousRow != null) {
previousRow.setNewEntry(true);
}
if (row.isAssignments()) {
lastNewEntry = true;
} else {
lastNewEntry = false;
row.setNewEntry(true);
}
} else {
row.setNewEntry(false);
}
previousRow = row;
}
if (lastNewEntry && previousRow != null) {
previousRow.setNewEntry(true);
}
super.setObjects(rows);
}
use of org.olat.modules.portfolio.ui.model.PortfolioElementRow in project openolat by klemens.
the class PageListDataModel method filter.
public List<Section> filter(Section section) {
if (section == null) {
super.setObjects(backup);
return null;
} else if (backup == null) {
return new ArrayList<>();
}
Set<Section> sectionSet = new HashSet<>();
List<Section> sectionList = new ArrayList<>();
List<PortfolioElementRow> sectionRows = new ArrayList<>();
for (PortfolioElementRow row : backup) {
if (row.getSection() != null) {
if (!sectionSet.contains(row.getSection())) {
sectionSet.add(row.getSection());
sectionList.add(row.getSection());
}
if (section.equals(row.getSection())) {
sectionRows.add(row);
}
}
}
super.setObjects(sectionRows);
return sectionList;
}
use of org.olat.modules.portfolio.ui.model.PortfolioElementRow in project openolat by klemens.
the class SharedPageStatusCellRenderer method render.
@Override
public void render(Renderer renderer, StringOutput target, Object cellValue, int row, FlexiTableComponent source, URLBuilder ubu, Translator trans) {
if (cellValue instanceof SharedPageRow) {
SharedPageRow pageRow = (SharedPageRow) cellValue;
PageStatus status = pageRow.getStatus();
PageUserStatus userStatus = pageRow.getUserStatus();
render(target, status, userStatus);
} else if (cellValue instanceof PortfolioElementRow) {
PortfolioElementRow elementRow = (PortfolioElementRow) cellValue;
if (elementRow.getPage() != null) {
PageStatus status = elementRow.getPageStatus();
PageUserStatus userStatus = elementRow.getUserInfosStatus();
render(target, status, userStatus);
}
}
}
use of org.olat.modules.portfolio.ui.model.PortfolioElementRow in project OpenOLAT by OpenOLAT.
the class AbstractPageListController method forgeSectionRow.
protected PortfolioElementRow forgeSectionRow(Section section, AssessmentSection assessmentSection, List<Assignment> assignments, Map<OLATResourceable, List<Category>> categorizedElementMap) {
PortfolioElementRow row = new PortfolioElementRow(section, assessmentSection, config.isAssessable(), (assignments != null && assignments.size() > 0));
String openLinkId = "open_" + (++counter);
FormLink openLink = uifactory.addFormLink(openLinkId, "open.full", "open.full.page", null, flc, Link.BUTTON_SMALL);
openLink.setIconRightCSS("o_icon o_icon_start");
openLink.setPrimary(true);
row.setOpenFormLink(openLink);
openLink.setUserObject(row);
addCategoriesToRow(row, categorizedElementMap);
if (assignments != null && secCallback.canViewPendingAssignments(section) && secCallback.canInstantiateAssignment()) {
List<Assignment> startableAssignments = assignments.stream().filter(ass -> ass.getAssignmentStatus() == AssignmentStatus.notStarted).filter(ass -> ass.getPage() == null).collect(Collectors.toList());
if (!startableAssignments.isEmpty()) {
String[] keys = new String[startableAssignments.size() + 1];
String[] values = new String[startableAssignments.size() + 1];
keys[0] = "start.assignment.hint";
values[0] = translate("start.assignment.hint");
int count = 1;
for (Assignment assignment : startableAssignments) {
keys[count] = Long.toString(assignment.getKey());
values[count] = assignment.getTitle();
count++;
}
SingleSelection startEl = uifactory.addDropdownSingleselect("assignments_" + (++counter), "", flc, keys, values, null);
startEl.setDomReplacementWrapperRequired(false);
startEl.addActionListener(FormEvent.ONCHANGE);
row.setStartSelection(startEl);
}
}
return row;
}
use of org.olat.modules.portfolio.ui.model.PortfolioElementRow in project OpenOLAT by OpenOLAT.
the class AbstractPageListController method getSelectedRows.
protected List<PortfolioElementRow> getSelectedRows() {
Set<Integer> indexes = tableEl.getMultiSelectedIndex();
List<PortfolioElementRow> selectedRows = new ArrayList<>(indexes.size());
for (Integer index : indexes) {
PortfolioElementRow row = model.getObject(index.intValue());
selectedRows.add(row);
}
return selectedRows;
}
Aggregations