java - JFace TableViewer invalid text position in first column if some cells contain an icon -
this question has answer here:
i noticed jface tableviewer has troubles displaying text in first column (only) if other cells in other columns contain icons. additional space before text appears. don't think issue has not been found yet, possibly additional configuration required. here sample:
and simple code test:
public class icontest { private static class mycontentprovider implements istructuredcontentprovider { public object[] getelements(object inputelement) { return new string[] { "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten" }; } public void dispose() { } public void inputchanged(viewer viewer, object oldinput, object newinput) { } } /** * @param args */ public static void main(string[] args) { final display display = new display(); shell shell = new shell(display); shell.setlayout(new filllayout()); tableviewer v = new tableviewer(shell, swt.full_selection); v.gettable().setlinesvisible(true); v.gettable().setheadervisible(true); v.setcontentprovider(new mycontentprovider()); celllabelprovider labelprovider = new celllabelprovider() { public void update(viewercell cell) { cell.settext(cell.getelement().tostring()); } }; celllabelprovider labelprovider2 = new celllabelprovider() { public void update(viewercell cell) { cell.settext(cell.getelement().tostring()); cell.setimage(display.getdefault().getsystemimage(swt.icon_question)); } }; tableviewercolumn column = new tableviewercolumn(v, swt.none); column.setlabelprovider(labelprovider); column.getcolumn().settext("column 1"); column.getcolumn().setwidth(100); tableviewercolumn column2 = new tableviewercolumn(v, swt.none); column2.setlabelprovider(labelprovider2); column2.getcolumn().settext("column 2"); column2.getcolumn().setwidth(100); v.setinput(""); shell.setsize(400, 400); shell.open(); while (!shell.isdisposed()) { if (!display.readanddispatch()) { display.sleep(); } } display.dispose(); } }
any ideas?
this long standing known issue - see eclipse bug report 43910 (from 2004!)
the bug report saying underlying windows table code behaves , there nothing swt/jface can it.
you may able work around using ownerdrawlabelprovider
provides full control of how cell drawn. styledcelllabelprovider
derived ownerdrawlabelprovider
, easier use.
Comments
Post a Comment