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

Bug 370756

Summary: MessageBox showing Chinese not sized correctly
Product: [RT] RAP Reporter: Scott Helsby <scott.helsby>
Component: RWTAssignee: Project Inbox <rap-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3    
Version: unspecified   
Target Milestone: 1.5 M6   
Hardware: All   
OS: All   
Whiteboard:
Attachments:
Description Flags
Patch that solves the issue none

Description Scott Helsby CLA 2012-02-06 14:13:56 EST
Build Identifier: 

We have tested our project using English and using Simplified Chinese.
The English testing did not show problems with the sizing of a MessageBox.
The Chinese testing did show a problem. The first time the MessageBox was shown, it was very badly sized. The rest of the time the MessageBox was shown correctly.

The code I used to reproduce the issue outside of our project is:

public class EntryPoint implements IEntryPoint {

	@SuppressWarnings("nls")
	@Override
	public int createUI() {
		String localeParameter = RWT.getRequest().getParameter("locale");
		if (localeParameter != null) {
			setLocale(localeParameter);
		} else {
			String languageString = System.getProperty("user.language");
			if (languageString != null) {
				setLocale(languageString);
			} else {
				setLocale("zh_CN");
			}
		}

		Display display = PlatformUI.createDisplay();

		final Shell shell = new Shell(display, SWT.SHELL_TRIM);
		shell.setLayout(new FillLayout());
		Button button = new Button(shell, SWT.NONE);
		button.setText("\u767b\u5f55");
		button.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected(SelectionEvent event) {
				MessageBox box = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK | SWT.APPLICATION_MODAL);
				box.setText("\u9519\u8bef");
				box.setMessage("\u65e0\u6cd5\u901a\u8fc7\u9a8c\u8bc1\u3002\n\u8bf7\u6838\u5b9e\u60a8\u7684\u7528\u6237\u8bc6\u522b\u540d\u548c\u5bc6\u7801\u3002");
				box.open();
			}
		});
		shell.open();
		while (!shell.isDisposed()) {
			if (!display.readAndDispatch()) {
				display.sleep();
			}
		}

		return 0;
	}

	@SuppressWarnings("nls")
	private void setLocale(String languageString) {
		String[] split = languageString.split("_", -1);

		Locale locale;
		switch (split.length) {
		case 0: return;
		case 1:
			locale = new Locale(split[0]);
			break;
		case 2:
			locale = new Locale(split[0], split[1]);
			break;
		default:
			locale = new Locale(split[0], split[1], split[2]);
			break;
		}
		RWT.setLocale(locale);
	}

}

Reproducible: Always
Comment 1 Ivan Furnadjiev CLA 2012-02-06 14:29:39 EST
Created attachment 210612 [details]
Patch that solves the issue

This is a TSD issue. When a Shell is packed, the text size recalculation does not re-pack it, but restore its original bounds.
Comment 2 Ivan Furnadjiev CLA 2012-02-06 14:31:31 EST
Applied patch to CVS HEAD.