Search in sources :

Example 11 with StaticColumnDescriptor

use of org.olat.core.gui.components.table.StaticColumnDescriptor in project OpenOLAT by OpenOLAT.

the class ScormResultDetailsController method init.

protected void init(UserRequest ureq) {
    main = createVelocityContainer("scores");
    TableGuiConfiguration summaryTableConfig = new TableGuiConfiguration();
    summaryTableConfig.setDownloadOffered(true);
    summaryTableCtr = new TableController(summaryTableConfig, ureq, getWindowControl(), getTranslator());
    summaryTableCtr.addColumnDescriptor(new DefaultColumnDescriptor("summary.column.header.date", 0, null, ureq.getLocale()));
    summaryTableCtr.addColumnDescriptor(new DefaultColumnDescriptor("summary.column.header.duration", 1, null, ureq.getLocale()));
    summaryTableCtr.addColumnDescriptor(new DefaultColumnDescriptor("summary.column.header.assesspoints", 2, null, ureq.getLocale()));
    summaryTableCtr.addColumnDescriptor(new StaticColumnDescriptor("sel", "summary.column.header.details", getTranslator().translate("select")));
    CourseEnvironment courseEnv = assessedUserCourseEnv.getCourseEnvironment();
    String username = assessedUserCourseEnv.getIdentityEnvironment().getIdentity().getName();
    // <OLATCE-289>
    Map<Date, List<CmiData>> rawDatas = ScormAssessmentManager.getInstance().visitScoDatasMultiResults(username, courseEnv, node);
    summaryTableCtr.setTableDataModel(new SummaryTableDataModelMultiResults(rawDatas));
    // </OLATCE-289>
    listenTo(summaryTableCtr);
    main.put("summary", summaryTableCtr.getInitialComponent());
    if (!coachCourseEnv.isCourseReadOnly()) {
        resetButton = LinkFactory.createButton("reset", main, this);
        main.put("resetButton", resetButton);
    }
    putInitialPanel(main);
}
Also used : CourseEnvironment(org.olat.course.run.environment.CourseEnvironment) UserCourseEnvironment(org.olat.course.run.userview.UserCourseEnvironment) TableController(org.olat.core.gui.components.table.TableController) StaticColumnDescriptor(org.olat.core.gui.components.table.StaticColumnDescriptor) List(java.util.List) TableGuiConfiguration(org.olat.core.gui.components.table.TableGuiConfiguration) DefaultColumnDescriptor(org.olat.core.gui.components.table.DefaultColumnDescriptor) Date(java.util.Date)

Example 12 with StaticColumnDescriptor

use of org.olat.core.gui.components.table.StaticColumnDescriptor in project OpenOLAT by OpenOLAT.

the class EPMultipleArtefactsAsTableController method initOrUpdateTable.

