use of org.olat.core.gui.render.StringOutput in project openolat by klemens.
the class TableListProvider method getResult.
@Override
public void getResult(String searchValue, ListReceiver receiver) {
Filter htmlFilter = FilterFactory.getHtmlTagsFilter();
Set<String> searchEntries = new TreeSet<String>();
int entryCounter = 1;
// loop over whole data-model
TableDataModel<?> unfilteredModel = table.getUnfilteredTableDataModel();
int rowCount = unfilteredModel.getRowCount();
int colCount = table.getColumnCountFromAllCDs();
a_a: for (int colIndex = 0; colIndex < colCount; colIndex++) {
ColumnDescriptor cd = table.getColumnDescriptorFromAllCDs(colIndex);
int dataColumn = cd.getDataColumn();
if (dataColumn >= 0 && table.isColumnDescriptorVisible(cd)) {
for (int rowIndex = 0; rowIndex < rowCount; rowIndex++) {
Object obj = unfilteredModel.getValueAt(rowIndex, dataColumn);
// When a CustomCellRenderer exist, use this to render cell-value to String
if (cd instanceof CustomRenderColumnDescriptor) {
CustomRenderColumnDescriptor crcd = (CustomRenderColumnDescriptor) cd;
CustomCellRenderer customCellRenderer = crcd.getCustomCellRenderer();
if (customCellRenderer instanceof CustomCssCellRenderer) {
// For css renderers only use the hover
// text, not the CSS class name and other
// markup
CustomCssCellRenderer cssRenderer = (CustomCssCellRenderer) customCellRenderer;
obj = cssRenderer.getHoverText(obj);
if (!StringHelper.containsNonWhitespace((String) obj)) {
continue;
}
} else {
StringOutput sb = StringOutputPool.allocStringBuilder(250);
customCellRenderer.render(sb, null, obj, crcd.getLocale(), cd.getAlignment(), null);
obj = StringOutputPool.freePop(sb);
}
}
if (obj instanceof String) {
String valueString = (String) obj;
// Remove any HTML markup from the value
valueString = htmlFilter.filter(valueString);
// Finally compare with search value based on a simple lowercase match
if (valueString.toLowerCase().indexOf(searchValue.toLowerCase()) != -1) {
if (searchEntries.add(valueString)) {
// Add to receiver list same entries only once
if (searchEntries.size() == 1) {
// before first entry, add searchValue. But add only when one search match
receiver.addEntry(searchValue, searchValue);
}
// limit the number of entries
if (entryCounter++ > MAX_TABLE_SEARCH_RESULT_ENTRIES) {
receiver.addEntry("...", "...");
break a_a;
}
receiver.addEntry(valueString, valueString);
}
}
}
}
}
}
}
use of org.olat.core.gui.render.StringOutput in project openolat by klemens.
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 klemens.
the class BooleanColumnDescriptor method toString.
public String toString(final int rowid) {
StringOutput sb = new StringOutput();
renderValue(sb, rowid, null);
return sb.toString();
}
use of org.olat.core.gui.render.StringOutput in project openolat by klemens.
the class CustomRenderColumnDescriptor method toString.
public String toString(final int rowid) {
StringOutput sb = new StringOutput();
renderValue(sb, rowid, null);
return sb.toString();
}
use of org.olat.core.gui.render.StringOutput in project openolat by klemens.
the class DefaultCsvTableExporter method createData.
private void createData(final Table table, final int cdcnt, final int rcnt, final StringBuilder sb) {
for (int r = 0; r < rcnt; r++) {
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);
sb.append('\t').append(cellValue);
}
sb.append('\n');
}
}
Aggregations