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

Bug 190633

Summary: [Help]TVT33:TCT441: IW: Help path in preference is RTL
Product: [Eclipse Project] Platform Reporter: CDE Administration <cdeadmin>
Component: User AssistanceAssignee: Adam Archer <agarcher>
Status: RESOLVED FIXED QA Contact:
Severity: major    
Priority: P2 CC: agarcher, camle, cgold, eclipse.felipe, kitlo, snorthov, Tod_Creasey
Version: 3.3Flags: cgold: review? (Tod_Creasey)
Target Milestone: 3.3.1   
Hardware: PC   
OS: Windows XP   
URL: 441
Whiteboard:
Bug Depends on: 87368    
Bug Blocks:    
Attachments:
Description Flags
TRL_help_path.JPG
none
screen capture
none
language options
none
sample demonstrating Text bug
none
Patch
none
temporary fix none

Description CDE Administration CLA 2007-06-02 00:14:31 EDT
<response_by> Gaby Pelleg at 2007.05.27.19.07.16 </response_by>
OS: Windows
Build date: 20070511
Component name: base
Blocking: No
Tester Name: Gaby Pelleg

Steps to recreate the problem:

In Preferences panel,Expand Help
Under Help, click Content

Problem Description:

The Path field has RTL reading order. All path fields must be LTR. See attached screen shot.

<response_by> Bryan Green at 2007.06.01.08.13.26 </response_by>
This actually is LTR reading order.  The string in RTL is "/help".

If you click the check box at the top and type in the field you can see that it is LTR enabled.

<response_by> Bryan Green at 2007.06.01.08.17.56 </response_by>
Sorry, this is a valid bug.  I confused my right and left.  Please reopen.

