| Summary: | Tab character wrongly displayed in TableViewer | ||
|---|---|---|---|
| Product: | [Eclipse Project] Platform | Reporter: | Urmila <urmila.bhowmick> |
| Component: | SWT | Assignee: | Platform-SWT-Inbox <platform-swt-inbox> |
| Status: | CLOSED WONTFIX | QA Contact: | |
| Severity: | normal | ||
| Priority: | P3 | CC: | eclipse.felipe, remy.suen |
| Version: | 3.5.2 | ||
| Target Milestone: | --- | ||
| Hardware: | PC | ||
| OS: | Windows XP | ||
| Whiteboard: | |||
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();
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. |
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.