Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 481320

Summary: RowTemplates with right aligned cell and vscroll positioned off right edge
Product: [RT] RAP Reporter: John Gymer <jgymer>
Component: RWTAssignee: Project Inbox <rap-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: tbuschto
Version: 3.0   
Target Milestone: 3.1 M4   
Hardware: PC   
OS: Windows 7   
Whiteboard:

Description John Gymer CLA 2015-11-03 08:37:51 EST
Since RAP 3.0, if you have a Table using a RowTemplate and use RIGHT aligned TextCell with setHorizontalAlignment(SWT.RIGHT), as soon as the Table gains a vertical scrollbar, any such right-aligned TextCells jump too far to the right and have their edges truncated.

Worked OK in RAP 2.3.

Snippet as below:
(simply reduce browser size until Table gets a vscroll bar - watch the 'price' data jump too far right).

/* DEMONSTRATES row template issue with right-aligned cells in RAP 3.1 */
package bug.snippet;
import java.io.IOException;
import java.io.InputStream;

import org.eclipse.rap.rwt.RWT;
import org.eclipse.rap.rwt.service.ResourceManager;
import org.eclipse.rap.rwt.template.Template;
import org.eclipse.rap.rwt.template.TextCell;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.layout.FormAttachment;
import org.eclipse.swt.layout.FormData;
import org.eclipse.swt.layout.FormLayout;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.widgets.TableItem;

public class Bugsy {
	private Display display;
	private Shell shell;
	private static Table tab;
	private static TableColumn col;
	
	public void begin() {
		System.out.println("BugSnippy Starting...");
		
		// create the Shell
		display = new Display();
		shell = new Shell(display, SWT.TITLE|SWT.CLOSE|SWT.RESIZE);
		shell.setText("Shell");
		shell.setBounds(10, 10, 900, 500);
		shell.setFullScreen(true);
		shell.setBackground(new Color(null, new RGB(255,192,255)));
		FormLayout layout = new FormLayout();
		shell.setLayout(layout);

		//create the table
		tab = new Table(shell, SWT.FULL_SELECTION|SWT.MULTI|SWT.BORDER);
//		tab.setHeaderVisible(true);
		tab.setLinesVisible(true);
		tab.setData(RWT.MARKUP_ENABLED, true);

		// create columns
		
		// column - title
		col = new TableColumn(tab, SWT.NONE);
		col.setResizable(true);
		col.setWidth(50);
		col.setText("Title");

		// column - price
		col = new TableColumn(tab, SWT.NONE);
		col.setResizable(true);
		col.setWidth(50);
		col.setText("Price");

		// define the table's rowTemplate
		Template template = new Template();
		TextCell textCell;;
		
		textCell = new TextCell(template); // title - positioned on the left
		textCell.setLeft(0).setWidth(200).setTop(0).setHeight(30).setHorizontalAlignment(SWT.LEFT);
		textCell.setBindingIndex(0);

		textCell = new TextCell(template); // price - positioned on the right
		textCell.setRight(0).setWidth(200).setTop(0).setHeight(30).setHorizontalAlignment(SWT.RIGHT);
		textCell.setBindingIndex(1);
		
		tab.setData(RWT.ROW_TEMPLATE, template);

		//add some data to the table
		addRow("Alphacraft Rapide", "$123,456.00");
		addRow("Brum", "$23,456.00");
		addRow("Brum Brum", "$3,456.00");
		addRow("Easy-comfort saddle", "$456.00");
		addRow("Not so hot", "$56.00");
		addRow("Coming in to land", "$6.00");
		addRow("Relax", "$123,456.00");
		addRow("Roundie", "$23,456.00");
		addRow("Brum Brum Brum", "$3,456.00");
		addRow("Brum Brum Brum Brum", "$456.00");
		addRow("Culture-filled", "$56.00");
		addRow("Brum Brum Brum Brum Brum", "$6.00");
		addRow("Splish Splash", "$123,456.00");
		addRow("Blood-sucking", "$23,456.00");
		addRow("Dirt-sucking", "$3,456.00");
		addRow("Fuel-sucking", "$456.00");
		addRow("Tickerty Tockerty", "$56.00");
		
		//set table's position
		FormData fd = new FormData();
		fd.left = new FormAttachment(0, 5);
		fd.top = new FormAttachment(0, 50);
		fd.right = new FormAttachment(100,-5);
		fd.bottom = new FormAttachment(100,-5);
		tab.setLayoutData(fd);

		shell.open();

		System.out.println("BugSnippy Done!");
	}

	private void addRow(String title, String price) {
		String[] tableData = new String[2];
		tableData[0] = title;
		tableData[1] = price;
		TableItem tableItem = new TableItem(tab, SWT.None, 0);
		tableItem.setText(tableData);
	}

}
Comment 1 Tim Buschtoens CLA 2015-11-26 04:49:23 EST
Fixed with commit a80c9fde4cf194d8548a5f17d6c2f4c9dee003ed. The issue was caused by the scrollbar changes in RAP 3.0. Adjusted grid row width and template render bounds to fix the issue.