Search in sources :

Example 26 with TableGuiConfiguration

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

the class AdvancedPropertiesController method event.

/**
 * @see org.olat.core.gui.control.DefaultController#event(org.olat.core.gui.UserRequest, org.olat.core.gui.control.Controller, org.olat.core.gui.control.Event)
 */
public void event(UserRequest ureq, Controller source, Event event) {
    if (source == searchForm && event == Event.DONE_EVENT) {
        String resourceTypeName = searchForm.getResourceTypeName();
        String resourceTypeId = searchForm.getResourceTypeId();
        Long resTypeId = null;
        if (resourceTypeId != null && !resourceTypeId.equals(""))
            resTypeId = Long.valueOf(resourceTypeId);
        String category = searchForm.getCategory();
        if (category != null && category.equals(""))
            category = null;
        String propertyName = searchForm.getPropertyName();
        if (propertyName != null && propertyName.equals(""))
            propertyName = null;
        List<Property> entries = PropertyManager.getInstance().listProperties(searchForm.getIdentity(), null, resourceTypeName, resTypeId, category, propertyName);
        PropertiesTableDataModel ptdm = new PropertiesTableDataModel(entries, isAdministrativeUser);
        TableGuiConfiguration tableConfig = new TableGuiConfiguration();
        removeAsListenerAndDispose(tableCtr);
        tableCtr = new TableController(tableConfig, ureq, getWindowControl(), getTranslator());
        // use null as listener argument because we are using listenTo(..) from basiccontroller
        tableCtr.addColumnDescriptor(new DefaultColumnDescriptor("table.header.userName", 0, null, getLocale()));
        tableCtr.addColumnDescriptor(new DefaultColumnDescriptor("table.header.resourceTypeName", 1, null, getLocale()));
        tableCtr.addColumnDescriptor(new DefaultColumnDescriptor("table.header.resourceTypeId", 2, null, getLocale(), ColumnDescriptor.ALIGNMENT_RIGHT));
        tableCtr.addColumnDescriptor(new DefaultColumnDescriptor("table.header.category", 3, null, getLocale()));
        tableCtr.addColumnDescriptor(new DefaultColumnDescriptor("table.header.name", 4, null, getLocale()));
        tableCtr.addColumnDescriptor(new DefaultColumnDescriptor("table.header.floatValue", 5, null, getLocale(), ColumnDescriptor.ALIGNMENT_RIGHT));
        tableCtr.addColumnDescriptor(new DefaultColumnDescriptor("table.header.stringValue", 6, null, getLocale()));
        tableCtr.addColumnDescriptor(new DefaultColumnDescriptor("table.header.longValue", 10, null, getLocale()));
        tableCtr.addColumnDescriptor(new DefaultColumnDescriptor("table.header.textValue", 7, null, getLocale()));
        tableCtr.addColumnDescriptor(new DefaultColumnDescriptor("table.header.creationdate", 8, null, getLocale()));
        tableCtr.addColumnDescriptor(new DefaultColumnDescriptor("table.header.lastmodified", 9, null, getLocale()));
        tableCtr.setTableDataModel(ptdm);
        listenTo(tableCtr);
        myPanel.setContent(tableCtr.getInitialComponent());
    }
}
Also used : TableController(org.olat.core.gui.components.table.TableController) TableGuiConfiguration(org.olat.core.gui.components.table.TableGuiConfiguration) Property(org.olat.properties.Property) DefaultColumnDescriptor(org.olat.core.gui.components.table.DefaultColumnDescriptor)

Example 27 with TableGuiConfiguration

use of org.olat.core.gui.components.table.TableGuiConfiguration 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 28 with TableGuiConfiguration

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

the class WikiMainController method refreshTableDataModel.

