diff --git a/src/main/java/org/olat/course/certificate/ui/CertificateAndEfficiencyStatementListController.java b/src/main/java/org/olat/course/certificate/ui/CertificateAndEfficiencyStatementListController.java index 99a377a4b56cb533aac4bbe9a73df2eaee6ec964..eecd41c05c89c6afd4aec64410e759ed83413924 100644 --- a/src/main/java/org/olat/course/certificate/ui/CertificateAndEfficiencyStatementListController.java +++ b/src/main/java/org/olat/course/certificate/ui/CertificateAndEfficiencyStatementListController.java @@ -172,15 +172,18 @@ public class CertificateAndEfficiencyStatementListController extends FormBasicCo } FlexiTableColumnModel tableColumnModel = FlexiTableDataModelFactory.createFlexiTableColumnModel(); - tableColumnModel.addFlexiColumnModel(new DefaultFlexiColumnModel(Cols.displayName.i18n(), Cols.displayName.ordinal())); - tableColumnModel.addFlexiColumnModel(new DefaultFlexiColumnModel(Cols.score.i18n(), Cols.score.ordinal())); + tableColumnModel.addFlexiColumnModel(new DefaultFlexiColumnModel(Cols.displayName.i18n(), Cols.displayName.ordinal(), + true, Cols.displayName.name())); + tableColumnModel.addFlexiColumnModel(new DefaultFlexiColumnModel(Cols.score.i18n(), Cols.score.ordinal(), + true, Cols.score.name())); tableColumnModel.addFlexiColumnModel(new DefaultFlexiColumnModel(Cols.passed.i18n(), Cols.passed.ordinal(), - new PassedCellRenderer())); + true, Cols.passed.name(), new PassedCellRenderer())); tableColumnModel.addFlexiColumnModel(new StaticFlexiColumnModel("table.header.show", translate("table.header.show"), CMD_SHOW)); - tableColumnModel.addFlexiColumnModel(new DefaultFlexiColumnModel(Cols.lastModified.i18n(), Cols.lastModified.ordinal())); + tableColumnModel.addFlexiColumnModel(new DefaultFlexiColumnModel(Cols.lastModified.i18n(), Cols.lastModified.ordinal(), + true, Cols.lastModified.name())); tableColumnModel.addFlexiColumnModel(new DefaultFlexiColumnModel(Cols.certificate.i18n(), Cols.certificate.ordinal(), - new DownloadCertificateCellRenderer(assessedIdentity))); + true, Cols.certificate.name(), new DownloadCertificateCellRenderer(assessedIdentity))); tableColumnModel.addFlexiColumnModel(new StaticFlexiColumnModel("table.header.launchcourse", translate("table.header.launchcourse"), CMD_LAUNCH_COURSE)); tableColumnModel.addFlexiColumnModel(new StaticFlexiColumnModel("table.header.delete", @@ -194,7 +197,7 @@ public class CertificateAndEfficiencyStatementListController extends FormBasicCo new StaticFlexiCellRenderer(CMD_ARTEFACT, new AsArtefactCellRenderer()))); } - tableModel = new CertificateAndEfficiencyStatementListModel(tableColumnModel); + tableModel = new CertificateAndEfficiencyStatementListModel(tableColumnModel, getLocale()); loadModel(); tableEl = uifactory.addTableElement(getWindowControl(), "certificates", tableModel, getTranslator(), formLayout); tableEl.setElementCssClass("o_sel_certificates_table"); diff --git a/src/main/java/org/olat/course/certificate/ui/CertificateAndEfficiencyStatementListModel.java b/src/main/java/org/olat/course/certificate/ui/CertificateAndEfficiencyStatementListModel.java index 6bd0fc6b3d2a99fa18d8169a7d9c2d828adcfa59..2c9ce688edfe28650a94d559e81008f59059c31f 100644 --- a/src/main/java/org/olat/course/certificate/ui/CertificateAndEfficiencyStatementListModel.java +++ b/src/main/java/org/olat/course/certificate/ui/CertificateAndEfficiencyStatementListModel.java @@ -20,9 +20,13 @@ package org.olat.course.certificate.ui; import java.util.Date; +import java.util.List; +import java.util.Locale; +import org.olat.core.commons.persistence.SortKey; import org.olat.core.gui.components.form.flexible.impl.elements.table.DefaultFlexiTableDataModel; import org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableColumnModel; +import org.olat.core.gui.components.form.flexible.impl.elements.table.SortableFlexiTableDataModel; import org.olat.course.assessment.AssessmentHelper; import org.olat.course.certificate.CertificateLight; import org.olat.course.certificate.ui.CertificateAndEfficiencyStatementListModel.CertificateAndEfficiencyStatement; @@ -33,20 +37,39 @@ import org.olat.course.certificate.ui.CertificateAndEfficiencyStatementListModel * @author srosse, stephane.rosse@frentix.com, http://www.frentix.com * */ -public class CertificateAndEfficiencyStatementListModel extends DefaultFlexiTableDataModel<CertificateAndEfficiencyStatement> { +public class CertificateAndEfficiencyStatementListModel extends DefaultFlexiTableDataModel<CertificateAndEfficiencyStatement> + implements SortableFlexiTableDataModel<CertificateAndEfficiencyStatement> { - public CertificateAndEfficiencyStatementListModel(FlexiTableColumnModel columnModel) { + private final Locale locale; + + public CertificateAndEfficiencyStatementListModel(FlexiTableColumnModel columnModel, Locale locale) { super(columnModel); + this.locale = locale; } @Override public DefaultFlexiTableDataModel<CertificateAndEfficiencyStatement> createCopyWithEmptyList() { - return new CertificateAndEfficiencyStatementListModel(getTableColumnModel()); + return new CertificateAndEfficiencyStatementListModel(getTableColumnModel(), locale); + } + + + + @Override + public void sort(SortKey orderBy) { + if(orderBy != null) { + List<CertificateAndEfficiencyStatement> views = new CertificateAndEfficiencyStatementListSort(orderBy, this, locale).sort(); + super.setObjects(views); + } } @Override public Object getValueAt(int row, int col) { CertificateAndEfficiencyStatement statement = getObject(row); + return getValueAt(statement, col); + } + + @Override + public Object getValueAt(CertificateAndEfficiencyStatement statement, int col) { switch(Cols.values()[col]) { case displayName: return statement.getDisplayName(); case score: @@ -60,7 +83,7 @@ public class CertificateAndEfficiencyStatementListModel extends DefaultFlexiTabl } return null; } - + public static enum Cols { displayName("table.header.course"), diff --git a/src/main/java/org/olat/course/certificate/ui/CertificateAndEfficiencyStatementListSort.java b/src/main/java/org/olat/course/certificate/ui/CertificateAndEfficiencyStatementListSort.java new file mode 100644 index 0000000000000000000000000000000000000000..002aee08ac8dd2f831f3261bd350f4f99686391f --- /dev/null +++ b/src/main/java/org/olat/course/certificate/ui/CertificateAndEfficiencyStatementListSort.java @@ -0,0 +1,55 @@ +/** + * <a href="http://www.openolat.org"> + * OpenOLAT - Online Learning and Training</a><br> + * <p> + * Licensed under the Apache License, Version 2.0 (the "License"); <br> + * you may not use this file except in compliance with the License.<br> + * You may obtain a copy of the License at the + * <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache homepage</a> + * <p> + * Unless required by applicable law or agreed to in writing,<br> + * software distributed under the License is distributed on an "AS IS" BASIS, <br> + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. <br> + * See the License for the specific language governing permissions and <br> + * limitations under the License. + * <p> + * Initial code contributed and copyrighted by<br> + * frentix GmbH, http://www.frentix.com + * <p> + */ +package org.olat.course.certificate.ui; + +import java.util.List; +import java.util.Locale; + +import org.olat.core.commons.persistence.SortKey; +import org.olat.core.gui.components.form.flexible.impl.elements.table.SortableFlexiTableDataModel; +import org.olat.core.gui.components.form.flexible.impl.elements.table.SortableFlexiTableModelDelegate; +import org.olat.course.certificate.ui.CertificateAndEfficiencyStatementListModel.CertificateAndEfficiencyStatement; +import org.olat.course.certificate.ui.CertificateAndEfficiencyStatementListModel.Cols; + + +/** + * + * Initial date: 30.03.2016<br> + * @author srosse, stephane.rosse@frentix.com, http://www.frentix.com + * + */ +public class CertificateAndEfficiencyStatementListSort extends SortableFlexiTableModelDelegate<CertificateAndEfficiencyStatement> { + + public CertificateAndEfficiencyStatementListSort(SortKey orderBy, + SortableFlexiTableDataModel<CertificateAndEfficiencyStatement> tableModel, Locale locale) { + super(orderBy, tableModel, locale); + } + + @Override + protected void sort(List<CertificateAndEfficiencyStatement> rows) { + int columnIndex = getColumnIndex(); + Cols column = Cols.values()[columnIndex]; + switch(column) { + default: { + super.sort(rows); + } + } + } +}