Search in sources :

Example 11 with RepositoryEntryShort

use of org.olat.repository.RepositoryEntryShort in project OpenOLAT by OpenOLAT.

the class RepositoryEntryIconRenderer method getIconCssClass.

public String getIconCssClass(Object val) {
    String cssClass = null;
    if (val instanceof RepositoryEntry) {
        RepositoryEntry re = (RepositoryEntry) val;
        cssClass = RepositoyUIFactory.getIconCssClass(re);
    } else if (val instanceof RepositoryEntryShort) {
        RepositoryEntryShort re = (RepositoryEntryShort) val;
        cssClass = RepositoyUIFactory.getIconCssClass(re);
    }
    return cssClass == null ? "" : cssClass;
}
Also used : RepositoryEntryShort(org.olat.repository.RepositoryEntryShort) RepositoryEntry(org.olat.repository.RepositoryEntry)

Example 12 with RepositoryEntryShort

use of org.olat.repository.RepositoryEntryShort in project OpenOLAT by OpenOLAT.

the class TypeRenderer method render.

@Override
public void render(Renderer renderer, StringOutput target, Object cellValue, int row, FlexiTableComponent source, URLBuilder ubu, Translator translator) {
    String type = null;
    if (cellValue instanceof RepositoryEntryShort) {
        // add image and typename code
        type = ((RepositoryEntryShort) cellValue).getResourceType();
    } else if (cellValue instanceof RepositoryEntry) {
        type = ((RepositoryEntry) cellValue).getOlatResource().getResourceableTypeName();
    }
    if (type == null) {
        type = translator.translate("cif.type.na");
    } else {
        type = NewControllerFactory.translateResourceableTypeName(type, translator.getLocale());
    }
    type = StringEscapeUtils.escapeHtml(type);
    String cssClass = "";
    boolean managed = false;
    int access = -1;
    if (cellValue instanceof AuthoringEntryRow) {
        AuthoringEntryRow re = (AuthoringEntryRow) cellValue;
        cssClass = RepositoyUIFactory.getIconCssClass(re);
        managed = re.isManaged();
        access = re.getAccess();
    } else if (cellValue instanceof RepositoryEntryShort) {
        RepositoryEntryShort re = (RepositoryEntryShort) cellValue;
        cssClass = RepositoyUIFactory.getIconCssClass(re);
    } else if (cellValue instanceof RepositoryEntry) {
        RepositoryEntry re = (RepositoryEntry) cellValue;
        cssClass = RepositoyUIFactory.getIconCssClass(re);
        managed = StringHelper.containsNonWhitespace(re.getManagedFlagsString());
        access = re.getStatusCode();
    }
    if (renderer == null) {
        // excel download
        target.append(type);
    } else {
        target.append("<div class='o_nowrap o_repoentry_type'>").append("<i class='o_icon o_icon-lg ").append(cssClass).append("' title=\"").append(type).append("\"> </i>");
        if (managed) {
            target.append(" <i class='o_icon o_icon_managed' title=\"").append(translator.translate("cif.managedflags")).append("\"> </i> ");
        }
        if (access == 0) {
            target.append(" <i class='o_icon o_icon-lg o_icon_deleted'> </i> ");
        }
        target.append("</div>");
    }
}
Also used : RepositoryEntryShort(org.olat.repository.RepositoryEntryShort) RepositoryEntry(org.olat.repository.RepositoryEntry)

Example 13 with RepositoryEntryShort

use of org.olat.repository.RepositoryEntryShort in project OpenOLAT by OpenOLAT.

the class AbstractBusinessGroupListController method formInnerEvent.