private void initOrUpdateTable(UserRequest ureq, List<AbstractArtefact> artefacts) {
    ArtefactTableDataModel artefactListModel = new ArtefactTableDataModel(artefacts);
    artefactListModel.setLocale(getLocale());
    TableGuiConfiguration tableGuiConfiguration = new TableGuiConfiguration();
    tableGuiConfiguration.setTableEmptyMessage(getTranslator().translate("table.empty"));
    tableGuiConfiguration.setPageingEnabled(true);
    // offer download only when in artefact pool (no struct given)
    tableGuiConfiguration.setDownloadOffered(struct == null);
    tableGuiConfiguration.setResultsPerPage(10);
    tableGuiConfiguration.setPreferencesOffered(true, "artefacts.as.table.prefs");
    artefactListTblCtrl = new TableController(tableGuiConfiguration, ureq, getWindowControl(), getTranslator());
    if (multiSelect) {
        artefactListTblCtrl.setMultiSelect(true);
        artefactListTblCtrl.addMultiSelectAction("select", "select");
    }
    listenTo(artefactListTblCtrl);
    String details = artefactChooseMode ? null : CMD_TITLE;
    DefaultColumnDescriptor descr = new DefaultColumnDescriptor("artefact.title", 0, details, getLocale());
    artefactListTblCtrl.addColumnDescriptor(descr);
    descr = new DefaultColumnDescriptor("artefact.description", 1, null, getLocale());
    descr.setEscapeHtml(EscapeMode.antisamy);
    artefactListTblCtrl.addColumnDescriptor(true, descr);
    descr = new DefaultColumnDescriptor("artefact.date", 2, null, getLocale());
    artefactListTblCtrl.addColumnDescriptor(true, descr);
    descr = new DefaultColumnDescriptor("artefact.author", 3, null, getLocale());
    artefactListTblCtrl.addColumnDescriptor(false, descr);
    descr = new DefaultColumnDescriptor("artefact.tags", 4, null, getLocale());
    artefactListTblCtrl.addColumnDescriptor(false, descr);
    descr = new CustomRenderColumnDescriptor("table.header.type", 5, null, ureq.getLocale(), ColumnDescriptor.ALIGNMENT_CENTER, new ArtefactTypeImageCellRenderer(getLocale())) {

        /**
         * @see org.olat.core.gui.components.table.DefaultColumnDescriptor#compareTo(int, int)
         */
        @Override
        public int compareTo(int rowa, int rowb) {
            Object a = table.getTableDataModel().getValueAt(rowa, dataColumn);
            Object b = table.getTableDataModel().getValueAt(rowb, dataColumn);
            String typeA = getArtefactTranslatedTypeName((AbstractArtefact) a);
            String typeB = getArtefactTranslatedTypeName((AbstractArtefact) b);
            return typeA.compareTo(typeB);
        }
    };
    artefactListTblCtrl.addColumnDescriptor(false, descr);
    StaticColumnDescriptor staticDescr;
    if (!artefactChooseMode) {
        if (mapClosed || !secCallback.canEditReflexion()) {
            // change link-description in row, when map is closed or viewed by another person
            staticDescr = new StaticColumnDescriptor(CMD_REFLEXION, "table.header.reflexion", translate("table.header.view"));
        } else {
            staticDescr = new StaticColumnDescriptor(CMD_REFLEXION, "table.header.reflexion", translate("table.row.reflexion"));
        }
        artefactListTblCtrl.addColumnDescriptor(true, staticDescr);
    }
    if (struct == null) {
        staticDescr = new StaticColumnDescriptor(CMD_DELETEARTEFACT, "delete.artefact", translate("delete.artefact"));
        artefactListTblCtrl.addColumnDescriptor(true, staticDescr);
    }
    if (artefactChooseMode) {
        staticDescr = new StaticColumnDescriptor(CMD_CHOOSE, "table.header.choose", translate("choose.artefact"));
        artefactListTblCtrl.addColumnDescriptor(true, staticDescr);
    }
    if (struct != null && secCallback.canRemoveArtefactFromStruct()) {
        staticDescr = new StaticColumnDescriptor(CMD_UNLINK, "table.header.unlink", translate("remove.from.map"));
        artefactListTblCtrl.addColumnDescriptor(true, staticDescr);
    }
    if (struct != null && secCallback.canRemoveArtefactFromStruct() && secCallback.canAddArtefact()) {
        staticDescr = new StaticColumnDescriptor(CMD_MOVE, "table.header.move", translate("artefact.options.move"));
        artefactListTblCtrl.addColumnDescriptor(true, staticDescr);
    }
    artefactListTblCtrl.setTableDataModel(artefactListModel);
    if (vC.getComponent("artefactTable") != null)
        vC.remove(artefactListTblCtrl.getInitialComponent());
    vC.put("artefactTable", artefactListTblCtrl.getInitialComponent());
}
Also used : CustomRenderColumnDescriptor(org.olat.core.gui.components.table.CustomRenderColumnDescriptor) TableController(org.olat.core.gui.components.table.TableController) AbstractArtefact(org.olat.portfolio.model.artefacts.AbstractArtefact) StaticColumnDescriptor(org.olat.core.gui.components.table.StaticColumnDescriptor) TableGuiConfiguration(org.olat.core.gui.components.table.TableGuiConfiguration) DefaultColumnDescriptor(org.olat.core.gui.components.table.DefaultColumnDescriptor)

Example 13 with StaticColumnDescriptor

use of org.olat.core.gui.components.table.StaticColumnDescriptor in project OpenOLAT by OpenOLAT.

the class RepositoryTableModel method addColumnDescriptors.