private void refreshTableDataModel(UserRequest ureq, Wiki wiki) {
    removeAsListenerAndDispose(mediaTableCtr);
    mediaTableCtr = new TableController(new TableGuiConfiguration(), ureq, getWindowControl(), getTranslator());
    listenTo(mediaTableCtr);
    mediaTableCtr.setMultiSelect(true);
    mediaTableCtr.addMultiSelectAction(ACTION_DELETE_MEDIAS, ACTION_DELETE_MEDIAS);
    List<VFSItem> filelist = wiki.getMediaFileListWithMetadata();
    Map<String, MediaFileElement> files = new HashMap<String, MediaFileElement>();
    for (Iterator<VFSItem> iter = filelist.iterator(); iter.hasNext(); ) {
        VFSLeaf elem = (VFSLeaf) iter.next();
        if (elem.getName().endsWith(METADATA_SUFFIX)) {
            // *.metadata files
            // go here
            Properties p = new Properties();
            try {
                p.load(elem.getInputStream());
                MediaFileElement mediaFileElement = new MediaFileElement(elem.getName(), p.getProperty(MEDIA_FILE_CREATED_BY), p.getProperty(MEDIA_FILE_CREATIONDATE));
                mediaFileElement.setDeletedBy(p.getProperty(MEDIA_FILE_DELETED_BY));
                mediaFileElement.setDeletionDate(p.getProperty(MEDIA_FILE_DELETIONDATE));
                files.put(p.getProperty(MEDIA_FILE_FILENAME), mediaFileElement);
            } catch (IOException e) {
                throw new OLATRuntimeException("Could'n read properties from media file: " + elem.getName(), e);
            }
        }
    }
    for (Iterator<VFSItem> iter = filelist.iterator(); iter.hasNext(); ) {
        VFSLeaf elem = (VFSLeaf) iter.next();
        if (!elem.getName().endsWith(METADATA_SUFFIX)) {
            if (!files.containsKey(elem.getName())) {
                // legacy file without metadata
                files.put(elem.getName(), new MediaFileElement(elem.getName(), 0, elem.getLastModified()));
            } else {
                // file with metadata, update name
                MediaFileElement element = files.get(elem.getName());
                element.setFileName(elem.getName());
            }
        }
    }
    mediaFilesTableModel = new MediaFilesTableModel(new ArrayList<MediaFileElement>(files.values()), getTranslator());
    mediaFilesTableModel.addColumnDescriptors(mediaTableCtr);
    mediaTableCtr.setTableDataModel(mediaFilesTableModel);
    mediaTableCtr.setSortColumn(3, false);
    mediaTableCtr.modelChanged();
}
Also used : VFSLeaf(org.olat.core.util.vfs.VFSLeaf) HashMap(java.util.HashMap) TableController(org.olat.core.gui.components.table.TableController) ArrayList(java.util.ArrayList) VFSItem(org.olat.core.util.vfs.VFSItem) IOException(java.io.IOException) Properties(java.util.Properties) OLATRuntimeException(org.olat.core.logging.OLATRuntimeException) TableGuiConfiguration(org.olat.core.gui.components.table.TableGuiConfiguration)

Example 29 with TableGuiConfiguration

use of org.olat.core.gui.components.table.TableGuiConfiguration 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 30 with TableGuiConfiguration

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

the class MembersPeekViewController method initForm.

private void initForm(UserRequest ureq) {
    TableGuiConfiguration tableConfig = new TableGuiConfiguration();
    tableConfig.setDisplayTableHeader(false);
    tableConfig.setCustomCssClass("o_portlet_table table-condensed");
    tableConfig.setDisplayRowCount(false);
    tableConfig.setPageingEnabled(false);
    tableConfig.setDownloadOffered(false);
    tableConfig.setSortingEnabled(false);
    removeAsListenerAndDispose(tableController);
    tableController = new TableController(tableConfig, ureq, getWindowControl(), getTranslator());
    listenTo(tableController);
    tableController.addColumnDescriptor(new DefaultColumnDescriptor("members.type", 0, null, ureq.getLocale()));
    tableController.addColumnDescriptor(new DefaultColumnDescriptor("members.count", 1, null, ureq.getLocale(), ColumnDescriptor.ALIGNMENT_LEFT));
    tableController.setTableDataModel(new DefaultTableDataModel<Row>(entries) {

        @Override
        public int getColumnCount() {
            return 2;
        }

        @Override
        public Object getValueAt(int row, int col) {
            Row r = entries.get(row);
            if (col == 0) {
                return r.col1;
            }
            if (col == 1) {
                return r.col2;
            }
            return null;
        }
    });
    putInitialPanel(tableController.getInitialComponent());
}
Also used : TableController(org.olat.core.gui.components.table.TableController) TableGuiConfiguration(org.olat.core.gui.components.table.TableGuiConfiguration) DefaultColumnDescriptor(org.olat.core.gui.components.table.DefaultColumnDescriptor)

Aggregations

TableController (org.olat.core.gui.components.table.TableController)60 TableGuiConfiguration (org.olat.core.gui.components.table.TableGuiConfiguration)60 DefaultColumnDescriptor (org.olat.core.gui.components.table.DefaultColumnDescriptor)38 StaticColumnDescriptor (org.olat.core.gui.components.table.StaticColumnDescriptor)14 CustomRenderColumnDescriptor (org.olat.core.gui.components.table.CustomRenderColumnDescriptor)12 BooleanColumnDescriptor (org.olat.core.gui.components.table.BooleanColumnDescriptor)10 Identity (org.olat.core.id.Identity)8 ArrayList (java.util.ArrayList)6 Date (java.util.Date)6 BaseSecurityModule (org.olat.basesecurity.BaseSecurityModule)6 FormLayoutContainer (org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)4 Roles (org.olat.core.id.Roles)4 CourseEnvironment (org.olat.course.run.environment.CourseEnvironment)4 UserCourseEnvironment (org.olat.course.run.userview.UserCourseEnvironment)4 RepositoryTableModel (org.olat.repository.ui.RepositoryTableModel)4 IOException (java.io.IOException)2 BigDecimal (java.math.BigDecimal)2 HashMap (java.util.HashMap)2 List (java.util.List)2 Properties (java.util.Properties)2