Bug 437485: [BiDi] Text alignment should follow the text direction for Text widget

Change-Id: Id8896a7348ab45e4de90fb8a1b5fc2cfce206ecd
Signed-off-by: Moshe WAJNBERG <wajnberg@il.ibm.com>
diff --git a/bundles/org.eclipse.jface/src/org/eclipse/jface/util/BaseTextDirectionSegmentListener.java b/bundles/org.eclipse.jface/src/org/eclipse/jface/util/BaseTextDirectionSegmentListener.java
index 993e5ea..2b78b1c 100644
--- a/bundles/org.eclipse.jface/src/org/eclipse/jface/util/BaseTextDirectionSegmentListener.java
+++ b/bundles/org.eclipse.jface/src/org/eclipse/jface/util/BaseTextDirectionSegmentListener.java
@@ -11,8 +11,10 @@
 
 package org.eclipse.jface.util;
 
+import org.eclipse.swt.SWT;
 import org.eclipse.swt.events.SegmentEvent;
 import org.eclipse.swt.events.SegmentListener;
+import org.eclipse.swt.widgets.Control;
 
 /**
  * Defines the segment listener that enforces Base Text Direction (BTD) support.
@@ -43,16 +45,25 @@
 	public void getSegments(SegmentEvent event) {
 		int length = event.lineText.length();
 		if (length > 0) {
-			event.segments = new int[2];
-			event.segments[0] = 0;
-			event.segments[1] = length;
-			event.segmentsChars = new char[2];
-			event.segmentsChars[0] = isRTLValue(event.lineText) ? BidiUtils.RLE : BidiUtils.LRE;
-			event.segmentsChars[1] = BidiUtils.PDF;				
+			boolean isRTL = isRTLValue(event.lineText);
+			if (event.widget instanceof Control && Util.isWindows()) {
+				if (isRTL) {
+					((Control) event.widget).setOrientation(SWT.RIGHT_TO_LEFT);
+				} else {
+					((Control) event.widget).setOrientation(SWT.LEFT_TO_RIGHT);
+				}
+			} else {
+				event.segments = new int[2];
+				event.segments[0] = 0;
+				event.segments[1] = length;
+				event.segmentsChars = new char[2];
+				event.segmentsChars[0] = isRTL ? BidiUtils.RLE : BidiUtils.LRE;
+				event.segmentsChars[1] = BidiUtils.PDF;
+			}
 		}
 	}
 	
-	private boolean isRTLValue(String stringValue){
+	protected boolean isRTLValue(String stringValue) {
 		if (stringValue == null || stringValue.length() == 0 || BidiUtils.LEFT_TO_RIGHT.equals(textDirection))
 			return false;