/**
 * @param tableCtr
 * @param selectButtonLabel Label of action row or null if no action row should be used
 * @param enableDirectLaunch
 * @return the position of the display name column
 */
public ColumnDescriptor addColumnDescriptors(TableController tableCtr, boolean selectTitle, boolean selectIcon, boolean remove, boolean infos) {
    Locale loc = translator.getLocale();
    CustomCellRenderer acRenderer = new RepositoryEntryACColumnDescriptor();
    tableCtr.addColumnDescriptor(new CustomRenderColumnDescriptor("table.header.ac", RepoCols.ac.ordinal(), null, loc, ColumnDescriptor.ALIGNMENT_LEFT, acRenderer) {

        @Override
        public int compareTo(int rowa, int rowb) {
            Object o1 = table.getTableDataModel().getObject(rowa);
            Object o2 = table.getTableDataModel().getObject(rowb);
            if (o1 == null || !(o1 instanceof RepositoryEntry))
                return -1;
            if (o2 == null || !(o2 instanceof RepositoryEntry))
                return 1;
            RepositoryEntry re1 = (RepositoryEntry) o1;
            RepositoryEntry re2 = (RepositoryEntry) o2;
            if (re1.isMembersOnly()) {
                if (!re2.isMembersOnly()) {
                    return 1;
                }
            } else if (re2.isMembersOnly()) {
                return -1;
            }
            OLATResourceAccess ac1 = repoEntriesWithOffer.get(re1.getOlatResource().getKey());
            OLATResourceAccess ac2 = repoEntriesWithOffer.get(re2.getOlatResource().getKey());
            if (ac1 == null && ac2 != null)
                return -1;
            if (ac1 != null && ac2 == null)
                return 1;
            if (ac1 != null && ac2 != null)
                return compareAccess(re1, ac1, re2, ac2);
            return super.compareString(re1.getDisplayname(), re2.getDisplayname());
        }

        private int compareAccess(RepositoryEntry re1, OLATResourceAccess ac1, RepositoryEntry re2, OLATResourceAccess ac2) {
            int s1 = ac1.getMethods().size();
            int s2 = ac2.getMethods().size();
            int compare = s1 - s2;
            if (compare != 0)
                return compare;
            if (s1 > 0 && s2 > 0) {
                String t1 = ac1.getMethods().get(0).getMethod().getType();
                String t2 = ac2.getMethods().get(0).getMethod().getType();
                int compareType = super.compareString(t1, t2);
                if (compareType != 0)
                    return compareType;
            }
            return super.compareString(re1.getDisplayname(), re2.getDisplayname());
        }
    });
    tableCtr.addColumnDescriptor(new RepositoryEntryTypeColumnDescriptor("table.header.typeimg", RepoCols.repoEntry.ordinal(), null, loc, ColumnDescriptor.ALIGNMENT_LEFT));
    String selectAction = selectTitle ? TABLE_ACTION_SELECT_LINK : null;
    if (repositoryModule.isManagedRepositoryEntries()) {
        tableCtr.addColumnDescriptor(false, new DefaultColumnDescriptor("table.header.externalid", RepoCols.externalId.ordinal(), selectAction, loc));
        tableCtr.addColumnDescriptor(new DefaultColumnDescriptor("table.header.externalref", RepoCols.externalRef.ordinal(), selectAction, loc));
    }
    boolean lfVisible = lifecycleDao.countPublicLifecycle() > 0;
    tableCtr.addColumnDescriptor(lfVisible, new DefaultColumnDescriptor("table.header.lifecycle.label", RepoCols.lifecycleLabel.ordinal(), null, loc));
    tableCtr.addColumnDescriptor(false, new DefaultColumnDescriptor("table.header.lifecycle.softkey", RepoCols.lifecycleSoftKey.ordinal(), null, loc));
    ColumnDescriptor nameColDesc = new DefaultColumnDescriptor("table.header.displayname", RepoCols.displayname.ordinal(), selectAction, loc) {

        @Override
        public int compareTo(int rowa, int rowb) {
            Object o1 = table.getTableDataModel().getValueAt(rowa, 1);
            Object o2 = table.getTableDataModel().getValueAt(rowb, 1);
            if (o1 == null || !(o1 instanceof RepositoryEntry))
                return -1;
            if (o2 == null || !(o2 instanceof RepositoryEntry))
                return 1;
            RepositoryEntry re1 = (RepositoryEntry) o1;
            RepositoryEntry re2 = (RepositoryEntry) o2;
            boolean c1 = RepositoryManager.getInstance().createRepositoryEntryStatus(re1.getStatusCode()).isClosed();
            boolean c2 = RepositoryManager.getInstance().createRepositoryEntryStatus(re2.getStatusCode()).isClosed();
            // same as Boolean compare
            int result = (c2 == c1 ? 0 : (c1 ? 1 : -1));
            if (result == 0) {
                Object a = table.getTableDataModel().getValueAt(rowa, dataColumn);
                Object b = table.getTableDataModel().getValueAt(rowb, dataColumn);
                if (a == null || !(a instanceof String))
                    return -1;
                if (b == null || !(b instanceof String))
                    return 1;
                String s1 = (String) a;
                String s2 = (String) b;
                result = compareString(s1, s2);
            }
            return result;
        }
    };
    tableCtr.addColumnDescriptor(nameColDesc);
    CustomCellRenderer dateRenderer = new DateCellRenderer(loc);
    tableCtr.addColumnDescriptor(false, new CustomRenderColumnDescriptor("table.header.lifecycle.start", RepoCols.lifecycleStart.ordinal(), null, loc, ColumnDescriptor.ALIGNMENT_LEFT, dateRenderer));
    tableCtr.addColumnDescriptor(false, new CustomRenderColumnDescriptor("table.header.lifecycle.end", RepoCols.lifecycleEnd.ordinal(), null, loc, ColumnDescriptor.ALIGNMENT_LEFT, dateRenderer));
    tableCtr.addColumnDescriptor(new DefaultColumnDescriptor("table.header.author", RepoCols.author.ordinal(), null, loc));
    CustomCellRenderer accessRenderer = new RepositoryEntryAccessColumnDescriptor(translator);
    ColumnDescriptor accessColDesc = new CustomRenderColumnDescriptor("table.header.access", RepoCols.repoEntry.ordinal(), null, loc, ColumnDescriptor.ALIGNMENT_LEFT, accessRenderer) {

        @Override
        public int compareTo(int rowa, int rowb) {
            Object o1 = table.getTableDataModel().getValueAt(rowa, 1);
            Object o2 = table.getTableDataModel().getValueAt(rowb, 1);
            if (o1 == null || !(o1 instanceof RepositoryEntry))
                return -1;
            if (o2 == null || !(o2 instanceof RepositoryEntry))
                return 1;
            RepositoryEntry re1 = (RepositoryEntry) o1;
            RepositoryEntry re2 = (RepositoryEntry) o2;
            int ar1 = re1.getAccess();
            if (re1.isMembersOnly()) {
                ar1 = 99;
            }
            int ar2 = re2.getAccess();
            if (re2.isMembersOnly()) {
                ar2 = 99;
            }
            if (ar1 < ar2)
                return -1;
            if (ar1 > ar2)
                return 1;
            return super.compareString(re1.getDisplayname(), re2.getDisplayname());
        }
    };
    tableCtr.addColumnDescriptor(accessColDesc);
    tableCtr.addColumnDescriptor(false, new DefaultColumnDescriptor("table.header.date", RepoCols.creationDate.ordinal(), null, loc));
    tableCtr.addColumnDescriptor(false, new DefaultColumnDescriptor("table.header.lastusage", RepoCols.lastUsage.ordinal(), null, loc));
    if (infos) {
        tableCtr.addColumnDescriptor(new StaticColumnDescriptor(TABLE_ACTION_INFOS, "info.header", translator.translate("info.header")) {

            @Override
            public void renderValue(StringOutput so, int row, Renderer renderer) {
                so.append("<i id='o_core").append(row).append("ref' class='o_icon o_icon-lg o_icon_info_resource'> </i>");
            }
        });
    }
    if (selectIcon) {
        tableCtr.addColumnDescriptor(new StaticColumnDescriptor(TABLE_ACTION_SELECT_LINK, "select", translator.translate("table.select")));
    }
    if (remove) {
        tableCtr.addColumnDescriptor(new StaticColumnDescriptor(TABLE_ACTION_REMOVE_LINK, "remove", translator.translate("remove")));
    }
    return nameColDesc;
}
Also used : Locale(java.util.Locale) CustomRenderColumnDescriptor(org.olat.core.gui.components.table.CustomRenderColumnDescriptor) CustomRenderColumnDescriptor(org.olat.core.gui.components.table.CustomRenderColumnDescriptor) DefaultColumnDescriptor(org.olat.core.gui.components.table.DefaultColumnDescriptor) StaticColumnDescriptor(org.olat.core.gui.components.table.StaticColumnDescriptor) ColumnDescriptor(org.olat.core.gui.components.table.ColumnDescriptor) StaticColumnDescriptor(org.olat.core.gui.components.table.StaticColumnDescriptor) StringOutput(org.olat.core.gui.render.StringOutput) RepositoryEntry(org.olat.repository.RepositoryEntry) OLATResourceAccess(org.olat.resource.accesscontrol.model.OLATResourceAccess) CustomCellRenderer(org.olat.core.gui.components.table.CustomCellRenderer) DateCellRenderer(org.olat.core.gui.components.table.DateCellRenderer) CustomCellRenderer(org.olat.core.gui.components.table.CustomCellRenderer) Renderer(org.olat.core.gui.render.Renderer) DateCellRenderer(org.olat.core.gui.components.table.DateCellRenderer) DefaultColumnDescriptor(org.olat.core.gui.components.table.DefaultColumnDescriptor)

