use of de.jaret.util.ui.table.renderer.ICellRenderer in project translationstudio8 by heartsome.
the class JaretTable method getCellRendererFromMap.
/**
* Retrieve a cell renderer for a given class. Checks all interfaces and all superclasses.
*
* @param clazz class in queston
* @return renderer or null
*/
private ICellRenderer getCellRendererFromMap(Class<?> clazz) {
ICellRenderer result = null;
result = _colClassRendererMap.get(clazz);
if (result != null) {
return result;
}
Class<?>[] interfaces = clazz.getInterfaces();
for (Class<?> c : interfaces) {
result = _colClassRendererMap.get(c);
if (result != null) {
return result;
}
}
Class<?> sc = clazz.getSuperclass();
while (sc != null) {
result = _colClassRendererMap.get(sc);
if (result != null) {
return result;
}
// interfaces of the superclass
Class<?>[] scinterfaces = sc.getInterfaces();
for (Class<?> c : scinterfaces) {
result = _colClassRendererMap.get(c);
if (result != null) {
return result;
}
}
sc = sc.getSuperclass();
}
return result;
}
use of de.jaret.util.ui.table.renderer.ICellRenderer in project translationstudio8 by heartsome.
the class JaretTablePrinter method drawCell.
/**
* TODO creation and disposal of the cell renderers for printing is ... well should be changed!
*
* @param gc
* @param area
* @param row
* @param col
*/
private void drawCell(GC gc, Rectangle area, IRow row, IColumn col) {
ICellStyle bc = _table.getTableViewState().getCellStyle(row, col);
ICellRenderer cellRenderer = _table.getCellRenderer(row, col).createPrintRenderer(_printer);
if (cellRenderer != null) {
cellRenderer.draw(gc, _table, bc, area, row, col, false, false, true);
}
cellRenderer.dispose();
}
use of de.jaret.util.ui.table.renderer.ICellRenderer in project translationstudio8 by heartsome.
the class JaretTable method getCellRenderer.
/**
* Retrieve the cell renderer for a cell.
*
* @param row row row of the cell
* @param column column column of the cell
* @return cell renderer
*/
protected ICellRenderer getCellRenderer(IRow row, IColumn column) {
// first check column specific renderers
ICellRenderer renderer = null;
renderer = _colCellRendererMap.get(column);
if (renderer == null) {
// try class map
Object value = column.getValue(row);
if (value != null) {
renderer = getCellRendererFromMap(value.getClass());
}
if (renderer == null) {
// nothing? -> default
renderer = _colClassRendererMap.get(void.class);
}
}
return renderer;
}
use of de.jaret.util.ui.table.renderer.ICellRenderer in project translationstudio8 by heartsome.
the class JaretTable method getToolTipText.
/**
* Supply tooltip text for a position in the table.
*
* @param x x coordinate
* @param y y coordinate
* @return tooltip text or <code>null</code>
*/
private String getToolTipText(int x, int y) {
IJaretTableCell cell = getCell(x, y);
if (cell != null) {
Rectangle bounds = getCellBounds(cell);
ICellRenderer renderer = getCellRenderer(cell.getRow(), cell.getColumn());
if (renderer != null) {
String tt = renderer.getTooltip(this, bounds, cell.getRow(), cell.getColumn(), x, y);
if (tt != null) {
return tt;
}
}
}
return null;
}
use of de.jaret.util.ui.table.renderer.ICellRenderer in project translationstudio8 by heartsome.
the class JaretTable method getPreferredRowHeight.
/**
* Calculate the preferred height of a row. Only visibl columns are taken into account.
*
* @param gc Graphics context
* @param row row to calculate the height for
* @return preferred height or -1 if no preferred height can be determined
*/
private int getPreferredRowHeight(GC gc, IRow row) {
int result = -1;
for (IColumn column : _cols) {
if (_tvs.getColumnVisible(column)) {
ICellRenderer renderer = getCellRenderer(row, column);
ICellStyle cellStyle = _tvs.getCellStyle(row, column);
int ph = renderer.getPreferredHeight(gc, cellStyle, _tvs.getColumnWidth(column), row, column);
if (ph > result) {
result = ph;
}
}
}
return result;
}
Aggregations