use of org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableColumnModel in project OpenOLAT by OpenOLAT.
the class BinderListController method initForm.
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
FlexiTableColumnModel columnsModel = FlexiTableDataModelFactory.createFlexiTableColumnModel();
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(false, PortfolioCols.key, "select"));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(PortfolioCols.title, "select"));
model = new BindersDataModel(columnsModel);
tableEl = uifactory.addTableElement(getWindowControl(), "table", model, 20, false, getTranslator(), formLayout);
tableEl.setAvailableRendererTypes(FlexiTableRendererType.custom);
tableEl.setRendererType(FlexiTableRendererType.custom);
tableEl.setSearchEnabled(false);
tableEl.setCustomizeColumns(false);
tableEl.setElementCssClass("o_portfolio_listing");
tableEl.setEmtpyTableMessageKey("table.sEmptyTable");
tableEl.setNumOfRowsEnabled(false);
tableEl.setPageSize(24);
VelocityContainer row = createVelocityContainer("binder_row");
// sets its own DOM id in velocity container
row.setDomReplacementWrapperRequired(false);
tableEl.setRowRenderer(row, this);
tableEl.setCssDelegate(new BinderCssDelegate());
tableEl.setAndLoadPersistedPreferences(ureq, getTableId());
mapperThumbnailUrl = registerCacheableMapper(ureq, "binder-list", new ImageMapper(model));
row.contextPut("mapperThumbnailUrl", mapperThumbnailUrl);
if (!portfolioModule.isLearnerCanCreateBinders() && !portfolioModule.isCanCreateBindersFromTemplate() && portfolioModule.isCanCreateBindersFromCourse()) {
newBinderFromCourseButton = uifactory.addFormLink("create.binder.from.course", "create.empty.binder.from.course", null, formLayout, Link.BUTTON);
row.put("createBinderFromCourse", newBinderFromCourseButton.getComponent());
} else if (portfolioModule.isLearnerCanCreateBinders() || portfolioModule.isCanCreateBindersFromTemplate() || portfolioModule.isCanCreateBindersFromCourse()) {
newBinderDropdown = uifactory.addFormLink("create.binders", "create.new.binder", null, formLayout, Link.BUTTON);
int count = (portfolioModule.isLearnerCanCreateBinders() ? 1 : 0) + (portfolioModule.isCanCreateBindersFromTemplate() ? 1 : 0) + (portfolioModule.isCanCreateBindersFromCourse() ? 1 : 0);
if (count > 1) {
newBinderDropdown.setIconRightCSS("o_icon o_icon_caret");
}
row.put("createDropdown", newBinderDropdown.getComponent());
}
}
use of org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableColumnModel in project OpenOLAT by OpenOLAT.
the class HighScoreRunController method initForm.
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
VelocityContainer mainVC = this.flc.getFormItemComponent();
mainVC.put("loadd3js", new StatisticsComponent("d3loader"));
if (viewHistogram) {
VelocityContainer scoreHistogramVC = createVelocityContainer("histogram_score");
// transfer all scores to velocity container as base data for histogram
HighScoreRankingResults modifiedData = highScoreManager.processHistogramData(allScores, lowerBorder, upperBorder);
allScores = modifiedData.getModifiedScores();
scoreHistogramVC.contextPut("datas", BarSeries.datasToString(allScores));
// histogram marker for own position
scoreHistogramVC.contextPut("cutValue", ownIdIndices.size() > 0 ? highScoreManager.calculateHistogramCutvalue(allMembers.get(ownIdIndices.get(0)).getScore(), modifiedData.getClasswidth(), modifiedData.getMin()) : -1000);
// classwidth to correctly display the histogram
long classwidth = modifiedData.getClasswidth();
scoreHistogramVC.contextPut("step", classwidth);
// find path for ownID image to display in histogram
UserAvatarMapper mapper = new UserAvatarMapper(false);
String mapperPath = registerMapper(ureq, mapper);
String identityMapperPath = mapper.createPathFor(mapperPath, ownIdentity);
scoreHistogramVC.contextPut("mapperUrl", identityMapperPath);
mainVC.put("scoreHistogram", scoreHistogramVC);
}
if (viewPodium) {
String[] localizer = { "first", "second", "third" };
// for clarity and space reasons do not show any portraits if one position has more than 6 persons
int maxPerson = 6;
boolean showPortraits = !anonymous && allPodium.get(0).size() <= maxPerson && allPodium.get(1).size() <= maxPerson && allPodium.get(2).size() <= maxPerson;
for (int i = 0; i < localizer.length; i++) {
int sizePerPos = allPodium.get(i).size();
StringBuilder sb = new StringBuilder();
if (sizePerPos > 2) {
int reduce = 0;
// create link if podium has more than 2 entries per rank, entries can be displayed as anonymous
if (allPodium.get(i).get(0).getIdentity().equals(ownIdentity)) {
sb.append(userManager.getUserDisplayName(ownIdentity));
++reduce;
}
if (sizePerPos > 6 || anonymous) {
mainVC.contextPut("further" + (i + 1), (sizePerPos - reduce) + " " + (reduce == 1 ? translate("highscore.further") : translate("highscore.total")));
} else {
links[i] = LinkFactory.createLink(null, "link" + (i + 1), "cmd", (sizePerPos - reduce) + " " + (reduce == 1 ? translate("highscore.further") : translate("highscore.total")), getTranslator(), mainVC, this, 16);
}
} else {
for (HighScoreTableEntry te : allPodium.get(i)) {
if (!anonymous || te.getIdentity().equals(ownIdentity)) {
sb.append(userManager.getUserDisplayName(te.getIdentity()));
sb.append("<br/>");
}
}
}
mainVC.contextPut(localizer[i], sizePerPos > 0 ? sb.toString() : translate("highscore.unavail"));
mainVC.contextPut("score" + (i + 1), sizePerPos > 0 ? allPodium.get(i).get(0).getScore() : null);
if (sizePerPos > 0 && showPortraits) {
// decide whether or not to display id portrait
mainVC.contextPut("number" + (i + 1), sizePerPos);
for (int j = 0; j < sizePerPos; j++) {
Identity currentID = allPodium.get(i).get(j).getIdentity();
boolean choosePortrait = !anonymous || ownIdentity.equals(currentID);
DisplayPortraitController portrait = new DisplayPortraitController(ureq, getWindowControl(), currentID, false, choosePortrait, !choosePortrait);
listenTo(portrait);
Component portraitComponent = portrait.getInitialComponent();
mainVC.put("portrait" + (i + 1) + "-" + (j + 1), portraitComponent);
}
} else {
// if amount of people per rank is too large, own id portrait can still be displayed
for (int j = 0; j < sizePerPos; j++) {
Identity currentID = allPodium.get(i).get(j).getIdentity();
if (ownIdentity.equals(currentID)) {
DisplayPortraitController portrait = new DisplayPortraitController(ureq, getWindowControl(), currentID, true, true, false);
listenTo(portrait);
mainVC.put("portrait" + (i + 1), portrait.getInitialComponent());
}
}
}
}
}
if (viewTable) {
FlexiTableColumnModel tableColumnModel = FlexiTableDataModelFactory.createFlexiTableColumnModel();
tableColumnModel.addFlexiColumnModel(new DefaultFlexiColumnModel("highscore.table.header1", HighScoreTableEntry.RANK));
tableColumnModel.addFlexiColumnModel(new DefaultFlexiColumnModel("highscore.table.header2", HighScoreTableEntry.SCORE));
tableColumnModel.addFlexiColumnModel(new DefaultFlexiColumnModel("highscore.table.header3", HighScoreTableEntry.NAME));
// trim to tableSize
if (tableSize < allMembers.size()) {
allMembers.subList(tableSize, allMembers.size()).clear();
}
tableDataModel = new FlexiTableDataModelImpl<HighScoreTableEntry>(new HighScoreFlexiTableModel(allMembers, anonymous, translate("highscore.anonymous"), ownIdentity), tableColumnModel);
FlexiTableElement topTenTable = uifactory.addTableElement(getWindowControl(), "table", tableDataModel, getTranslator(), formLayout);
topTenTable.setNumOfRowsEnabled(false);
topTenTable.setCustomizeColumns(false);
topTenTable.setCssDelegate(new MarkedMemberCssDelegate(false));
// establish a 2nd table if ownID position is greater than first table's size setting
if (!ownIdMembers.isEmpty()) {
tableDataModel2 = new FlexiTableDataModelImpl<HighScoreTableEntry>(new HighScoreFlexiTableModel(ownIdMembers, anonymous, translate("highscore.anonymous"), ownIdentity), tableColumnModel);
FlexiTableElement tableElement = uifactory.addTableElement(getWindowControl(), "table2", tableDataModel2, getTranslator(), formLayout);
tableElement.setNumOfRowsEnabled(false);
tableElement.setCustomizeColumns(false);
tableElement.setCssDelegate(new MarkedMemberCssDelegate(true));
}
}
if (viewPosition && ownIdIndices.size() > 0) {
int amountWorse = allScores.length - ownIdIndices.get(0) - 1;
if (amountWorse > 0) {
mainVC.contextPut("relposition", translate("highscore.position.inrelation", new String[] { String.valueOf(amountWorse) }));
}
int ownRank = highscoreDataModel.getOwnTableEntry().getRank();
mainVC.contextPut("position", translate("highscore.position.yourposition", new String[] { String.valueOf(ownRank) }));
}
}
use of org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableColumnModel in project OpenOLAT by OpenOLAT.
the class DialogElementListEditController method initForm.
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
FlexiTableColumnModel columnsModel = FlexiTableDataModelFactory.createFlexiTableColumnModel();
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(DialogCols.filename));
// list of user properties
if (isAdministrativeUser) {
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(DialogCols.authorUsername));
}
int colIndex = USER_PROPS_OFFSET;
for (int i = 0; i < userPropertyHandlers.size(); i++) {
UserPropertyHandler userPropertyHandler = userPropertyHandlers.get(i);
boolean visible = UserManager.getInstance().isMandatoryUserProperty(usageIdentifyer, userPropertyHandler);
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(visible, userPropertyHandler.i18nColumnDescriptorLabelKey(), colIndex, null, true, "userProp-" + colIndex));
colIndex++;
}
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(DialogCols.date));
StaticFlexiCellRenderer deleteRenderer = new StaticFlexiCellRenderer(translate("delete"), "delete", null, "o_icon o_icon_delete_item");
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel("table.header.action", -1, "delete", deleteRenderer));
tableModel = new DialogElementsTableModel(columnsModel);
tableEl = uifactory.addTableElement(getWindowControl(), "table", tableModel, getTranslator(), formLayout);
tableEl.setAndLoadPersistedPreferences(ureq, "dialog.elements");
tableEl.setPageSize(25);
}
use of org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableColumnModel in project OpenOLAT by OpenOLAT.
the class AssessedIdentityListController method initForm.
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
if (formLayout instanceof FormLayoutContainer) {
FormLayoutContainer layoutCont = (FormLayoutContainer) formLayout;
layoutCont.contextPut("title", testEntry.getDisplayname());
RepositoryHandler handler = repositoryHandlerFactory.getRepositoryHandler(testEntry);
layoutCont.contextPut("cssClass", RepositoyUIFactory.getIconCssClass(handler.getSupportedType()));
}
// add the table
FlexiTableColumnModel columnsModel = FlexiTableDataModelFactory.createFlexiTableColumnModel();
if (isAdministrativeUser) {
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(IdentityCourseElementCols.username, "select"));
}
int colIndex = AssessmentToolConstants.USER_PROPS_OFFSET;
for (int i = 0; i < userPropertyHandlers.size(); i++) {
UserPropertyHandler userPropertyHandler = userPropertyHandlers.get(i);
boolean visible = UserManager.getInstance().isMandatoryUserProperty(AssessmentToolConstants.usageIdentifyer, userPropertyHandler);
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(visible, userPropertyHandler.i18nColumnDescriptorLabelKey(), colIndex, "select", true, "userProp-" + colIndex));
colIndex++;
}
if (element.hasAttemptsConfigured()) {
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(IdentityCourseElementCols.attempts, "select"));
}
if (element.hasScoreConfigured()) {
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(IdentityCourseElementCols.min, "select", new ScoreCellRenderer()));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(IdentityCourseElementCols.max, "select", new ScoreCellRenderer()));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(IdentityCourseElementCols.score, "select", new ScoreCellRenderer()));
}
if (element.hasPassedConfigured()) {
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(IdentityCourseElementCols.passed, new PassedCellRenderer()));
}
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(IdentityCourseElementCols.assessmentStatus, new AssessmentStatusCellRenderer(getLocale())));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(IdentityCourseElementCols.initialLaunchDate, "select"));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(false, IdentityCourseElementCols.lastModified, "select"));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(IdentityCourseElementCols.lastUserModified, "select"));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(false, IdentityCourseElementCols.lastCoachModified, "select"));
usersTableModel = new AssessedIdentityListTableModel(columnsModel, element);
usersTableModel.setCertificateMap(new ConcurrentHashMap<>());
tableEl = uifactory.addTableElement(getWindowControl(), "table", usersTableModel, 20, false, getTranslator(), formLayout);
tableEl.setExportEnabled(true);
tableEl.setSearchEnabled(new AssessedIdentityListProvider(getIdentity(), testEntry, testEntry, null, assessmentCallback), ureq.getUserSession());
List<FlexiTableFilter> filters = new ArrayList<>();
filters.add(new FlexiTableFilter(translate("filter.passed"), "passed"));
filters.add(new FlexiTableFilter(translate("filter.failed"), "failed"));
filters.add(new FlexiTableFilter(translate("filter.inProgress"), "inProgress"));
filters.add(new FlexiTableFilter(translate("filter.inReview"), "inReview"));
filters.add(new FlexiTableFilter(translate("filter.done"), "done"));
tableEl.setFilters("", filters, false);
if (assessmentCallback.canAssessBusinessGoupMembers()) {
List<BusinessGroup> coachedGroups;
if (assessmentCallback.isAdmin()) {
SearchBusinessGroupParams params = new SearchBusinessGroupParams();
coachedGroups = businessGroupService.findBusinessGroups(params, testEntry, 0, -1);
} else {
coachedGroups = assessmentCallback.getCoachedGroups();
}
if (coachedGroups.size() > 0) {
List<FlexiTableFilter> groupFilters = new ArrayList<>();
for (BusinessGroup coachedGroup : coachedGroups) {
String groupName = StringHelper.escapeHtml(coachedGroup.getName());
groupFilters.add(new FlexiTableFilter(groupName, coachedGroup.getKey().toString(), "o_icon o_icon_group"));
}
tableEl.setExtendedFilterButton(translate("filter.groups"), groupFilters);
}
}
}
use of org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableColumnModel in project OpenOLAT by OpenOLAT.
the class StudentCoursesController method initForm.
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
if (formLayout instanceof FormLayoutContainer) {
FormLayoutContainer layoutCont = (FormLayoutContainer) formLayout;
String fullName = userManager.getUserDisplayName(student);
layoutCont.contextPut("studentName", StringHelper.escapeHtml(fullName));
}
// add the table
FlexiTableColumnModel columnsModel = FlexiTableDataModelFactory.createFlexiTableColumnModel();
if (isAdministrativeUser) {
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(false, Columns.name, "select"));
}
int colIndex = UserListController.USER_PROPS_OFFSET;
for (int i = 0; i < userPropertyHandlers.size(); i++) {
UserPropertyHandler userPropertyHandler = userPropertyHandlers.get(i);
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(false, userPropertyHandler.i18nColumnDescriptorLabelKey(), colIndex++, "select", true, userPropertyHandler.i18nColumnDescriptorLabelKey()));
}
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(Columns.repoName, "select"));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(Columns.passed, new PassedCellRenderer()));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(Columns.score, new ScoreCellRenderer()));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(Columns.certificate, new DownloadCertificateCellRenderer(getLocale())));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(Columns.recertification, new DateFlexiCellRenderer(getLocale())));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(Columns.progress, new ProgressRenderer(true, getTranslator())));
if (lectureModule.isEnabled()) {
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(Columns.plannedLectures));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(Columns.attendedLectures));
if (lectureModule.isAuthorizedAbsenceEnabled()) {
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(Columns.unauthorizedAbsenceLectures));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(Columns.authorizedAbsenceLectures));
} else {
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(Columns.absentLectures));
}
}
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(false, Columns.lastModification));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(Columns.lastUserModified));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(false, Columns.lastCoachModified));
model = new EfficiencyStatementEntryTableDataModel(columnsModel);
tableEl = uifactory.addTableElement(getWindowControl(), "table", model, 20, false, getTranslator(), formLayout);
tableEl.setExportEnabled(true);
tableEl.setEmtpyTableMessageKey("error.no.found");
tableEl.setAndLoadPersistedPreferences(ureq, "fStudentCourseListController");
}
Aggregations