Example 14 with StaticColumnDescriptor

use of org.olat.core.gui.components.table.StaticColumnDescriptor in project OpenOLAT by OpenOLAT.

the class NotificationSubscriptionTableDataModel method addTableColumns.

/**
 * Add the column descriptors to the given table controller that matches with
 * this data model
 *
 * @param subscriptionsTableCtr
 */
void addTableColumns(TableController subscriptionsTableCtr, boolean admin) {
    subscriptionsTableCtr.addColumnDescriptor(false, new DefaultColumnDescriptor("overview.column.key", 0, "launch", getLocale()));
    subscriptionsTableCtr.addColumnDescriptor(new DefaultColumnDescriptor("overview.column.type", 1, "launch", getLocale()));
    subscriptionsTableCtr.addColumnDescriptor(new DefaultColumnDescriptor("overview.column.resname", 2, null, getLocale()));
    subscriptionsTableCtr.addColumnDescriptor(new DefaultColumnDescriptor("overview.column.subidentifier", 3, null, getLocale()));
    subscriptionsTableCtr.addColumnDescriptor(admin, new DefaultColumnDescriptor("overview.column.creationDate", 4, null, getLocale()));
    subscriptionsTableCtr.addColumnDescriptor(admin, new DefaultColumnDescriptor("overview.column.lastEmail", 5, null, getLocale()));
    subscriptionsTableCtr.addColumnDescriptor(new StaticColumnDescriptor("del", "overview.column.action", trans.translate("overview.column.action.cellvalue")));
}
Also used : StaticColumnDescriptor(org.olat.core.gui.components.table.StaticColumnDescriptor) DefaultColumnDescriptor(org.olat.core.gui.components.table.DefaultColumnDescriptor)