@Override
protected void formInnerEvent(UserRequest ureq, FormItem source, FormEvent event) {
    if (createButton == source) {
        doCreate(ureq, getWindowControl(), null);
    } else if (deleteButton == source) {
        confirmDelete(ureq, getSelectedItems());
    } else if (duplicateButton == source) {
        doCopy(ureq, getSelectedItems());
    } else if (configButton == source) {
        doConfiguration(ureq, getSelectedItems());
    } else if (emailButton == source) {
        doEmails(ureq, getSelectedItems());
    } else if (usersButton == source) {
        doUserManagement(ureq, getSelectedItems());
    } else if (mergeButton == source) {
        doMerge(ureq, getSelectedItems());
    } else if (selectButton == source) {
        doSelect(ureq, getSelectedItems());
    } else if (source instanceof FormLink) {
        FormLink link = (FormLink) source;
        String cmd = link.getCmd();
        if ("mark".equals(cmd)) {
            BusinessGroupRow row = (BusinessGroupRow) link.getUserObject();
            boolean marked = toogleMark(row);
            link.setIconLeftCSS(marked ? "o_icon o_icon_bookmark o_icon-lg" : "o_icon o_icon_bookmark_add o_icon-lg");
            link.getComponent().setDirty(true);
        } else if ("allresources".equals(cmd)) {
            BusinessGroupShort bg = (BusinessGroupShort) link.getUserObject();
            NewControllerFactory.getInstance().launch("[BusinessGroup:" + bg.getKey() + "][toolresources:0]", ureq, getWindowControl());
        } else if ("resource".equals(cmd)) {
            RepositoryEntryShort re = (RepositoryEntryShort) link.getUserObject();
            NewControllerFactory.getInstance().launch("[RepositoryEntry:" + re.getKey() + "]", ureq, getWindowControl());
        } else if (link.getUserObject() instanceof BusinessGroupRef) {
            BusinessGroupRef item = (BusinessGroupRef) link.getUserObject();
            Long businessGroupKey = item.getKey();
            BusinessGroup businessGroup = businessGroupService.loadBusinessGroup(businessGroupKey);
            if (businessGroup == null) {
                groupTableModel.removeBusinessGroup(businessGroupKey);
                tableEl.reset();
            } else if (TABLE_ACTION_ACCESS.equals(cmd)) {
                doAccess(ureq, businessGroup);
            } else if (TABLE_ACTION_LEAVE.equals(cmd)) {
                doConfirmLeaving(ureq, businessGroup);
            }
        }
    } else if (source == tableEl) {
        String cmd = event.getCommand();
        if (event instanceof SelectionEvent) {
            SelectionEvent se = (SelectionEvent) event;
            if (se.getIndex() >= 0 && se.getIndex() < groupTableModel.getRowCount()) {
                BusinessGroupRef item = groupTableModel.getObject(se.getIndex());
                Long businessGroupKey = item.getKey();
                BusinessGroup businessGroup = businessGroupService.loadBusinessGroup(businessGroupKey);
                // prevent rs after a group is deleted by someone else
                if (businessGroup == null) {
                    groupTableModel.removeBusinessGroup(businessGroupKey);
                    tableEl.reset();
                } else if (TABLE_ACTION_LAUNCH.equals(cmd)) {
                    doLaunch(ureq, businessGroup);
                } else if (TABLE_ACTION_DELETE.equals(cmd)) {
                    confirmDelete(ureq, Collections.singletonList(item));
                } else if (TABLE_ACTION_LAUNCH.equals(cmd)) {
                    doLaunch(ureq, businessGroup);
                } else if (TABLE_ACTION_EDIT.equals(cmd)) {
                    doEdit(ureq, businessGroup);
                } else if (TABLE_ACTION_LEAVE.equals(cmd)) {
                    doConfirmLeaving(ureq, businessGroup);
                } else if (TABLE_ACTION_ACCESS.equals(cmd)) {
                    doAccess(ureq, businessGroup);
                } else if (TABLE_ACTION_SELECT.equals(cmd)) {
                    doSelect(ureq, businessGroup);
                }
            }
        } else if (event instanceof FlexiTableSearchEvent) {
            doSearch((FlexiTableSearchEvent) event);
        }
    }
    super.formInnerEvent(ureq, source, event);
}
Also used : BusinessGroupRef(org.olat.group.BusinessGroupRef) RepositoryEntryShort(org.olat.repository.RepositoryEntryShort) BGCopyBusinessGroup(org.olat.group.ui.wizard.BGCopyBusinessGroup) BGConfigBusinessGroup(org.olat.group.ui.wizard.BGConfigBusinessGroup) BusinessGroup(org.olat.group.BusinessGroup) SelectionEvent(org.olat.core.gui.components.form.flexible.impl.elements.table.SelectionEvent) BusinessGroupSelectionEvent(org.olat.group.model.BusinessGroupSelectionEvent) FlexiTableSearchEvent(org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableSearchEvent) FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink) BusinessGroupShort(org.olat.group.BusinessGroupShort) BusinessGroupRow(org.olat.group.model.BusinessGroupRow)

Example 14 with RepositoryEntryShort

use of org.olat.repository.RepositoryEntryShort in project OpenOLAT by OpenOLAT.

the class BGResourcesCellRenderer method render.

