Search in sources :

Example 21 with StaticColumnDescriptor

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

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 22 with StaticColumnDescriptor

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

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)

Example 23 with StaticColumnDescriptor

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

the class SelectionForm method initializeTableController.

private void initializeTableController(UserRequest ureq) {
    TableGuiConfiguration tableConfig = new TableGuiConfiguration();
    tableConfig.setTableEmptyMessage(translate("error.no.user.found"));
    removeAsListenerAndDispose(tableCtr);
    tableCtr = new TableController(tableConfig, ureq, getWindowControl(), propertyHandlerTranslator);
    listenTo(tableCtr);
    List<Identity> l = UserDeletionManager.getInstance().getDeletableIdentities(UserDeletionManager.getInstance().getLastLoginDuration());
    tdm = new UserDeleteTableModel(l, ureq.getLocale(), isAdministrativeUser);
    tdm.addColumnDescriptors(tableCtr, null);
    tableCtr.addColumnDescriptor(new StaticColumnDescriptor(ACTION_SINGLESELECT_CHOOSE, "table.header.action", translate("action.activate")));
    tableCtr.addMultiSelectAction("action.delete.selection", ACTION_MULTISELECT_CHOOSE);
    tableCtr.setMultiSelect(true);
    tableCtr.setTableDataModel(tdm);
}
Also used : TableController(org.olat.core.gui.components.table.TableController) StaticColumnDescriptor(org.olat.core.gui.components.table.StaticColumnDescriptor) TableGuiConfiguration(org.olat.core.gui.components.table.TableGuiConfiguration) Identity(org.olat.core.id.Identity)

Example 24 with StaticColumnDescriptor

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

the class StatusController method initializeTableController.

private void initializeTableController(UserRequest ureq) {
    TableGuiConfiguration tableConfig = new TableGuiConfiguration();
    tableConfig.setTableEmptyMessage(translate("error.no.user.found"));
    removeAsListenerAndDispose(tableCtr);
    tableCtr = new TableController(tableConfig, ureq, getWindowControl(), this.propertyHandlerTranslator);
    listenTo(tableCtr);
    List<Identity> l = UserDeletionManager.getInstance().getIdentitiesInDeletionProcess(UserDeletionManager.getInstance().getDeleteEmailDuration());
    tdm = new UserDeleteTableModel(l, ureq.getLocale(), isAdministrativeUser);
    tdm.addColumnDescriptors(tableCtr, null, "table.identity.deleteEmail");
    tableCtr.addColumnDescriptor(new StaticColumnDescriptor(ACTION_SINGLESELECT_CHOOSE, "table.header.action", translate("action.activate")));
    tableCtr.setMultiSelect(false);
    tableCtr.setTableDataModel(tdm);
    userDeleteStatusPanel.setContent(tableCtr.getInitialComponent());
}
Also used : TableController(org.olat.core.gui.components.table.TableController) StaticColumnDescriptor(org.olat.core.gui.components.table.StaticColumnDescriptor) TableGuiConfiguration(org.olat.core.gui.components.table.TableGuiConfiguration) Identity(org.olat.core.id.Identity)

Example 25 with StaticColumnDescriptor

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

the class UserSearchController method doSearch.

private void doSearch(UserRequest ureq) {
    String login = searchform.login.getValue();
    // build user fields search map
    Map<String, String> userPropertiesSearch = new HashMap<>();
    for (UserPropertyHandler userPropertyHandler : searchform.userPropertyHandlers) {
        if (userPropertyHandler == null)
            continue;
        FormItem ui = searchform.propFormItems.get(userPropertyHandler.getName());
        String uiValue = userPropertyHandler.getStringValue(ui);
        if (userPropertyHandler.getName().startsWith("genericCheckboxProperty")) {
            if (!"false".equals(uiValue)) {
                userPropertiesSearch.put(userPropertyHandler.getName(), uiValue);
            }
        } else if (StringHelper.containsNonWhitespace(uiValue)) {
            userPropertiesSearch.put(userPropertyHandler.getName(), uiValue);
        }
    }
    if (userPropertiesSearch.isEmpty()) {
        userPropertiesSearch = null;
    }
    tableCtr = new TableController(tableConfig, ureq, getWindowControl(), myContent.getTranslator());
    listenTo(tableCtr);
    List<Identity> users = searchUsers(login, userPropertiesSearch, true);
    int maxResults = securityModule.getUserSearchMaxResultsValue();
    if (maxResults > 0 && users.size() > maxResults) {
        users = users.subList(0, maxResults);
        showWarning("error.search.maxResults", Integer.toString(maxResults));
    }
    if (!users.isEmpty()) {
        tdm = new UserTableDataModel(users, getLocale(), isAdministrativeUser);
        // add the data column descriptors
        tdm.addColumnDescriptors(tableCtr, null);
        // add the action columns
        if (useMultiSelect) {
            // add multiselect action
            tableCtr.addMultiSelectAction(this.actionKeyChoose, ACTION_MULTISELECT_CHOOSE);
        } else {
            // add single column selec action
            tableCtr.addColumnDescriptor(new StaticColumnDescriptor(ACTION_SINGLESELECT_CHOOSE, "table.header.action", myContent.getTranslator().translate("action.choose")));
        }
        tableCtr.setTableDataModel(tdm);
        tableCtr.setMultiSelect(useMultiSelect);
        searchPanel.pushContent(tableCtr.getInitialComponent());
        myContent.contextPut("showButton", "true");
    } else {
        getWindowControl().setInfo(translate("error.no.user.found"));
    }
}
Also used : HashMap(java.util.HashMap) FormItem(org.olat.core.gui.components.form.flexible.FormItem) TableController(org.olat.core.gui.components.table.TableController) StaticColumnDescriptor(org.olat.core.gui.components.table.StaticColumnDescriptor) Identity(org.olat.core.id.Identity) UserPropertyHandler(org.olat.user.propertyhandlers.UserPropertyHandler)

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