Example 15 with StaticColumnDescriptor

use of org.olat.core.gui.components.table.StaticColumnDescriptor in project OpenOLAT by OpenOLAT.

the class GroupChoiceForm method initManageTable.

private void initManageTable(UserRequest ureq) {
    // reload data
    loadData();
    // load participants
    List<Identity> lstIdents = new ArrayList<Identity>();
    if (groupForm.getSelection().equals(GroupChoiceForm.CHOICE_ALL)) {
        lstIdents.addAll(allIdentities);
    } else if (groupForm.getSelection().equals(GroupChoiceForm.CHOICE_OTHERS)) {
        lstIdents.addAll(notInGroupIdentities);
    } else if (StringHelper.isLong(groupForm.getSelection())) {
        Long groupKey = new Long(groupForm.getSelection());
        BusinessGroup group = businessGroupService.loadBusinessGroup(groupKey);
        lstIdents.addAll(businessGroupService.getMembers(group, GroupRoles.participant.name()));
    }
    boolean isAdministrativeUser = securityModule.isUserAllowedAdminProps(ureq.getUserSession().getRoles());
    List<UserPropertyHandler> userPropertyHandlers = userManager.getUserPropertyHandlersFor(USER_PROPS_ID, isAdministrativeUser);
    // prepare table for run view
    TableGuiConfiguration tableConfig = new TableGuiConfiguration();
    tableConfig.setTableEmptyMessage(translate("cl.table.empty"));
    tableConfig.setDownloadOffered(true);
    tableConfig.setPreferencesOffered(true, "ExtendedManageTable");
    removeAsListenerAndDispose(manageChecklistTable);
    manageChecklistTable = new TableController(tableConfig, ureq, getWindowControl(), getTranslator());
    listenTo(manageChecklistTable);
    int cols = 0;
    if (isAdministrativeUser) {
        manageChecklistTable.addColumnDescriptor(new DefaultColumnDescriptor("username", 1000, null, getLocale()));
        cols++;
    }
    int i = 0;
    for (UserPropertyHandler userPropertyHandler : userPropertyHandlers) {
        if (userPropertyHandler == null)
            continue;
        boolean visible = UserManager.getInstance().isMandatoryUserProperty(USER_PROPS_ID, userPropertyHandler);
        manageChecklistTable.addColumnDescriptor(visible, userPropertyHandler.getColumnDescriptor(i++, DETAILS_ACTION, getLocale()));
        cols++;
    }
    int j = 500;
    List<Checkpoint> checkpointList = checklist.getCheckpointsSorted(ChecklistUIFactory.comparatorTitleAsc);
    for (Checkpoint checkpoint : checkpointList) {
        String pointTitle = checkpoint.getTitle() == null ? "" : checkpoint.getTitle();
        manageChecklistTable.addColumnDescriptor(new ChecklistMultiSelectColumnDescriptor(pointTitle, j++));
        cols++;
    }
    if (!readOnly) {
        manageChecklistTable.addColumnDescriptor(new StaticColumnDescriptor(EDIT_ACTION, "cl.edit.title", translate(EDIT_ACTION)));
        cols++;
    }
    manageChecklistTable.setMultiSelect(false);
    manageTableData = new ChecklistManageTableDataModel(checkpointList, lstIdents, userPropertyHandlers, cols);
    manageChecklistTable.setTableDataModel(manageTableData);
    panel.setContent(manageChecklistTable.getInitialComponent());
}
Also used : BusinessGroup(org.olat.group.BusinessGroup) TableController(org.olat.core.gui.components.table.TableController) ArrayList(java.util.ArrayList) StaticColumnDescriptor(org.olat.core.gui.components.table.StaticColumnDescriptor) TableGuiConfiguration(org.olat.core.gui.components.table.TableGuiConfiguration) Identity(org.olat.core.id.Identity) UserPropertyHandler(org.olat.user.propertyhandlers.UserPropertyHandler) DefaultColumnDescriptor(org.olat.core.gui.components.table.DefaultColumnDescriptor)

