diff --git a/bundles/org.eclipse.jface/src/org/eclipse/jface/util/BidiUtils.java b/bundles/org.eclipse.jface/src/org/eclipse/jface/util/BidiUtils.java index 4f0bf6a..7d0a425 100644 --- a/bundles/org.eclipse.jface/src/org/eclipse/jface/util/BidiUtils.java +++ b/bundles/org.eclipse.jface/src/org/eclipse/jface/util/BidiUtils.java @@ -20,6 +20,7 @@ import org.eclipse.swt.custom.BidiSegmentListener; import org.eclipse.swt.custom.StyledText; import org.eclipse.swt.events.SegmentListener; +import org.eclipse.swt.widgets.Combo; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Text; @@ -277,16 +278,73 @@ } /** - * Returns a segment listener for the given handlingType that can e.g. be passed to - * {@link Text#addSegmentListener(SegmentListener)}. + * Applies bidi processing to the given combo * *

- * Note: The Structured Text handling only works if the org.eclipse.equinox.bidi - * bundle is on the classpath! + * Possible values for handlingType are: + *

+ *

+ * The 3 values {@link #LEFT_TO_RIGHT}, {@link #RIGHT_TO_LEFT}, and + * {@link #AUTO} are usable whether {@link #getBidiSupport() bidi support} + * is enabled or disabled. + *

+ * The remaining values only have an effect if bidi support is enabled. + *

+ * The 4 first values {@link #LEFT_TO_RIGHT}, {@link #RIGHT_TO_LEFT}, + * {@link #AUTO}, and {@link #BTD_DEFAULT} are for Base Text Direction (BTD) + * handling. The remaining values are for Structured Text handling. + *

+ * Note: If this method is called on a combo control, then + * {@link #applyTextDirection(Control, String)} must not be called on the + * same control. + *

+ * Note: The Structured Text handling only works if the + * org.eclipse.equinox.bidi bundle is on the classpath! *

* - * @param handlingType the handling type as specified in {@link #applyBidiProcessing(Text, String)} - * @return the segment listener, or null if no handling is required + *

+ * Note: + * {@link org.eclipse.swt.widgets.Combo#addSegmentListener(SegmentListener)} + * is currently only implemented on Windows so this method won't have an + * effect on Cocoa and GTK. + * + * @param combo + * the text field + * @param handlingType + * the type of handling + * @throws IllegalArgumentException + * if handlingType is not a known type identifier + */ + public static void applyBidiProcessing(Combo combo, String handlingType) { + SegmentListener listener = getSegmentListener(handlingType); + if (listener != null) { + combo.addSegmentListener(listener); + } + } + + /** + * Returns a segment listener for the given handlingType that + * can e.g. be passed to {@link Text#addSegmentListener(SegmentListener)}. + * + *

+ * Note: The Structured Text handling only works if the + * org.eclipse.equinox.bidi bundle is on the classpath! + *

+ * + * @param handlingType + * the handling type as specified in + * {@link #applyBidiProcessing(Text, String)} + * @return the segment listener, or null if no handling is + * required * @throws IllegalArgumentException * if handlingType is not a known type identifier * @see #applyBidiProcessing(Text, String)