@Override
public void render(Renderer renderer, StringOutput sb, Object cellValue, int row, FlexiTableComponent source, URLBuilder ubu, Translator translator) {
    if (cellValue instanceof BGTableItem) {
        BGTableItem item = (BGTableItem) cellValue;
        if (item.getRelations() != null && !item.getRelations().isEmpty()) {
            List<RepositoryEntryShort> relations = item.getRelations();
            int count = 0;
            for (RepositoryEntryShort relation : relations) {
                if (renderer == null) {
                    if (sb.length() > 0) {
                        sb.append(", ");
                    }
                    sb.append(StringHelper.escapeHtml(relation.getDisplayname()));
                } else if (count >= 2) {
                    sb.append(" ");
                    FormLink allResourcesLink = item.getAllResourcesLink();
                    if (allResourcesLink == null) {
                        allResourcesLink = uifactory.addFormLink("repo_entry_" + counter.incrementAndGet(), "allresources", "...", null, formLayout, Link.NONTRANSLATED);
                    }
                    allResourcesLink.setUserObject(item);
                    allResourcesLink.getComponent().getHTMLRendererSingleton().render(renderer, sb, allResourcesLink.getComponent(), ubu, translator, null, null);
                    break;
                } else {
                    if (count > 0)
                        sb.append(" ");
                    String name = "repo_entry_" + item.getBusinessGroupKey() + "_" + relation.getKey();
                    FormLink markLink = (FormLink) formLayout.getFormComponent(name);
                    if (markLink == null) {
                        String resourceName = StringHelper.escapeHtml(relation.getDisplayname());
                        markLink = uifactory.addFormLink("repo_entry_" + relation.getKey(), "resource", resourceName, null, formLayout, Link.NONTRANSLATED);
                        markLink.setIconLeftCSS("o_icon o_CourseModule_icon");
                        markLink.setUserObject(relation);
                        formLayout.add(name, markLink);
                    }
                    markLink.getComponent().getHTMLRendererSingleton().render(renderer, sb, markLink.getComponent(), ubu, translator, null, null);
                    count++;
                }
            }
        }
    }
}
Also used : RepositoryEntryShort(org.olat.repository.RepositoryEntryShort) FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink)

Example 15 with RepositoryEntryShort

use of org.olat.repository.RepositoryEntryShort in project OpenOLAT by OpenOLAT.

the class BGMailHelper method getTemplateInfos.

public static BGMailTemplateInfos getTemplateInfos(BusinessGroupShort group, List<RepositoryEntryShort> repoEntries) {
    StringBuilder learningResources = new StringBuilder();
    if (repoEntries != null && repoEntries.size() > 0) {
        for (RepositoryEntryShort entry : repoEntries) {
            String title = entry.getDisplayname();
            String url = BusinessControlFactory.getInstance().getURLFromBusinessPathString("[RepositoryEntry:" + entry.getKey() + "]");
            learningResources.append(title);
            learningResources.append(" (");
            learningResources.append(url);
            learningResources.append(")\n");
        }
    }
    String courseList = null;
    if (learningResources.length() > 0) {
        courseList = learningResources.toString();
    }
    String groupNameWithUrl = null;
    String groupDescription = null;
    if (group != null) {
        // get group name and description
        StringBuilder sb = new StringBuilder();
        sb.append(group.getName() == null ? "" : group.getName()).append(" (").append(BusinessControlFactory.getInstance().getURLFromBusinessPathString("[BusinessGroup:" + group.getKey() + "]")).append(")\n");
        groupNameWithUrl = sb.toString();
        String description;
        if (group instanceof BusinessGroup) {
            description = ((BusinessGroup) group).getDescription();
        } else {
            description = CoreSpringFactory.getImpl(BusinessGroupDAO.class).loadDescription(group.getKey());
        }
        groupDescription = FilterFactory.getHtmlTagAndDescapingFilter().filter(description);
    }
    return new BGMailTemplateInfos(group.getName(), groupNameWithUrl, groupDescription, courseList);
}
Also used : RepositoryEntryShort(org.olat.repository.RepositoryEntryShort) BusinessGroup(org.olat.group.BusinessGroup)

Aggregations

RepositoryEntryShort (org.olat.repository.RepositoryEntryShort)20 RepositoryEntry (org.olat.repository.RepositoryEntry)10 BusinessGroup (org.olat.group.BusinessGroup)8 ArrayList (java.util.ArrayList)4 FormLink (org.olat.core.gui.components.form.flexible.elements.FormLink)4 BusinessGroupShort (org.olat.group.BusinessGroupShort)4 HashMap (java.util.HashMap)2 Locale (java.util.Locale)2 VelocityContext (org.apache.velocity.VelocityContext)2 Test (org.junit.Test)2 FlexiTableSearchEvent (org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableSearchEvent)2 SelectionEvent (org.olat.core.gui.components.form.flexible.impl.elements.table.SelectionEvent)2 Translator (org.olat.core.gui.translator.Translator)2 Identity (org.olat.core.id.Identity)2 User (org.olat.core.id.User)2 MailTemplate (org.olat.core.util.mail.MailTemplate)2 BusinessGroupRef (org.olat.group.BusinessGroupRef)2 BusinessGroupService (org.olat.group.BusinessGroupService)2 BusinessGroupRow (org.olat.group.model.BusinessGroupRow)2 BusinessGroupSelectionEvent (org.olat.group.model.BusinessGroupSelectionEvent)2