Package org.eclipse.jface.fieldassist
Class TextContentAdapter
java.lang.Object
org.eclipse.jface.fieldassist.TextContentAdapter
- All Implemented Interfaces:
IControlContentAdapter,IControlContentAdapter2
public class TextContentAdapter
extends Object
implements IControlContentAdapter, IControlContentAdapter2
An
IControlContentAdapter for SWT Text controls. This is a
convenience class for easily creating a ContentProposalAdapter for
text fields.- Since:
- 3.2
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetControlContents(Control control) Get the text contents of the control.intgetCursorPosition(Control control) Get the current cursor position in the control.getInsertionBounds(Control control) Get the bounds (in pixels) of the insertion point for the control content.getSelection(Control control) Get the current selection range in the control.voidinsertControlContents(Control control, String text, int cursorPosition) Insert the specified contents into the control's current contents.voidsetControlContents(Control control, String text, int cursorPosition) Set the contents of the specified control to the specified text.voidsetCursorPosition(Control control, int position) Set the current cursor position in the control.voidsetSelection(Control control, Point range) Set the current selection range in the control.
-
Constructor Details
-
TextContentAdapter
public TextContentAdapter()
-
-
Method Details
-
getControlContents
Description copied from interface:IControlContentAdapterGet the text contents of the control.- Specified by:
getControlContentsin interfaceIControlContentAdapter- Parameters:
control- the control whose contents are to be retrieved.- Returns:
- the String contents of the control.
-
setControlContents
Description copied from interface:IControlContentAdapterSet the contents of the specified control to the specified text. Must not benull.- Specified by:
setControlContentsin interfaceIControlContentAdapter- Parameters:
control- the control whose contents are to be set (replaced).text- the String specifying the new control content.cursorPosition- the zero-based index representing the desired cursor position in the control's contents after the contents are set.
-
insertControlContents
Description copied from interface:IControlContentAdapterInsert the specified contents into the control's current contents. Must not benull.- Specified by:
insertControlContentsin interfaceIControlContentAdapter- Parameters:
control- the control whose contents are to be altered.text- the String to be inserted into the control contents.cursorPosition- the zero-based index representing the desired cursor position within the inserted contents after the insertion is made.
-
getCursorPosition
Description copied from interface:IControlContentAdapterGet the current cursor position in the control. The position is specified as a zero-based index into the string. Valid ranges are from 0 to N, where N is the size of the contents string. A value of N indicates that the cursor is at the end of the contents.- Specified by:
getCursorPositionin interfaceIControlContentAdapter- Parameters:
control- the control whose position is to be retrieved.- Returns:
- the zero-based index representing the cursor position in the control's contents.
-
getInsertionBounds
Description copied from interface:IControlContentAdapterGet the bounds (in pixels) of the insertion point for the control content. This is a rectangle, in coordinates relative to the control, where the insertion point is displayed. If the implementer does not have an insertion point, or cannot determine the location of the insertion point, it is appropriate to return the bounds of the entire control. This value may be used to position a content proposal popup.- Specified by:
getInsertionBoundsin interfaceIControlContentAdapter- Parameters:
control- the control whose offset is to be retrieved.- Returns:
- the pixel width representing the distance between the edge of the control and the insertion point.
-
setCursorPosition
Description copied from interface:IControlContentAdapterSet the current cursor position in the control. The position is specified as a zero-based index into the string. Valid ranges are from 0 to N, where N is the size of the contents string. A value of N indicates that the cursor is at the end of the contents.- Specified by:
setCursorPositionin interfaceIControlContentAdapter- Parameters:
control- the control whose cursor position is to be set.position- the zero-based index representing the cursor position in the control's contents.
-
getSelection
Description copied from interface:IControlContentAdapter2Get the current selection range in the control. The x coordinate of the returned point is the position of the first selected character and the y coordinate of the returned point is the position of the last selected character. The positions are specified as a zero-based index into the string. Valid ranges are from 0 to N, where N is the size of the contents string. A value of N indicates that the last character is in the selection.- Specified by:
getSelectionin interfaceIControlContentAdapter2- Parameters:
control- the control whose position is to be retrieved.- Returns:
- a point representing the selection start and end
- Since:
- 3.4
- See Also:
-
setSelection
Description copied from interface:IControlContentAdapter2Set the current selection range in the control. The x coordinate of the provided point is the position of the first selected character and the y coordinate of the point is the position of the last selected character. The positions are specified as a zero-based index into the string. Valid ranges are from 0 to N, where N is the size of the contents string. A value of N indicates that the last character is in the selection. If the x and y coordinates are the same, then there is no selection.- Specified by:
setSelectionin interfaceIControlContentAdapter2- Parameters:
control- the control whose position is to be retrieved.range- a point representing the selection start and end- Since:
- 3.4
- See Also:
-