use of org.olat.core.commons.services.license.ui.LicenseRenderer in project OpenOLAT by OpenOLAT.
the class ListRenderer method appendRenderedFile.
// getRenderedDirectoryContent
/**
* Render a single file or folder.
*
* @param f The file or folder to render
* @param sb StringOutput to append generated html code
*/
private void appendRenderedFile(FolderComponent fc, VFSItem child, String currentContainerPath, StringOutput sb, URLBuilder ubu, Translator translator, boolean iframePostEnabled, boolean canContainerVersion, int pos) {
// assume full access unless security callback tells us something different.
boolean canWrite = child.getParentContainer().canWrite() == VFSConstants.YES;
// special case: virtual folders are always read only. parent of child =! the current container
canWrite = canWrite && !(fc.getCurrentContainer() instanceof VirtualContainer);
boolean isAbstract = (child instanceof AbstractVirtualContainer);
Versions versions = null;
if (canContainerVersion && child instanceof Versionable) {
Versionable versionable = (Versionable) child;
if (versionable.getVersions().isVersioned()) {
versions = versionable.getVersions();
}
}
boolean canVersion = versions != null && !versions.getRevisions().isEmpty();
boolean canAddToEPortfolio = FolderConfig.isEPortfolioAddEnabled();
VFSLeaf leaf = null;
if (child instanceof VFSLeaf) {
leaf = (VFSLeaf) child;
}
// if not a leaf, it must be a container...
boolean isContainer = (leaf == null);
MetaInfo metaInfo = null;
if (child instanceof MetaTagged) {
metaInfo = ((MetaTagged) child).getMetaInfo();
}
boolean lockedForUser = lockManager.isLockedForMe(child, fc.getIdentityEnvironnement().getIdentity(), fc.getIdentityEnvironnement().getRoles());
String name = child.getName();
boolean xssErrors = StringHelper.xssScanForErrors(name);
String pathAndName;
if (xssErrors) {
pathAndName = null;
} else {
pathAndName = currentContainerPath;
if (pathAndName.length() > 0 && !pathAndName.endsWith("/")) {
pathAndName += "/";
}
pathAndName += name;
}
// tr begin
sb.append("<tr><td>").append("<input type=\"checkbox\" name=\"").append(FileSelection.FORM_ID).append("\" value=\"");
if (xssErrors) {
sb.append(StringHelper.escapeHtml(name)).append("\" disabled=\"disabled\"");
} else {
sb.append(name).append("\" ");
}
sb.append("/> ");
// browse link pre
if (xssErrors) {
sb.append("<i class='o_icon o_icon-fw o_icon_banned'> </i> ");
sb.append(StringHelper.escapeHtml(name));
log.error("XSS Scan found something suspicious in: " + child);
} else {
sb.append("<a id='o_sel_doc_").append(pos).append("'");
if (isContainer) {
// for directories... normal module URIs
// needs encoding, not done in buildHrefAndOnclick!
// FIXME: SR: refactor encode: move to ubu.buildHrefAndOnclick
String pathAndNameEncoded = ubu.encodeUrl(pathAndName);
ubu.buildHrefAndOnclick(sb, pathAndNameEncoded, iframePostEnabled, false, true);
} else {
// for files, add PARAM_SERV command
sb.append(" href=\"");
ubu.buildURI(sb, new String[] { PARAM_SERV }, new String[] { "x" }, pathAndName, AJAXFlags.MODE_NORMAL);
sb.append("\"");
boolean download = FolderManager.isDownloadForcedFileType(name);
if (download) {
sb.append(" download=\"").append(StringHelper.escapeHtml(name)).append("\"");
} else {
sb.append(" target=\"_blank\"");
}
}
sb.append(">");
// icon css
sb.append("<i class=\"o_icon o_icon-fw ");
if (isContainer)
sb.append(CSSHelper.CSS_CLASS_FILETYPE_FOLDER);
else
sb.append(CSSHelper.createFiletypeIconCssClassFor(name));
sb.append("\"></i> ");
// name
if (isAbstract)
sb.append("<i>");
sb.append(StringHelper.escapeHtml(name));
if (isAbstract)
sb.append("</i>");
sb.append("</a>");
}
// file metadata as tooltip
if (metaInfo != null) {
boolean hasMeta = false;
sb.append("<div id='o_sel_doc_tooltip_").append(pos).append("' class='o_bc_meta' style='display:none;'>");
if (StringHelper.containsNonWhitespace(metaInfo.getTitle())) {
String title = StringHelper.escapeHtml(metaInfo.getTitle());
sb.append("<h5>").append(Formatter.escapeDoubleQuotes(title)).append("</h5>");
hasMeta = true;
}
if (StringHelper.containsNonWhitespace(metaInfo.getComment())) {
sb.append("<div class=\"o_comment\">");
String comment = StringHelper.escapeHtml(metaInfo.getComment());
sb.append(Formatter.escapeDoubleQuotes(comment));
sb.append("</div>");
hasMeta = true;
}
// boolean hasThumbnail = false;
if (metaInfo.isThumbnailAvailable() && !xssErrors) {
sb.append("<div class='o_thumbnail' style='background-image:url(");
ubu.buildURI(sb, new String[] { PARAM_SERV_THUMBNAIL }, new String[] { "x" }, pathAndName, AJAXFlags.MODE_NORMAL);
sb.append("); background-repeat:no-repeat; background-position:50% 50%;'></div>");
hasMeta = true;
// hasThumbnail = true;
}
// first try author info from metadata (creator)
// boolean hasMetaAuthor = false;
String author = metaInfo.getCreator();
// fallback use file author (uploader)
if (StringHelper.containsNonWhitespace(author)) {
// hasMetaAuthor = true;
} else {
author = metaInfo.getAuthor();
if (!"-".equals(author)) {
author = UserManager.getInstance().getUserDisplayName(author);
} else {
author = null;
}
}
author = StringHelper.escapeHtml(author);
if (StringHelper.containsNonWhitespace(author)) {
sb.append("<p class=\"o_author\">").append(Formatter.escapeDoubleQuotes(translator.translate("mf.author")));
sb.append(": ").append(Formatter.escapeDoubleQuotes(author)).append("</p>");
hasMeta = true;
}
sb.append("</div>");
if (hasMeta) {
// render tooltip only when it contains something
sb.append("<script type='text/javascript'>").append("/* <![CDATA[ */").append("jQuery(function() {\n").append(" jQuery('#o_sel_doc_").append(pos).append("').tooltip({\n").append(" html: true,\n").append(" container: 'body',\n").append(" title: function(){ return jQuery('#o_sel_doc_tooltip_").append(pos).append("').html(); }\n").append(" });\n").append(" jQuery('#o_sel_doc_").append(pos).append("').on('click', function(){\n").append(" jQuery('#o_sel_doc_").append(pos).append("').tooltip('hide');\n").append(" });\n").append("});").append("/* ]]> */").append("</script>");
}
}
sb.append("</td><td>");
// filesize
if (!isContainer) {
// append filesize
sb.append("<span class='text-muted small'>");
sb.append(Formatter.formatBytes(leaf.getSize()));
sb.append("</span>");
}
sb.append("</td><td>");
// last modified
long lastModified = child.getLastModified();
sb.append("<span class='text-muted small'>");
if (lastModified != VFSConstants.UNDEFINED)
sb.append(DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT, translator.getLocale()).format(new Date(lastModified)));
else
sb.append("-");
sb.append("</span></td><td>");
// license
if (licensesEnabled) {
MetaInfoFactory metaInfoFactory = CoreSpringFactory.getImpl(MetaInfoFactory.class);
License license = metaInfoFactory.getLicense(metaInfo);
LicenseRenderer licenseRenderer = new LicenseRenderer(translator.getLocale());
licenseRenderer.render(sb, license, true);
sb.append("</td><td>");
}
if (canContainerVersion) {
if (canVersion)
if (versions != null) {
sb.append("<span class='text-muted small'>");
sb.append(versions.getRevisionNr());
sb.append("</span>");
}
sb.append("</td><td>");
}
// locked
boolean locked = lockManager.isLocked(child);
if (locked) {
LockInfo lock = lockManager.getLock(child);
sb.append("<i class=\"o_icon o_icon_locked\" title=\"");
if (lock != null && lock.getLockedBy() != null) {
String fullname = userManager.getUserDisplayName(lock.getLockedBy());
String date = "";
if (lock.getCreationDate() != null) {
date = fc.getDateTimeFormat().format(lock.getCreationDate());
}
String msg = translator.translate("Locked", new String[] { fullname, date });
if (lock.isWebDAVLock()) {
msg += " (WebDAV)";
}
sb.append(msg);
}
sb.append("\"> </i>");
}
sb.append("</td><td>");
// Info link
if (canWrite) {
int actionCount = 0;
if (canVersion) {
actionCount++;
}
String nameLowerCase = name.toLowerCase();
// OO-57 only display edit link if it's not a folder
boolean isLeaf = (child instanceof VFSLeaf);
boolean isEditable = (isLeaf && !lockedForUser && !xssErrors && (nameLowerCase.endsWith(".html") || nameLowerCase.endsWith(".htm") || nameLowerCase.endsWith(".txt") || nameLowerCase.endsWith(".css") || nameLowerCase.endsWith(".csv ")));
if (isEditable)
actionCount++;
boolean canEP = canAddToEPortfolio && !isContainer;
if (canEP)
actionCount++;
boolean canMetaData = canMetaInfo(child);
if (canMetaData)
actionCount++;
if (actionCount == 1 && canMetaData) {
// when only one action is available, don't render menu
sb.append("<a ");
ubu.buildHrefAndOnclick(sb, null, iframePostEnabled, false, false, new NameValuePair(PARAM_EDTID, pos)).append(" title=\"").append(StringHelper.escapeHtml(translator.translate("mf.edit"))).append("\"><i class=\"o_icon o_icon-fw o_icon_edit_metadata\"></i></a>");
} else if (actionCount > 1) {
// add actions to menu if multiple actions available
sb.append("<a id='o_sel_actions_").append(pos).append("' href='javascript:;'><i class='o_icon o_icon-lg o_icon_actions'></i></a>").append("<div id='o_sel_actions_pop_").append(pos).append("' style='display:none;'><ul class='list-unstyled'>");
// meta edit action (rename etc)
if (canMetaData) {
// Metadata edit link... also handles rename for non-OlatRelPathImpls
sb.append("<li><a ");
ubu.buildHrefAndOnclick(sb, null, iframePostEnabled, false, false, new NameValuePair(PARAM_EDTID, pos)).append("><i class=\"o_icon o_icon-fw o_icon_edit_metadata\"></i> ").append(StringHelper.escapeHtml(translator.translate("mf.edit"))).append("</a></li>");
}
// content edit action
if (isEditable) {
sb.append("<li><a ");
ubu.buildHrefAndOnclick(sb, null, iframePostEnabled, false, false, new NameValuePair(PARAM_CONTENTEDITID, pos)).append("><i class=\"o_icon o_icon-fw o_icon_edit_file\"></i> ").append(StringHelper.escapeHtml(translator.translate("editor"))).append("</a></li>");
}
// versions action
if (canVersion) {
// Versions link
sb.append("<li><a ");
ubu.buildHrefAndOnclick(sb, null, iframePostEnabled, false, false, new NameValuePair(PARAM_VERID, pos)).append("><i class=\"o_icon o_icon-fw o_icon_version\"></i> ").append(StringHelper.escapeHtml(translator.translate("versions"))).append("</a></li>");
}
// get a link for adding a file to ePortfolio, if file-owner is the current user
if (canEP) {
if (metaInfo != null) {
Identity author = metaInfo.getAuthorIdentity();
if (author != null && fc.getIdentityEnvironnement().getIdentity().getKey().equals(author.getKey())) {
sb.append("<li><a ");
ubu.buildHrefAndOnclick(sb, null, iframePostEnabled, false, false, new NameValuePair(PARAM_EPORT, pos)).append("><i class=\"o_icon o_icon-fw o_icon_eportfolio_add\"></i> ").append(StringHelper.escapeHtml(translator.translate("eportfolio"))).append("</a></li>");
}
}
}
sb.append("</ul></div>").append("<script type='text/javascript'>").append("/* <![CDATA[ */").append("jQuery(function() {\n").append(" o_popover('o_sel_actions_").append(pos).append("','o_sel_actions_pop_").append(pos).append("','left');\n").append("});").append("/* ]]> */").append("</script>");
}
}
sb.append("</td></tr>");
}
use of org.olat.core.commons.services.license.ui.LicenseRenderer in project OpenOLAT by OpenOLAT.
the class AbstractItemListController method initForm.
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
// add the table
FlexiTableColumnModel columnsModel = FlexiTableDataModelFactory.createFlexiTableColumnModel();
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel("quickview", "<i class='o_icon o_icon_quickview'> </i>", "quick-view"));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(Cols.mark.i18nKey(), Cols.mark.ordinal(), true, OrderBy.marks.name()));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(true, Cols.editable.i18nKey(), Cols.editable.ordinal(), false, null, FlexiColumnModel.ALIGNMENT_LEFT, new BooleanCellRenderer(new CSSIconFlexiCellRenderer(CSS_ICON_READWRITE), new CSSIconFlexiCellRenderer(CSS_ICON_READONLY))));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(false, Cols.key.i18nKey(), Cols.key.ordinal(), true, OrderBy.key.name()));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(false, Cols.identifier.i18nKey(), Cols.identifier.ordinal(), true, OrderBy.identifier.name()));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(Cols.title.i18nKey(), Cols.title.ordinal(), true, OrderBy.title.name()));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(Cols.topic.i18nKey(), Cols.topic.ordinal(), true, OrderBy.topic.name()));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(false, Cols.creationDate.i18nKey(), Cols.creationDate.ordinal(), true, OrderBy.creationDate.name()));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(false, Cols.lastModified.i18nKey(), Cols.lastModified.ordinal(), true, OrderBy.lastModified.name()));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(false, Cols.keywords.i18nKey(), Cols.keywords.ordinal(), true, OrderBy.keywords.name()));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(false, Cols.coverage.i18nKey(), Cols.coverage.ordinal(), true, OrderBy.coverage.name()));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(false, Cols.additionalInfos.i18nKey(), Cols.additionalInfos.ordinal(), true, OrderBy.additionalInformations.name()));
if (getSecurityCallback().canUseTaxonomy()) {
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(Cols.taxnonomyLevel.i18nKey(), Cols.taxnonomyLevel.ordinal(), true, OrderBy.taxonomyLevel.name()));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(Cols.taxnonomyPath.i18nKey(), Cols.taxnonomyPath.ordinal(), true, OrderBy.taxonomyPath.name()));
}
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(false, Cols.difficulty.i18nKey(), Cols.difficulty.ordinal(), true, OrderBy.difficulty.name()));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(false, Cols.stdevDifficulty.i18nKey(), Cols.stdevDifficulty.ordinal(), true, OrderBy.stdevDifficulty.name()));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(false, Cols.differentiation.i18nKey(), Cols.differentiation.ordinal(), true, OrderBy.differentiation.name()));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(false, Cols.numOfAnswerAlternatives.i18nKey(), Cols.numOfAnswerAlternatives.ordinal(), true, OrderBy.numOfAnswerAlternatives.name()));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(false, Cols.usage.i18nKey(), Cols.usage.ordinal(), true, OrderBy.usage.name()));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(Cols.type.i18nKey(), Cols.type.ordinal(), true, OrderBy.itemType.name()));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(Cols.format.i18nKey(), Cols.format.ordinal(), true, OrderBy.format.name()));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(Cols.rating.i18nKey(), Cols.rating.ordinal(), true, OrderBy.rating.name()));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(Cols.numberOfRatings.i18nKey(), Cols.numberOfRatings.ordinal(), true, OrderBy.numberOfRatings.name()));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(false, Cols.itemVersion.i18nKey(), Cols.itemVersion.ordinal(), true, OrderBy.itemVersion.name()));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(Cols.status.i18nKey(), Cols.status.ordinal(), true, OrderBy.status.name(), new QuestionStatusCellRenderer()));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(Cols.statusLastModified.i18nKey(), Cols.statusLastModified.ordinal(), true, OrderBy.statusLastModified.name()));
if (licenseModule.isEnabled(licenseHandler)) {
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(false, false, Cols.license.i18nKey(), Cols.license.ordinal(), "license", false, null, FlexiColumnModel.ALIGNMENT_LEFT, new StaticFlexiCellRenderer("license", new LicenseRenderer(getLocale()))));
}
initActionColumns(columnsModel);
model = new QuestionItemDataModel(columnsModel, this, getTranslator());
itemsTable = uifactory.addTableElement(getWindowControl(), "items", model, 50, false, getTranslator(), formLayout);
itemsTable.setWrapperSelector("qitems");
itemsTable.setSelectAllEnable(true);
itemsTable.setMultiSelect(true);
itemsTable.setSearchEnabled(true);
itemsTable.setSortSettings(new FlexiTableSortOptions(true));
itemsTable.setExtendedSearch(extendedSearchCtrl);
itemsTable.setColumnIndexForDragAndDropLabel(Cols.title.ordinal());
itemsTable.setAndLoadPersistedPreferences(ureq, "qpool-list-" + prefsKey);
listenTo(extendedSearchCtrl);
VelocityContainer detailsVC = createVelocityContainer("item_list_details");
itemsTable.setDetailsRenderer(detailsVC, this);
FlexiTableSortOptions sortOptions = new FlexiTableSortOptions();
sortOptions.setDefaultOrderBy(new SortKey(OrderBy.title.name(), true));
itemsTable.setSortSettings(sortOptions);
initButtons(ureq, formLayout);
itemsTable.reloadData();
}
use of org.olat.core.commons.services.license.ui.LicenseRenderer in project OpenOLAT by OpenOLAT.
the class AuthorListController method initForm.
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
// search form
if (withSearch) {
setFormDescription("table.search.author.desc");
searchCtrl = new AuthorSearchController(ureq, getWindowControl(), true, mainForm);
searchCtrl.setEnabled(false);
listenTo(searchCtrl);
}
if (withClosedfilter) {
String[] statusValues = new String[] { translate("cif.resources.status.all"), translate("cif.resources.status.active"), translate("cif.resources.status.closed") };
closedEl = uifactory.addRadiosHorizontal("cif_status", "cif.resources.status", formLayout, statusKeys, statusValues);
closedEl.addActionListener(FormEvent.ONCHANGE);
closedEl.setDomReplacementWrapperRequired(false);
closedEl.select(statusKeys[1], true);
searchParams.setClosed(Boolean.FALSE);
}
// add the table
FlexiTableColumnModel columnsModel = FlexiTableDataModelFactory.createFlexiTableColumnModel();
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(false, Cols.key.i18nKey(), Cols.key.ordinal(), true, OrderBy.key.name()));
DefaultFlexiColumnModel markColumn = new DefaultFlexiColumnModel(true, Cols.mark.i18nKey(), Cols.mark.ordinal(), true, OrderBy.favorit.name());
markColumn.setExportable(false);
columnsModel.addFlexiColumnModel(markColumn);
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(true, Cols.type.i18nKey(), Cols.type.ordinal(), true, OrderBy.type.name(), FlexiColumnModel.ALIGNMENT_LEFT, new TypeRenderer()));
FlexiCellRenderer renderer = new StaticFlexiCellRenderer("select", new TextFlexiCellRenderer());
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(Cols.displayName.i18nKey(), Cols.displayName.ordinal(), "select", true, OrderBy.displayname.name(), renderer));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(false, Cols.authors.i18nKey(), Cols.authors.ordinal(), true, OrderBy.authors.name()));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(false, Cols.location.i18nKey(), Cols.location.ordinal(), true, OrderBy.location.name()));
if (repositoryModule.isManagedRepositoryEntries()) {
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(false, Cols.externalId.i18nKey(), Cols.externalId.ordinal(), true, OrderBy.externalId.name()));
}
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(false, Cols.externalRef.i18nKey(), Cols.externalRef.ordinal(), true, OrderBy.externalRef.name()));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(false, Cols.lifecycleLabel.i18nKey(), Cols.lifecycleLabel.ordinal(), true, OrderBy.lifecycleLabel.name()));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(false, Cols.lifecycleSoftkey.i18nKey(), Cols.lifecycleSoftkey.ordinal(), true, OrderBy.lifecycleSoftkey.name()));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(true, Cols.lifecycleStart.i18nKey(), Cols.lifecycleStart.ordinal(), true, OrderBy.lifecycleStart.name(), FlexiColumnModel.ALIGNMENT_LEFT, new DateFlexiCellRenderer(getLocale())));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(true, Cols.lifecycleEnd.i18nKey(), Cols.lifecycleEnd.ordinal(), true, OrderBy.lifecycleEnd.name(), FlexiColumnModel.ALIGNMENT_LEFT, new DateFlexiCellRenderer(getLocale())));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(true, Cols.author.i18nKey(), Cols.author.ordinal(), true, OrderBy.author.name()));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(true, Cols.access.i18nKey(), Cols.access.ordinal(), true, OrderBy.access.name(), FlexiColumnModel.ALIGNMENT_LEFT, new AccessRenderer()));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(true, Cols.ac.i18nKey(), Cols.ac.ordinal(), true, OrderBy.ac.name(), FlexiColumnModel.ALIGNMENT_LEFT, new ACRenderer()));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(false, Cols.creationDate.i18nKey(), Cols.creationDate.ordinal(), true, OrderBy.creationDate.name()));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(false, Cols.lastUsage.i18nKey(), Cols.lastUsage.ordinal(), true, OrderBy.lastUsage.name()));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(true, Cols.references.i18nKey(), Cols.references.ordinal(), true, OrderBy.references.name()));
if (licenseModule.isEnabled(licenseHandler)) {
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(false, false, Cols.license.i18nKey(), Cols.license.ordinal(), "license", false, null, FlexiColumnModel.ALIGNMENT_LEFT, new StaticFlexiCellRenderer("license", new LicenseRenderer(getLocale()))));
}
initActionsColumns(columnsModel);
model = new AuthoringEntryDataModel(dataSource, columnsModel);
tableEl = uifactory.addTableElement(getWindowControl(), "table", model, 20, false, getTranslator(), formLayout);
tableEl.setSearchEnabled(withSearch);
tableEl.setCssDelegate(this);
tableEl.setExportEnabled(true);
tableEl.setExtendedSearch(searchCtrl);
tableEl.setCustomizeColumns(true);
tableEl.setElementCssClass("o_coursetable");
tableEl.setShowAllRowsEnabled(true);
tableEl.setMultiSelect(true);
tableEl.setSelectAllEnable(true);
tableEl.setEmtpyTableMessageKey("table.sEmptyTable");
tableEl.setSortSettings(new FlexiTableSortOptions(true, new SortKey(OrderBy.displayname.name(), true)));
tableEl.setAndLoadPersistedPreferences(ureq, "authors-list-" + i18nName);
if (!withSearch) {
tableEl.reloadData();
tableEl.setFilters(null, getFilters(), false);
}
initBatchButtons(formLayout);
}
use of org.olat.core.commons.services.license.ui.LicenseRenderer in project openolat by klemens.
the class AuthorListController method initForm.
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
// search form
if (withSearch) {
setFormDescription("table.search.author.desc");
searchCtrl = new AuthorSearchController(ureq, getWindowControl(), true, mainForm);
searchCtrl.setEnabled(false);
listenTo(searchCtrl);
}
if (withClosedfilter) {
String[] statusValues = new String[] { translate("cif.resources.status.all"), translate("cif.resources.status.active"), translate("cif.resources.status.closed") };
closedEl = uifactory.addRadiosHorizontal("cif_status", "cif.resources.status", formLayout, statusKeys, statusValues);
closedEl.addActionListener(FormEvent.ONCHANGE);
closedEl.setDomReplacementWrapperRequired(false);
closedEl.select(statusKeys[1], true);
searchParams.setClosed(Boolean.FALSE);
}
// add the table
FlexiTableColumnModel columnsModel = FlexiTableDataModelFactory.createFlexiTableColumnModel();
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(false, Cols.key.i18nKey(), Cols.key.ordinal(), true, OrderBy.key.name()));
DefaultFlexiColumnModel markColumn = new DefaultFlexiColumnModel(true, Cols.mark.i18nKey(), Cols.mark.ordinal(), true, OrderBy.favorit.name());
markColumn.setExportable(false);
columnsModel.addFlexiColumnModel(markColumn);
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(true, Cols.type.i18nKey(), Cols.type.ordinal(), true, OrderBy.type.name(), FlexiColumnModel.ALIGNMENT_LEFT, new TypeRenderer()));
FlexiCellRenderer renderer = new StaticFlexiCellRenderer("select", new TextFlexiCellRenderer());
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(Cols.displayName.i18nKey(), Cols.displayName.ordinal(), "select", true, OrderBy.displayname.name(), renderer));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(false, Cols.authors.i18nKey(), Cols.authors.ordinal(), true, OrderBy.authors.name()));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(false, Cols.location.i18nKey(), Cols.location.ordinal(), true, OrderBy.location.name()));
if (repositoryModule.isManagedRepositoryEntries()) {
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(false, Cols.externalId.i18nKey(), Cols.externalId.ordinal(), true, OrderBy.externalId.name()));
}
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(false, Cols.externalRef.i18nKey(), Cols.externalRef.ordinal(), true, OrderBy.externalRef.name()));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(false, Cols.lifecycleLabel.i18nKey(), Cols.lifecycleLabel.ordinal(), true, OrderBy.lifecycleLabel.name()));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(false, Cols.lifecycleSoftkey.i18nKey(), Cols.lifecycleSoftkey.ordinal(), true, OrderBy.lifecycleSoftkey.name()));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(true, Cols.lifecycleStart.i18nKey(), Cols.lifecycleStart.ordinal(), true, OrderBy.lifecycleStart.name(), FlexiColumnModel.ALIGNMENT_LEFT, new DateFlexiCellRenderer(getLocale())));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(true, Cols.lifecycleEnd.i18nKey(), Cols.lifecycleEnd.ordinal(), true, OrderBy.lifecycleEnd.name(), FlexiColumnModel.ALIGNMENT_LEFT, new DateFlexiCellRenderer(getLocale())));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(true, Cols.author.i18nKey(), Cols.author.ordinal(), true, OrderBy.author.name()));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(true, Cols.access.i18nKey(), Cols.access.ordinal(), true, OrderBy.access.name(), FlexiColumnModel.ALIGNMENT_LEFT, new AccessRenderer()));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(true, Cols.ac.i18nKey(), Cols.ac.ordinal(), true, OrderBy.ac.name(), FlexiColumnModel.ALIGNMENT_LEFT, new ACRenderer()));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(false, Cols.creationDate.i18nKey(), Cols.creationDate.ordinal(), true, OrderBy.creationDate.name()));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(false, Cols.lastUsage.i18nKey(), Cols.lastUsage.ordinal(), true, OrderBy.lastUsage.name()));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(true, Cols.references.i18nKey(), Cols.references.ordinal(), true, OrderBy.references.name()));
if (licenseModule.isEnabled(licenseHandler)) {
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(false, false, Cols.license.i18nKey(), Cols.license.ordinal(), "license", false, null, FlexiColumnModel.ALIGNMENT_LEFT, new StaticFlexiCellRenderer("license", new LicenseRenderer(getLocale()))));
}
initActionsColumns(columnsModel);
model = new AuthoringEntryDataModel(dataSource, columnsModel);
tableEl = uifactory.addTableElement(getWindowControl(), "table", model, 20, false, getTranslator(), formLayout);
tableEl.setSearchEnabled(withSearch);
tableEl.setCssDelegate(this);
tableEl.setExportEnabled(true);
tableEl.setExtendedSearch(searchCtrl);
tableEl.setCustomizeColumns(true);
tableEl.setElementCssClass("o_coursetable");
tableEl.setShowAllRowsEnabled(true);
tableEl.setMultiSelect(true);
tableEl.setSelectAllEnable(true);
tableEl.setEmtpyTableMessageKey("table.sEmptyTable");
tableEl.setSortSettings(new FlexiTableSortOptions(true, new SortKey(OrderBy.displayname.name(), true)));
tableEl.setAndLoadPersistedPreferences(ureq, "authors-list-" + i18nName);
if (!withSearch) {
tableEl.reloadData();
tableEl.setFilters(null, getFilters(), false);
}
initBatchButtons(formLayout);
}
use of org.olat.core.commons.services.license.ui.LicenseRenderer in project openolat by klemens.
the class AbstractItemListController method initForm.
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
// add the table
FlexiTableColumnModel columnsModel = FlexiTableDataModelFactory.createFlexiTableColumnModel();
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel("quickview", "<i class='o_icon o_icon_quickview'> </i>", "quick-view"));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(Cols.mark.i18nKey(), Cols.mark.ordinal(), true, OrderBy.marks.name()));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(true, Cols.editable.i18nKey(), Cols.editable.ordinal(), false, null, FlexiColumnModel.ALIGNMENT_LEFT, new BooleanCellRenderer(new CSSIconFlexiCellRenderer(CSS_ICON_READWRITE), new CSSIconFlexiCellRenderer(CSS_ICON_READONLY))));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(false, Cols.key.i18nKey(), Cols.key.ordinal(), true, OrderBy.key.name()));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(false, Cols.identifier.i18nKey(), Cols.identifier.ordinal(), true, OrderBy.identifier.name()));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(Cols.title.i18nKey(), Cols.title.ordinal(), true, OrderBy.title.name()));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(Cols.topic.i18nKey(), Cols.topic.ordinal(), true, OrderBy.topic.name()));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(false, Cols.creationDate.i18nKey(), Cols.creationDate.ordinal(), true, OrderBy.creationDate.name()));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(false, Cols.lastModified.i18nKey(), Cols.lastModified.ordinal(), true, OrderBy.lastModified.name()));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(false, Cols.keywords.i18nKey(), Cols.keywords.ordinal(), true, OrderBy.keywords.name()));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(false, Cols.coverage.i18nKey(), Cols.coverage.ordinal(), true, OrderBy.coverage.name()));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(false, Cols.additionalInfos.i18nKey(), Cols.additionalInfos.ordinal(), true, OrderBy.additionalInformations.name()));
if (getSecurityCallback().canUseTaxonomy()) {
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(Cols.taxnonomyLevel.i18nKey(), Cols.taxnonomyLevel.ordinal(), true, OrderBy.taxonomyLevel.name()));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(Cols.taxnonomyPath.i18nKey(), Cols.taxnonomyPath.ordinal(), true, OrderBy.taxonomyPath.name()));
}
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(false, Cols.difficulty.i18nKey(), Cols.difficulty.ordinal(), true, OrderBy.difficulty.name()));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(false, Cols.stdevDifficulty.i18nKey(), Cols.stdevDifficulty.ordinal(), true, OrderBy.stdevDifficulty.name()));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(false, Cols.differentiation.i18nKey(), Cols.differentiation.ordinal(), true, OrderBy.differentiation.name()));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(false, Cols.numOfAnswerAlternatives.i18nKey(), Cols.numOfAnswerAlternatives.ordinal(), true, OrderBy.numOfAnswerAlternatives.name()));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(false, Cols.usage.i18nKey(), Cols.usage.ordinal(), true, OrderBy.usage.name()));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(Cols.type.i18nKey(), Cols.type.ordinal(), true, OrderBy.itemType.name()));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(Cols.format.i18nKey(), Cols.format.ordinal(), true, OrderBy.format.name()));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(Cols.rating.i18nKey(), Cols.rating.ordinal(), true, OrderBy.rating.name()));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(Cols.numberOfRatings.i18nKey(), Cols.numberOfRatings.ordinal(), true, OrderBy.numberOfRatings.name()));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(false, Cols.itemVersion.i18nKey(), Cols.itemVersion.ordinal(), true, OrderBy.itemVersion.name()));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(Cols.status.i18nKey(), Cols.status.ordinal(), true, OrderBy.status.name(), new QuestionStatusCellRenderer()));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(Cols.statusLastModified.i18nKey(), Cols.statusLastModified.ordinal(), true, OrderBy.statusLastModified.name()));
if (licenseModule.isEnabled(licenseHandler)) {
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(false, false, Cols.license.i18nKey(), Cols.license.ordinal(), "license", false, null, FlexiColumnModel.ALIGNMENT_LEFT, new StaticFlexiCellRenderer("license", new LicenseRenderer(getLocale()))));
}
initActionColumns(columnsModel);
model = new QuestionItemDataModel(columnsModel, this, getTranslator());
itemsTable = uifactory.addTableElement(getWindowControl(), "items", model, 50, false, getTranslator(), formLayout);
itemsTable.setWrapperSelector("qitems");
itemsTable.setSelectAllEnable(true);
itemsTable.setMultiSelect(true);
itemsTable.setSearchEnabled(true);
itemsTable.setSortSettings(new FlexiTableSortOptions(true));
itemsTable.setExtendedSearch(extendedSearchCtrl);
itemsTable.setColumnIndexForDragAndDropLabel(Cols.title.ordinal());
itemsTable.setAndLoadPersistedPreferences(ureq, "qpool-list-" + prefsKey);
listenTo(extendedSearchCtrl);
VelocityContainer detailsVC = createVelocityContainer("item_list_details");
itemsTable.setDetailsRenderer(detailsVC, this);
FlexiTableSortOptions sortOptions = new FlexiTableSortOptions();
sortOptions.setDefaultOrderBy(new SortKey(OrderBy.title.name(), true));
itemsTable.setSortSettings(sortOptions);
initButtons(ureq, formLayout);
itemsTable.reloadData();
}
Aggregations