Class BidiUtils
- java.lang.Object
-
- org.eclipse.jface.util.BidiUtils
-
public final class BidiUtils extends Object
This class provides API to handle Base Text Direction (BTD) and Structured Text support for SWT Text widgets.- Since:
- 3.9
-
-
Field Summary
Fields Modifier and Type Field Description static StringAUTOAuto (contextual) Base Text Direction.static StringBTD_DEFAULTBase Text Direction defined ingetTextDirection()static StringLEFT_TO_RIGHTLeft-To-Right Base Text Direction.static StringRIGHT_TO_LEFTRight-To-Left Base Text Direction.static StringVISUAL_LEFT_TO_RIGHTVisual Left-To-Right Text Direction.static StringVISUAL_RIGHT_TO_LEFTVisual Right-To-Left Text Direction
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidapplyBidiProcessing(StyledText field, String handlingType)Applies bidi processing to the given styled text field.static voidapplyBidiProcessing(Combo combo, String handlingType)Applies bidi processing to the given combo.static voidapplyBidiProcessing(Text field, String handlingType)Applies bidi processing to the given text field.static voidapplyTextDirection(Control control, String textDirection)Applies a Base Text Direction to the given control (and its descendants, if it's aComposite).static booleangetBidiSupport()Returns whether bidi support is enabled.static SegmentListenergetSegmentListener(String handlingType)Returns a segment listener for the givenhandlingTypethat can e.g. be passed toText.addSegmentListener(SegmentListener).static StringgetTextDirection()Returns the Base Text Direction.static voidsetBidiSupport(boolean bidi)Enables or disables bidi support.static voidsetTextDirection(String direction)Sets the Base Text Direction.
-
-
-
Field Detail
-
LEFT_TO_RIGHT
public static final String LEFT_TO_RIGHT
Left-To-Right Base Text Direction.- See Also:
getTextDirection(), Constant Field Values
-
RIGHT_TO_LEFT
public static final String RIGHT_TO_LEFT
Right-To-Left Base Text Direction.- See Also:
getTextDirection(), Constant Field Values
-
AUTO
public static final String AUTO
Auto (contextual) Base Text Direction.- See Also:
getTextDirection(), Constant Field Values
-
BTD_DEFAULT
public static final String BTD_DEFAULT
Base Text Direction defined ingetTextDirection()
-
VISUAL_LEFT_TO_RIGHT
public static final String VISUAL_LEFT_TO_RIGHT
Visual Left-To-Right Text Direction.Note: This handling type is deprecated and should only be used when interfacing with legacy systems that store data in visual order.
-
VISUAL_RIGHT_TO_LEFT
public static final String VISUAL_RIGHT_TO_LEFT
Visual Right-To-Left Text DirectionNote: This handling type is deprecated and should only be used when interfacing with legacy systems that store data in visual order.
-
-
Method Detail
-
getTextDirection
public static String getTextDirection()
Returns the Base Text Direction. Possible values are:LEFT_TO_RIGHTRIGHT_TO_LEFTAUTOnull(no direction set)
- Returns:
- the base text direction
-
setTextDirection
public static void setTextDirection(String direction)
Sets the Base Text Direction. Possible values are:LEFT_TO_RIGHTRIGHT_TO_LEFTAUTOnull(no default direction)
- Parameters:
direction- the text direction to set- Throws:
IllegalArgumentException- ifdirectionis not legal
-
getBidiSupport
public static boolean getBidiSupport()
Returns whether bidi support is enabled.- Returns:
trueiff bidi support is enabled
-
setBidiSupport
public static void setBidiSupport(boolean bidi)
Enables or disables bidi support.- Parameters:
bidi-trueto enable bidi support,falseto disable
-
applyBidiProcessing
public static void applyBidiProcessing(Text field, String handlingType)
Applies bidi processing to the given text field.Possible values for
handlingTypeare:LEFT_TO_RIGHTRIGHT_TO_LEFTAUTOBTD_DEFAULTVISUAL_LEFT_TO_RIGHTVISUAL_RIGHT_TO_LEFT- the
Stringconstants inStructuredTextTypeHandlerFactory - if OSGi is running, the types that have been contributed to the
org.eclipse.equinox.bidi.bidiTypesextension point.
The 3 values
LEFT_TO_RIGHT,RIGHT_TO_LEFT, andAUTOare usable whetherbidi supportis enabled or disabled.The remaining values only have an effect if bidi support is enabled.
The 4 first values
LEFT_TO_RIGHT,RIGHT_TO_LEFT,AUTO, andBTD_DEFAULTare for Base Text Direction (BTD) handling. The remaining values are for Structured Text handling.Note: If this method is called on a text control, then
applyTextDirection(Control, String)must not be called on the same control.Note: The Structured Text handling only works if the
org.eclipse.equinox.bidibundle is on the classpath!Note:
Text.addSegmentListener(SegmentListener)is currently only implemented on Windows and GTK, so this method won't have an effect on Cocoa.- Parameters:
field- the text fieldhandlingType- the type of handling- Throws:
IllegalArgumentException- ifhandlingTypeis not a known type identifier
-
applyBidiProcessing
public static void applyBidiProcessing(StyledText field, String handlingType)
Applies bidi processing to the given styled text field.Possible values for
handlingTypeare:LEFT_TO_RIGHTRIGHT_TO_LEFTAUTOBTD_DEFAULTVISUAL_LEFT_TO_RIGHTVISUAL_RIGHT_TO_LEFT- the
Stringconstants inStructuredTextTypeHandlerFactory - if OSGi is running, the types that have been contributed to the
org.eclipse.equinox.bidi.bidiTypesextension point.
The 3 values
LEFT_TO_RIGHT,RIGHT_TO_LEFT, andAUTOare usable whetherbidi supportis enabled or disabled.The remaining values only have an effect if bidi support is enabled.
The 4 first values
LEFT_TO_RIGHT,RIGHT_TO_LEFT,AUTO, andBTD_DEFAULTare for Base Text Direction (BTD) handling. The remaining values are for Structured Text handling.Note: If this method is called on a text control, then
applyTextDirection(Control, String)must not be called on the same control.Note: The Structured Text handling only works if the
org.eclipse.equinox.bidibundle is on the classpath!- Parameters:
field- the styled text fieldhandlingType- the type of handling- Throws:
IllegalArgumentException- ifhandlingTypeis not a known type identifier
-
applyBidiProcessing
public static void applyBidiProcessing(Combo combo, String handlingType)
Applies bidi processing to the given combo.Possible values for
handlingTypeare:LEFT_TO_RIGHTRIGHT_TO_LEFTAUTOBTD_DEFAULTVISUAL_LEFT_TO_RIGHTVISUAL_RIGHT_TO_LEFT- the
Stringconstants inStructuredTextTypeHandlerFactory - if OSGi is running, the types that have been contributed to the
org.eclipse.equinox.bidi.bidiTypesextension point.
The 3 values
LEFT_TO_RIGHT,RIGHT_TO_LEFT, andAUTOare usable whetherbidi supportis enabled or disabled.The remaining values only have an effect if bidi support is enabled.
The 4 first values
LEFT_TO_RIGHT,RIGHT_TO_LEFT,AUTO, andBTD_DEFAULTare 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
applyTextDirection(Control, String)must not be called on the same control.Note: The Structured Text handling only works if the
org.eclipse.equinox.bidibundle is on the classpath!Note:
Combo.addSegmentListener(SegmentListener)is currently only implemented on Windows so this method won't have an effect on Cocoa and GTK.- Parameters:
combo- the combo fieldhandlingType- the type of handling- Throws:
IllegalArgumentException- ifhandlingTypeis not a known type identifier- Since:
- 3.10
-
getSegmentListener
public static SegmentListener getSegmentListener(String handlingType)
Returns a segment listener for the givenhandlingTypethat can e.g. be passed toText.addSegmentListener(SegmentListener).Note: The Structured Text handling only works if the
org.eclipse.equinox.bidibundle is on the classpath!- Parameters:
handlingType- the handling type as specified inapplyBidiProcessing(Text, String)- Returns:
- the segment listener, or
nullif no handling is required - Throws:
IllegalArgumentException- ifhandlingTypeis not a known type identifier- See Also:
applyBidiProcessing(Text, String)
-
applyTextDirection
public static void applyTextDirection(Control control, String textDirection)
Applies a Base Text Direction to the given control (and its descendants, if it's aComposite).Possible values for
textDirectionare:The 3 values
LEFT_TO_RIGHT,RIGHT_TO_LEFT, andAUTOare usable whetherbidi supportis enabled or disabled.The remaining value
BTD_DEFAULTonly has an effect if bidi support is enabled.Note: If this method is called on a control, then no
applyBidiProcessingmethod must be called on the same control.Note:
Control.setTextDirection(int)is currently only implemented on Windows, so the direction won't be inherited by descendants on GTK and Cocoa.- Parameters:
control- the controltextDirection- the text direction
-
-