Package org.eclipse.jface.fieldassist
Class ComboContentAdapter
java.lang.Object
org.eclipse.jface.fieldassist.ComboContentAdapter
- All Implemented Interfaces:
IControlContentAdapter
,IControlContentAdapter2
public class ComboContentAdapter
extends Object
implements IControlContentAdapter, IControlContentAdapter2
An
IControlContentAdapter
for SWT Combo controls. This is a
convenience class for easily creating a ContentProposalAdapter
for
combo fields.- Since:
- 3.2
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptiongetControlContents
(Control control) Get the text contents of the control.int
getCursorPosition
(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.void
insertControlContents
(Control control, String text, int cursorPosition) Insert the specified contents into the control's current contents.void
setControlContents
(Control control, String text, int cursorPosition) Set the contents of the specified control to the specified text.void
setCursorPosition
(Control control, int index) Set the current cursor position in the control.void
setSelection
(Control control, Point range) Set the current selection range in the control.
-
Constructor Details
-
ComboContentAdapter
public ComboContentAdapter()
-
-
Method Details
-
getControlContents
Description copied from interface:IControlContentAdapter
Get the text contents of the control.- Specified by:
getControlContents
in interfaceIControlContentAdapter
- Parameters:
control
- the control whose contents are to be retrieved.- Returns:
- the String contents of the control.
-
setControlContents
Description copied from interface:IControlContentAdapter
Set the contents of the specified control to the specified text. Must not benull
.- Specified by:
setControlContents
in 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:IControlContentAdapter
Insert the specified contents into the control's current contents. Must not benull
.- Specified by:
insertControlContents
in 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:IControlContentAdapter
Get 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:
getCursorPosition
in 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:IControlContentAdapter
Get 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:
getInsertionBounds
in 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:IControlContentAdapter
Set 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:
setCursorPosition
in interfaceIControlContentAdapter
- Parameters:
control
- the control whose cursor position is to be set.index
- the zero-based index representing the cursor position in the control's contents.
-
getSelection
Description copied from interface:IControlContentAdapter2
Get 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:
getSelection
in 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:IControlContentAdapter2
Set 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:
setSelection
in 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:
-