<response_by> Kit Lo at 2007.06.01.16.00.16 </response_by>
This article was reassigned from Category:''TVT Testcases''.
Comment 1 CDE Administration CLA 2007-06-02 00:14:37 EDT
Created attachment 69847 [details]
TRL_help_path.JPG
Comment 2 CDE Administration CLA 2007-06-02 00:14:44 EDT
<cde:tctdetail>
Testcase: 03.001260
Project: WSW33
Component: CDE - Platform/UI
Priority: 2
Subject: IW: Help path in preference is RTL
Article ID: 441
Originator: gpelleg@il.ibm.com
</cde:tctdetail>
Comment 3 CDE Administration CLA 2007-06-02 21:11:22 EDT
<response_by> Gaby Pelleg at 2007.06.02.19.40.21 </response_by>
Reopen
Comment 4 Eric Moffatt CLA 2007-06-04 13:42:08 EDT
Marking for review in 3.3.1.
Comment 5 CDE Administration CLA 2007-06-06 15:28:09 EDT
Changed severity to major because tester has identified this as a must fix for TVT.
Comment 6 Eric Moffatt CLA 2007-06-06 16:31:07 EDT
Moving to UA (sorry folks, just realized that this isn't one of our pages).
Comment 7 CDE Administration CLA 2007-06-07 11:13:40 EDT
<response_by> Noha El Ghannam at 2007.06.07.09.55.24 </response_by>
Hi,
Same problem for Arabic.
Comment 8 Chris Goldthorpe CLA 2007-06-07 11:23:27 EDT
I agree with the 3.3.1 target - I would not like to try to push this into 3.3 but it should be fixed.
Comment 9 Adam Archer CLA 2007-06-07 11:29:06 EDT
This cannot be reproduced on I20070607-0010 using -dir rtl.

I have not tried reproducing with languages yet as I don't have the environment setup for it.
Comment 10 Kit Lo CLA 2007-06-07 12:50:47 EDT
Created attachment 70523 [details]
screen capture

I recreated the problem by start eclipse with -dir rtl.
Comment 11 Kit Lo CLA 2007-06-07 12:54:08 EDT
Created attachment 70524 [details]
language options

Not sure if it's related. But, make sure in XP's "Regional and Language Options", the "complex script and righ-to-left languages" option is selected.
Comment 12 CDE Administration CLA 2007-06-12 19:12:09 EDT
<response_by> Gaby Pelleg at 2007.06.12.17.47.31 </response_by>
So is this deferred?
Comment 13 Chris Goldthorpe CLA 2007-06-12 19:38:53 EDT
Yes, until 3.3.1.
Comment 14 Chris Goldthorpe CLA 2007-06-14 16:06:15 EDT
Assigning to Adam.
Comment 15 Adam Archer CLA 2007-06-18 10:15:43 EDT
(In reply to comment #11)
> Created an attachment (id=70524) [details]
> language options
> 
> Not sure if it's related. But, make sure in XP's "Regional and Language
> Options", the "complex script and righ-to-left languages" option is selected.

Able to reproduce once these options were installed. Investigating.
Comment 16 Adam Archer CLA 2007-06-18 13:26:25 EDT
After doing some debugging, I discovered that the text in the box is still "/help" when it leaves our code and goes down to SWT. I tried setting the default text on the "Documentation URL" field on the Ant preference page to "/help" and discovered that it behaves the same way.

I discovered that by calling pathText.setOrientation(SWT.LEFT_TO_RIGHT); on the textbox it can be forced into left to right mode, but this also makes the text align to the left.

After a bit more testing of the org.eclipse.swt.widgets.Text behaviour, I think this stems from a bug in SWT's rendering of text in right to left fields. It seems that when the text in a box under rtl orientation, slash characters at the start or end of the String do not render correctly.

I will attach a small SWT sample to demonstrate the behaviour.
Comment 17 Adam Archer CLA 2007-06-18 14:03:49 EDT
Created attachment 71643 [details]
sample demonstrating Text bug

After a bit more testing I discovered that this seems to apply to all (or at least most) non letter characters.

Attached is a small SWT sample. It is a shell with a few text boxes demonstrating the problem.
Comment 18 Adam Archer CLA 2007-06-18 16:35:42 EDT
Moving to SWT.

See the sample attached in comment 17 to reproduce the problem.

Note that you must have the Windows regional and language options installed as shown in comment 11.

I have not tested this outside Windows.
Comment 19 Steve Northover CLA 2007-06-18 18:04:23 EDT
This looks like the BIDI algorithm in a text control.  Is it?
Comment 20 Felipe Heidrich CLA 2007-06-18 18:34:58 EDT
to embedded english text in a RTL component you need to use bidi control characters (LRE). see bug 191415 or bug 190740.

I'll close this as duplicate of bug 87368 because in bug 87368 we discuss other alternatives to this same problem.

*** This bug has been marked as a duplicate of bug 87368 ***
Comment 21 Steve Northover CLA 2007-06-19 09:18:59 EDT
The difference here is that it's a text control.  Embedding BIDI control characters doesn't seem right.
Comment 22 Felipe Heidrich CLA 2007-06-19 11:30:04 EDT
(In reply to comment #21)
> The difference here is that it's a text control.  Embedding BIDI control
> characters doesn't seem right.

I still think it is the right answer.
In the native text widget if you open the (native) context menu there is option "Insert Unicode control character", from the list you can pick "LRE - start left-to-right embedding", type you text, insert a PDF at the end.
Comment 23 Adam Archer CLA 2007-06-19 11:32:44 EDT
This problem for UA is targeted at 3.3.1 as it is a large usability problem for
languages that encounter the issue.

Can we have bug 87368 targeted at 3.3.1 as well if this is a duplicate?
Comment 24 Felipe Heidrich CLA 2007-06-21 14:00:47 EDT
> Can we have bug 87368 targeted at 3.3.1 as well if this is a duplicate?

Note: we still don't have a solution for bug 87368. Personally I believe people should use bidi control characters - which means there is no code involved in fixing bug 87368, we will probably just write a faq or howto for it.
Comment 25 Chris Goldthorpe CLA 2007-06-21 15:43:53 EDT
Reopening, this is not an exact duplicate. We have decided to workaround the issues reported in Bug 87368.
Comment 26 Chris Goldthorpe CLA 2007-06-21 15:43:59 EDT
Reopening, this is not an exact duplicate. We have decided to workaround the issues reported in Bug 87368.
Comment 27 Felipe Heidrich CLA 2007-06-21 16:01:18 EDT
How are you going to workaround this problem ?
Will you add bidi controls characters to your text ?
Comment 28 Adam Archer CLA 2007-06-21 16:11:24 EDT
That's right.

if (pathText.getOrientation() == SWT.RIGHT_TO_LEFT)
    path = LRE + path + PDF;
pathText.setText(path);

Just testing now.
Comment 29 Adam Archer CLA 2007-06-21 16:37:22 EDT
Created attachment 72087 [details]
Patch

This patch wraps the LRE/PDF characters around the text in the path field every time it is set while the textbox is in RTL mode. It then parses off the characters before updating the preferences.
Comment 30 Adam Archer CLA 2007-07-03 19:16:49 EDT
I tested the bug and the proposed fix on Linux and found that the bug does not occur and the fix does not cause any adverse effects.

We discovered that similar problems arise when trying to type in an IP address under the hostname field. When augmenting the patch to include this field, I discovered that the fix does not seem to work anymore. I think it's because the machine I'm working on now is on Sun JRE v6.x, but I will need to investigate further.

It seems that when the Text widgets contain strings with the BIDI control characters and the user manually edits the values, their text is entered outside the BIDI characters, causing incorrect functionality. One potential way to workaround this issue would be to add listeners to ensure the BIDI characters are on the outside of the string at all times but this seems extreme.
Comment 31 Felipe Heidrich CLA 2007-07-04 11:21:26 EDT
>It seems that when the Text widgets contain strings with the BIDI control
>characters and the user manually edits the values

Yes. The user can actually delete the control characters using backspace or delete.
You can make it a bit easier on yourself by not adding PDF at the end of string but still have the problem of making sure the LRE mark stays in the rigth place.
On GTK, you don't need the patch because GTK has a different algorithm to determine the paragraph level of a string.
Comment 32 Adam Archer CLA 2007-07-04 14:28:59 EDT
I attempted to improve this solution further by adding listeners, but the complexity is too great for such a trivial issue and the functionality is still not even ideal. In order to do this properly we need SWT to provide native support for situations like this. Even if they provided some mechanism to instruct the textbox to always wrap the contents in the LRE/PDF characters, but make them transparent to the user and uneditable, this would be an adequate solution.

As is, I think the best we can do is to make the Text elements render in SWT.LEFT_TO_RIGHT mode. This makes the alignment incorrect for RTL languages, but at least makes the preference page usable under this circumstance. I will upload a patch.
Comment 33 Adam Archer CLA 2007-07-04 14:30:33 EDT
Created attachment 73053 [details]
temporary fix

Forces the host and path fields into SWT.LEFT_TO_RIGHT orientation.
Comment 34 Chris Goldthorpe CLA 2007-07-05 17:24:39 EDT
Does the "temporary fix" replace the previous patch?
Comment 35 Adam Archer CLA 2007-07-09 09:15:27 EDT
Yes. I didn't mark the other one as obsolete because the two patches take different approaches. The older one has revealed itself to be too buggy to use at this point. We need further support from SWT.

See comment 32 and bug 87368.
Comment 36 Chris Goldthorpe CLA 2007-07-11 16:18:14 EDT
Tod can you give an opinion on the latest patch? 
Comment 37 Tod Creasey CLA 2007-07-12 08:16:09 EDT
If a field does not need to support RTL then make it a LTR field and do not process.  We are not processing text input anywhere in Eclipse in any locale right now as we try to not fight the experience the user is accustomed to. For instance in Chinese we take the input from whatever input method editor (IME) is installed and don't do anything special ourselves.

When there is an OS that supports BIDI better we will get this better support for free by not fighting the OS.

if it is comment 33 you are referring to Chris this is the right approach.
Comment 38 Chris Goldthorpe CLA 2007-07-12 11:46:13 EDT
Yes, I was referring to comment #33.
Comment 39 Chris Goldthorpe CLA 2007-07-16 11:44:35 EDT
Fixed in 3.3 maintenance stream.
Comment 40 Chris Goldthorpe CLA 2007-07-16 11:50:28 EDT
Fixed in HEAD also (using the patch from comment #33).