Aggregations

StaticColumnDescriptor (org.olat.core.gui.components.table.StaticColumnDescriptor)26 DefaultColumnDescriptor (org.olat.core.gui.components.table.DefaultColumnDescriptor)18 TableController (org.olat.core.gui.components.table.TableController)16 TableGuiConfiguration (org.olat.core.gui.components.table.TableGuiConfiguration)14 CustomRenderColumnDescriptor (org.olat.core.gui.components.table.CustomRenderColumnDescriptor)10 Identity (org.olat.core.id.Identity)10 UserPropertyHandler (org.olat.user.propertyhandlers.UserPropertyHandler)10 ColumnDescriptor (org.olat.core.gui.components.table.ColumnDescriptor)6 Date (java.util.Date)4 OnlineIconRenderer (org.olat.group.ui.main.OnlineIconRenderer)4 BigDecimal (java.math.BigDecimal)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 List (java.util.List)2 Locale (java.util.Locale)2 ShortName (org.olat.core.gui.ShortName)2 FormItem (org.olat.core.gui.components.form.flexible.FormItem)2 FormLayoutContainer (org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)2 CustomCellRenderer (org.olat.core.gui.components.table.CustomCellRenderer)2 DateCellRenderer (org.olat.core.gui.components.table.DateCellRenderer)2