Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » JFace » TableColumnLayout problem on mac os
TableColumnLayout problem on mac os [message #1052581] Tue, 30 April 2013 09:05
Cedric Moonen is currently offline Cedric MoonenFriend
Messages: 274
Registered: August 2009
Senior Member

I'm using Eclipse Indigo SR2.

I wanted to have a table viewer with two columns: a column with a fixed size and a column which has the same with as its largest cell (so you don't have to resize the column to fully see its content). If the column is too large and goes outside the range of the TableViewer, then an horizontal scroll bar appears on the table viewer.

I have the following piece of code which works fine on windows but doesn't work on mac: the second column is always a couple of pixels wide and thus you can only see the 2 first characters followed by "..."

(The code is taken from a custom view)
	class ViewContentProvider implements IStructuredContentProvider {
		public void inputChanged(Viewer v, Object oldInput, Object newInput) {

		public void dispose() {

		public Object[] getElements(Object parent) {
			if (parent instanceof Object[]) {
				return (Object[]) parent;
			return new Object[0];

	class ViewLabelProvider extends ColumnLabelProvider {

		private int columnIndex;

		public ViewLabelProvider(int colIndex) {
			columnIndex = colIndex;

		public String getText(Object element) {
			if (columnIndex == 0) {
				return "";
			return super.getText(element);

	public void createPartControl(Composite parent) {
		TableColumnLayout tableLayout = new TableColumnLayout();

		viewer = new TableViewer(parent, SWT.MULTI | SWT.H_SCROLL
				| SWT.V_SCROLL);
		viewer.setContentProvider(new ViewContentProvider());
		viewer.setLabelProvider(new ViewLabelProvider(0));
		// Provide the input to the ContentProvider
		viewer.setInput(new String[] { "One", "Two",
				"A loooooooooooooooooooooooooooooooooooooooooooooooooooooong string" });

		createColumns(viewer, tableLayout);

	private void createColumns(TableViewer viewer, TableColumnLayout tableLayout) {
		TableViewerColumn firstColumn = new TableViewerColumn(viewer, SWT.FILL);
		ViewLabelProvider labelProvider = new ViewLabelProvider(0);

		TableViewerColumn secondColumn = new TableViewerColumn(viewer, SWT.FILL);
		labelProvider = new ViewLabelProvider(1);

				new ColumnWeightData(0, 22));
				new ColumnWeightData(100, 100));

	protected void refreshViewer() {
		Table table = viewer.getTable();
		for (TableColumn column : table.getColumns()) {

To make it easier to test, I attached a sample project which creates a sample view a TableViewer showing the problem.

Previous Topic:TableViewer evaluation
Next Topic:TextViewerUndoManager
Goto Forum:

Current Time: Thu May 24 10:29:51 GMT 2018

Powered by FUDForum. Page generated in 0.01699 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top