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 String
AUTO
Auto (contextual) Base Text Direction.static String
BTD_DEFAULT
Base Text Direction defined ingetTextDirection()
static String
LEFT_TO_RIGHT
Left-To-Right Base Text Direction.static String
RIGHT_TO_LEFT
Right-To-Left Base Text Direction.static String
VISUAL_LEFT_TO_RIGHT
Visual Left-To-Right Text Direction.static String
VISUAL_RIGHT_TO_LEFT
Visual Right-To-Left Text Direction
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
applyBidiProcessing(StyledText field, String handlingType)
Applies bidi processing to the given styled text field.static void
applyBidiProcessing(Combo combo, String handlingType)
Applies bidi processing to the given combo.static void
applyBidiProcessing(Text field, String handlingType)
Applies bidi processing to the given text field.static void
applyTextDirection(Control control, String textDirection)
Applies a Base Text Direction to the given control (and its descendants, if it's aComposite
).static boolean
getBidiSupport()
Returns whether bidi support is enabled.static SegmentListener
getSegmentListener(String handlingType)
Returns a segment listener for the givenhandlingType
that can e.g. be passed toText.addSegmentListener(SegmentListener)
.static String
getTextDirection()
Returns the Base Text Direction.static void
setBidiSupport(boolean bidi)
Enables or disables bidi support.static void
setTextDirection(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_RIGHT
RIGHT_TO_LEFT
AUTO
null
(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_RIGHT
RIGHT_TO_LEFT
AUTO
null
(no default direction)
- Parameters:
direction
- the text direction to set- Throws:
IllegalArgumentException
- ifdirection
is not legal
-
getBidiSupport
public static boolean getBidiSupport()
Returns whether bidi support is enabled.- Returns:
true
iff bidi support is enabled
-
setBidiSupport
public static void setBidiSupport(boolean bidi)
Enables or disables bidi support.- Parameters:
bidi
-true
to enable bidi support,false
to disable
-
applyBidiProcessing
public static void applyBidiProcessing(Text field, String handlingType)
Applies bidi processing to the given text field.Possible values for
handlingType
are:LEFT_TO_RIGHT
RIGHT_TO_LEFT
AUTO
BTD_DEFAULT
VISUAL_LEFT_TO_RIGHT
VISUAL_RIGHT_TO_LEFT
- the
String
constants inStructuredTextTypeHandlerFactory
- if OSGi is running, the types that have been contributed to the
org.eclipse.equinox.bidi.bidiTypes
extension point.
The 3 values
LEFT_TO_RIGHT
,RIGHT_TO_LEFT
, andAUTO
are usable whetherbidi support
is 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_DEFAULT
are 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.bidi
bundle 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
- ifhandlingType
is 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
handlingType
are:LEFT_TO_RIGHT
RIGHT_TO_LEFT
AUTO
BTD_DEFAULT
VISUAL_LEFT_TO_RIGHT
VISUAL_RIGHT_TO_LEFT
- the
String
constants inStructuredTextTypeHandlerFactory
- if OSGi is running, the types that have been contributed to the
org.eclipse.equinox.bidi.bidiTypes
extension point.
The 3 values
LEFT_TO_RIGHT
,RIGHT_TO_LEFT
, andAUTO
are usable whetherbidi support
is 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_DEFAULT
are 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.bidi
bundle is on the classpath!- Parameters:
field
- the styled text fieldhandlingType
- the type of handling- Throws:
IllegalArgumentException
- ifhandlingType
is not a known type identifier
-
applyBidiProcessing
public static void applyBidiProcessing(Combo combo, String handlingType)
Applies bidi processing to the given combo.Possible values for
handlingType
are:LEFT_TO_RIGHT
RIGHT_TO_LEFT
AUTO
BTD_DEFAULT
VISUAL_LEFT_TO_RIGHT
VISUAL_RIGHT_TO_LEFT
- the
String
constants inStructuredTextTypeHandlerFactory
- if OSGi is running, the types that have been contributed to the
org.eclipse.equinox.bidi.bidiTypes
extension point.
The 3 values
LEFT_TO_RIGHT
,RIGHT_TO_LEFT
, andAUTO
are usable whetherbidi support
is 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_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
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!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
- ifhandlingType
is not a known type identifier- Since:
- 3.10
-
getSegmentListener
public static SegmentListener getSegmentListener(String handlingType)
Returns a segment listener for the givenhandlingType
that can e.g. be passed toText.addSegmentListener(SegmentListener)
.Note: The Structured Text handling only works if the
org.eclipse.equinox.bidi
bundle is on the classpath!- Parameters:
handlingType
- the handling type as specified inapplyBidiProcessing(Text, String)
- Returns:
- the segment listener, or
null
if no handling is required - Throws:
IllegalArgumentException
- ifhandlingType
is 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
textDirection
are:The 3 values
LEFT_TO_RIGHT
,RIGHT_TO_LEFT
, andAUTO
are usable whetherbidi support
is enabled or disabled.The remaining value
BTD_DEFAULT
only has an effect if bidi support is enabled.Note: If this method is called on a control, then no
applyBidiProcessing
method 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
-
-