Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 319840 - Tab character wrongly displayed in TableViewer
Summary: Tab character wrongly displayed in TableViewer
Status: CLOSED WONTFIX
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 3.5.2   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Platform-SWT-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-07-14 08:38 EDT by Urmila CLA
Modified: 2010-07-14 16:29 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Urmila CLA 2010-07-14 08:38:04 EDT
Build Identifier: M20100211-1343

I have a table which i have created using table viewer. The problem is that when the string gets displayed in the cell, the tab characters are getting displayed as boxes or squares(as you say). 

But if i set a string with tab characters in StyledText widget and display it in the shell, the tab characters are correctly displayed.


Reproducible: Always

Steps to Reproduce:
1.Use this code snippet to reproduce the problem.

import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.swt.*;
import org.eclipse.swt.custom.*;
import org.eclipse.swt.graphics.*;
import org.eclipse.swt.widgets.*;
import org.eclipse.swt.layout.*;

public class StyledTextExample {
public static void main(String [] args) {

// create the widget's shell
Shell shell = new Shell();
shell.setLayout(new FillLayout());
shell.setSize(200, 100);
Display display = shell.getDisplay();

//create a table
Table table = new Table(shell, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER
| SWT.FULL_SELECTION | SWT.DRAW_TAB);
TableViewer tableViewer = new TableViewer( table );
tableViewer.getTable().setHeaderVisible( true );
GridData gd = new GridData( SWT.FILL, SWT.FILL, true, true );
tableViewer.getTable().setLayoutData( gd );

//Add a text with tab character to the table
tableViewer.add("This \t is \t the \t tabbed \t string.");

//Add a text with tab character to the shell.
StyledText text = new StyledText(shell, SWT.BORDER);
text.setText("This\t is \t another \t tabbed \t string"); 

shell.open();
while (!shell.isDisposed())
if (!display.readAndDispatch()) display.sleep();
}
}

2. Run as Eclipse Application.

Result:
 The table shows the string with squares instead of tab spaces.
Comment 1 Remy Suen CLA 2010-07-14 08:42:33 EDT
SWT, please advise.

----------------------

Display display = new Display();
Shell shell = new Shell(display);
shell.setLayout(new FillLayout());
shell.setSize(400, 200);

Table table = new Table(shell, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL
		| SWT.BORDER | SWT.FULL_SELECTION | SWT.DRAW_TAB);
GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
table.setLayoutData(gd);

// Add a text with tab character to the table
TableItem item = new TableItem(table, SWT.LEAD);
item.setText("This \t is \t the \t tabbed \t string.");

// Add a text with tab character to the shell.
StyledText text = new StyledText(shell, SWT.BORDER);
text.setText("This\t is \t another \t tabbed \t string");

shell.open();
while (!shell.isDisposed()) {
	if (!display.readAndDispatch()) {
		display.sleep();
	}
}
display.dispose();
Comment 2 Felipe Heidrich CLA 2010-07-14 16:29:48 EDT
What happens to tab characters is platform dependent.
Use custom draw to have a consistent look across platforms.
Closing as wont fix (plaform behaviour), sorry.