use of org.olat.core.gui.render.StringOutput in project OpenOLAT by OpenOLAT.
the class TableRenderer method appendSingleDataRow.
private void appendSingleDataRow(final Renderer renderer, final StringOutput target, final URLBuilder ubu, Table table, final boolean iframePostEnabled, final int cols, final int i, final int currentPosInModel, final boolean isMark) {
String cssClass;
for (int j = 0; j < cols; j++) {
ColumnDescriptor cd = table.getColumnDescriptor(j);
int alignment = cd.getAlignment();
cssClass = (alignment == ColumnDescriptor.ALIGNMENT_LEFT ? "text-left" : (alignment == ColumnDescriptor.ALIGNMENT_RIGHT ? "text-right" : "text-center"));
target.append("<td class=\"").append(cssClass);
if (isMark) {
target.append(" o_table_marked");
}
target.append("\">");
String action = cd.getAction(i);
if (action != null) {
StringOutput so = new StringOutput(100);
cd.renderValue(so, i, renderer);
appendSingleDataRowActionColumn(target, ubu, table, iframePostEnabled, i, currentPosInModel, j, cd, action, so.toString());
} else {
cd.renderValue(target, i, renderer);
}
target.append("</td>");
}
}
use of org.olat.core.gui.render.StringOutput in project OpenOLAT by OpenOLAT.
the class DefaultXlsTableExporter method createData.
private void createData(final Table table, final int cdcnt, final int rcnt, final OpenXMLWorksheet exportSheet) {
for (int r = 0; r < rcnt; r++) {
Row dataRow = exportSheet.newRow();
for (int c = 0; c < cdcnt; c++) {
ColumnDescriptor cd = table.getColumnDescriptor(c);
if (cd instanceof StaticColumnDescriptor) {
// ignore static column descriptors - of no value in excel download!
continue;
}
StringOutput so = new StringOutput();
cd.renderValue(so, r, null);
String cellValue = so.toString();
cellValue = StringHelper.stripLineBreaks(cellValue);
cellValue = FilterFactory.getHtmlTagsFilter().filter(cellValue);
if (StringHelper.containsNonWhitespace(cellValue)) {
cellValue = StringEscapeUtils.unescapeHtml(cellValue);
if (cellValue.length() >= 32767) {
cellValue = Formatter.truncate(cellValue, 32760);
}
}
dataRow.addCell(c, cellValue, null);
}
}
}
use of org.olat.core.gui.render.StringOutput in project OpenOLAT by OpenOLAT.
the class ChoiceTableDataModel method matchRowWithSearchString.
/**
* Check if the row-value matches with the search-query.
* @param row
* @param tableSearchString2
* @return
*/
private boolean matchRowWithSearchString(final int row, final String tableSearchString2) {
log.debug("matchRowWithFilter: row=" + row + " tableFilterString=" + tableSearchString);
if (!isTableFiltered()) {
return true;
}
// loop over all columns
TableDataModel unfilteredModel = getUnfilteredTableDataModel();
Filter htmlFilter = FilterFactory.getHtmlTagsFilter();
for (int colIndex = getColumnCountFromAllCDs(); colIndex-- > 0; ) {
ColumnDescriptor cd = getColumnDescriptorFromAllCDs(colIndex);
int dataColumn = cd.getDataColumn();
if (dataColumn >= 0 && isColumnDescriptorVisible(cd)) {
Object value = unfilteredModel.getValueAt(row, dataColumn);
// When a CustomCellRenderer exist, use this to render cell-value to String
if (cd instanceof CustomRenderColumnDescriptor) {
CustomRenderColumnDescriptor cdrd = (CustomRenderColumnDescriptor) cd;
CustomCellRenderer customCellRenderer = cdrd.getCustomCellRenderer();
if (customCellRenderer instanceof CustomCssCellRenderer) {
// For css renderers only use the hover
// text, not the CSS class name and other
// HTLM markup
CustomCssCellRenderer cssRenderer = (CustomCssCellRenderer) customCellRenderer;
value = cssRenderer.getHoverText(value);
if (!StringHelper.containsNonWhitespace((String) value)) {
continue;
}
} else {
StringOutput sb = StringOutputPool.allocStringBuilder(250);
customCellRenderer.render(sb, null, value, cdrd.getLocale(), cd.getAlignment(), null);
value = StringOutputPool.freePop(sb);
}
}
if (value instanceof String) {
String valueAsString = (String) value;
// Remove any HTML markup from the value
valueAsString = htmlFilter.filter(valueAsString);
// Finally compare with search value based on a simple lowercase match
if (valueAsString.toLowerCase().indexOf(tableSearchString2.toLowerCase()) != -1) {
return true;
}
}
}
}
return false;
}
use of org.olat.core.gui.render.StringOutput in project OpenOLAT by OpenOLAT.
the class MenuTreeRenderer method appendDragAndDropElement.
private void appendDragAndDropElement(TreeNode node, MenuTree tree, List<DndElement> target, URLBuilder ubu, AJAXFlags flags) {
String id = node.getIdent();
boolean drag = tree.isDragEnabled() && ((DnDTreeModel) tree.getTreeModel()).isNodeDraggable(node);
boolean drop = tree.isDropEnabled() && ((DnDTreeModel) tree.getTreeModel()).isNodeDroppable(node);
if (drag || drop) {
DndElement el = new DndElement();
el.setId(id);
if (drag) {
el.setDrag(drag);
}
if (drop) {
el.setDrop(true);
StringOutput endUrl = new StringOutput(64);
ubu.buildURI(endUrl, new String[] { COMMAND_ID, NODE_IDENT }, new String[] { COMMAND_TREENODE_DROP, node.getIdent() }, flags.isIframePostEnabled() ? AJAXFlags.MODE_TOBGIFRAME : AJAXFlags.MODE_NORMAL);
el.setEndUrl(endUrl.toString());
}
target.add(el);
}
}
use of org.olat.core.gui.render.StringOutput in project OpenOLAT by OpenOLAT.
the class StaticColumnDescriptor method toString.
public String toString(final int rowid) {
StringOutput sb = new StringOutput();
renderValue(sb, rowid, null);
return sb.toString();
}
Aggregations