public abstract class AbstractCombo
extends org.eclipse.swt.widgets.Composite
Text
, a
Button
and a popup associated to the button.
The creation of text, button and popup content is delegated to abstract methods.
Note that although this class is a subclass of Composite
,
it does not make sense to add children to it, or set a layout on it.
Modifier and Type | Field and Description |
---|---|
(package private) org.eclipse.swt.widgets.Shell |
_shell
The parent Shell
|
protected org.eclipse.swt.widgets.Button |
button
Button opening the popup
|
protected boolean |
createOnDrop
Flag indicating that the popup content must be created each time the combo is dropped
|
protected org.eclipse.swt.widgets.Listener |
filter
Listener for external events
|
static boolean |
GTK
GTK platform constant
|
protected boolean |
hasFocus
Flag indicating if the widget has focus or not
|
protected org.eclipse.swt.widgets.Listener |
listener
Listener for all internal events
|
protected org.eclipse.swt.widgets.Shell |
popup
Popup shell for the selection
|
protected org.eclipse.swt.widgets.Control |
popupContent
Content of the popup
|
protected boolean |
showButtonOnFocus
Flag to show button only if combo has the focus
|
protected org.eclipse.swt.widgets.Text |
text
Text widget for the input
|
static boolean |
WIN32
WIN32 platform constant
|
Constructor and Description |
---|
AbstractCombo(org.eclipse.swt.widgets.Composite parent,
int style)
Constructs a new instance of this class given its parent
and a style value describing its behavior and appearance.
|
Modifier and Type | Method and Description |
---|---|
void |
addModifyListener(org.eclipse.swt.events.ModifyListener listener)
Adds the listener to the collection of listeners who will
be notified when the receiver's text is modified, by sending
it one of the messages defined in the
ModifyListener
interface. |
void |
addSelectionListener(org.eclipse.swt.events.SelectionListener listener)
Adds the listener to the collection of listeners who will
be notified when the receiver's selection changes, by sending
it one of the messages defined in the
SelectionListener
interface. |
void |
addVerifyListener(org.eclipse.swt.events.VerifyListener listener)
Adds the listener to the collection of listeners who will
be notified when the receiver's text is verified, by sending
it one of the messages defined in the
VerifyListener
interface. |
protected void |
beforeDrop()
Called just before the popup is dropped.
|
protected void |
buttonEvent(org.eclipse.swt.widgets.Event event)
Manages button events.
|
(package private) static int |
checkStyle(int style) |
protected void |
comboEvent(org.eclipse.swt.widgets.Event event)
Manages global combo events.
|
protected void |
contentEvent(org.eclipse.swt.widgets.Event event)
Manages popup content events.
|
void |
copy()
Copies the selected text.
|
protected org.eclipse.swt.widgets.Button |
createButtonControl(int style)
Creates the arrow button widget.
|
protected void |
createPopup()
Creates the popup that will be displayed when the button is selected.
|
protected abstract org.eclipse.swt.widgets.Control |
createPopupContent(org.eclipse.swt.widgets.Composite parent)
Creates the popup content.
|
protected org.eclipse.swt.widgets.Text |
createTextControl(int style)
Creates the text widget.
|
void |
cut()
Cuts the selected text.
|
protected abstract boolean |
doSelection()
This method is called when a SWT.Selection is notify in the popup content,
allowing to update the Text widget content.
|
protected void |
dropDown(boolean drop)
Manages drop down of the popup.
|
boolean |
getEditable()
Gets the editable state.
|
boolean |
getPopupVisible()
Returns
true if the receiver's popup is visible,
and false otherwise. |
org.eclipse.swt.graphics.Point |
getSelection()
Returns a
Point whose x coordinate is the start of the
selection in the receiver's text field, and whose y coordinate is the end
of the selection. |
org.eclipse.swt.widgets.Shell |
getShell() |
int |
getStyle()
Returns the receiver's style information.
|
java.lang.String |
getText()
Returns a string containing a copy of the contents of the receiver's text
field.
|
int |
getTextHeight()
Returns the height of the receivers's text field.
|
int |
getTextLimit()
Returns the maximum number of characters that the receiver's
text field is capable of holding.
|
protected void |
handleFocus(int type)
Manages the focus on the combo.
|
protected boolean |
isDropped()
Returns
true if popup is dropped (visible), else false . |
boolean |
isFocusControl()
Returns
true if the receiver has the user-interface focus,
and false otherwise. |
boolean |
isShowButtonOnFocus()
Returns
true if button is displayed only when the combo has
has focus and false otherwise. |
void |
paste()
Pastes text from clipboard.
|
protected void |
popupEvent(org.eclipse.swt.widgets.Event event)
Manages popup shell events.
|
void |
redraw()
Causes the entire bounds of the receiver to be marked as needing to be
redrawn.
|
void |
redraw(int x,
int y,
int width,
int height,
boolean all)
Causes the rectangular area of the receiver specified by the arguments to
be marked as needing to be redrawn.
|
void |
removeModifyListener(org.eclipse.swt.events.ModifyListener listener)
Removes the listener from the collection of listeners who will
be notified when the receiver's text is modified.
|
void |
removeSelectionListener(org.eclipse.swt.events.SelectionListener listener)
Removes the listener from the collection of listeners who will
be notified when the receiver's selection changes.
|
void |
removeVerifyListener(org.eclipse.swt.events.VerifyListener listener)
Removes the listener from the collection of listeners who will
be notified when the control is verified.
|
void |
selectAll()
Selects all the text in the receiver.
|
void |
setBackground(org.eclipse.swt.graphics.Color color)
Sets the receiver's background color to the color specified by the
argument, or to the default system color for the control if the argument
is null.
|
protected void |
setCreateOnDrop(boolean createOnDrop)
Sets the flag indicating if the popup content must be created each time
the combo is dropped.
|
void |
setEditable(boolean editable)
Sets the editable state.
|
void |
setEnabled(boolean enabled)
Enables the receiver if the argument is
true , and disables it
otherwise. |
boolean |
setFocus()
Causes the receiver to have the keyboard focus, such that all keyboard
events will be delivered to it.
|
void |
setFont(org.eclipse.swt.graphics.Font font)
Sets the font that the receiver will use to paint textual information to
the font specified by the argument, or to the default font for that kind
of control if the argument is null.
|
void |
setForeground(org.eclipse.swt.graphics.Color color)
Sets the receiver's foreground color to the color specified by the
argument, or to the default system color for the control if the argument
is null.
|
void |
setLayout(org.eclipse.swt.widgets.Layout layout)
Sets the layout which is associated with the receiver to be
the argument which may be null.
|
void |
setMenu(org.eclipse.swt.widgets.Menu menu)
Sets the receiver's pop up menu to the argument.
|
protected void |
setPopupLocation()
Calculates and returns the location of popup.
Called just before than the popup is dropped. |
void |
setSelection(org.eclipse.swt.graphics.Point selection)
Sets the selection in the receiver's text field to the
range specified by the argument whose x coordinate is the
start of the selection and whose y coordinate is the end
of the selection.
|
void |
setShowButtonOnFocus(boolean showButtonOnFocus)
Sets the flag indicating if the button must be shown only if the combo
has the focus (
true ). |
void |
setTextLimit(int limit)
Sets the maximum number of characters that the receiver's
text field is capable of holding to be the argument.
|
void |
setToolTipText(java.lang.String string)
Sets the receiver's tool tip text to the argument, which may be null
indicating that no tool tip text should be shown.
|
void |
setVisible(boolean visible)
Marks the receiver as visible if the argument is
true , and
marks it invisible otherwise. |
protected void |
textEvent(org.eclipse.swt.widgets.Event event)
Manages text widget events.
|
protected void |
updateButtonDisplay()
Updates the visibility of the button in function of the flag and the focus.
|
changed, checkSubclass, drawBackground, getBackgroundMode, getChildren, getLayout, getLayoutDeferred, getTabList, isLayoutDeferred, layout, layout, layout, layout, layout, setBackgroundMode, setLayoutDeferred, setTabList
computeTrim, getClientArea, getHorizontalBar, getScrollbarsMode, getVerticalBar
addControlListener, addDragDetectListener, addFocusListener, addGestureListener, addHelpListener, addKeyListener, addMenuDetectListener, addMouseListener, addMouseMoveListener, addMouseTrackListener, addMouseWheelListener, addPaintListener, addTouchListener, addTraverseListener, computeSize, computeSize, dragDetect, dragDetect, forceFocus, getAccessible, getBackground, getBackgroundImage, getBorderWidth, getBounds, getCursor, getDragDetect, getEnabled, getFont, getForeground, getLayoutData, getLocation, getMenu, getMonitor, getOrientation, getParent, getRegion, getSize, getTextDirection, getToolTipText, getTouchEnabled, getVisible, internal_dispose_GC, internal_new_GC, isEnabled, isReparentable, isVisible, moveAbove, moveBelow, pack, pack, print, removeControlListener, removeDragDetectListener, removeFocusListener, removeGestureListener, removeHelpListener, removeKeyListener, removeMenuDetectListener, removeMouseListener, removeMouseMoveListener, removeMouseTrackListener, removeMouseWheelListener, removePaintListener, removeTouchListener, removeTraverseListener, requestLayout, setBackgroundImage, setBounds, setBounds, setCapture, setCursor, setDragDetect, setLayoutData, setLocation, setLocation, setOrientation, setParent, setRedraw, setRegion, setSize, setSize, setTextDirection, setTouchEnabled, toControl, toControl, toDisplay, toDisplay, traverse, traverse, traverse, update
addDisposeListener, addListener, checkWidget, dispose, getData, getData, getDisplay, getListeners, isAutoDirection, isDisposed, isListening, notifyListeners, removeDisposeListener, removeListener, removeListener, reskin, setData, setData, toString
public static final boolean GTK
public static final boolean WIN32
org.eclipse.swt.widgets.Shell _shell
protected org.eclipse.swt.widgets.Text text
protected org.eclipse.swt.widgets.Shell popup
protected org.eclipse.swt.widgets.Button button
protected org.eclipse.swt.widgets.Control popupContent
protected org.eclipse.swt.widgets.Listener listener
protected org.eclipse.swt.widgets.Listener filter
protected boolean hasFocus
protected boolean showButtonOnFocus
protected boolean createOnDrop
public AbstractCombo(org.eclipse.swt.widgets.Composite parent, int style)
parent
- a widget which will be the parent of the new instance (cannot be null)style
- the style of widget to constructstatic int checkStyle(int style)
public void addModifyListener(org.eclipse.swt.events.ModifyListener listener)
ModifyListener
interface.listener
- the listener which should be notifiedjava.lang.IllegalArgumentException
- org.eclipse.swt.SWTException
- ModifyListener
,
removeModifyListener(org.eclipse.swt.events.ModifyListener)
public void addSelectionListener(org.eclipse.swt.events.SelectionListener listener)
SelectionListener
interface.
widgetSelected
is called when the combo's list selection changes.
widgetDefaultSelected
is typically called when ENTER is pressed the combo's text area.
listener
- the listener which should be notifiedjava.lang.IllegalArgumentException
- org.eclipse.swt.SWTException
- SelectionListener
,
removeSelectionListener(org.eclipse.swt.events.SelectionListener)
,
SelectionEvent
public void addVerifyListener(org.eclipse.swt.events.VerifyListener listener)
VerifyListener
interface.listener
- the listener which should be notifiedjava.lang.IllegalArgumentException
- org.eclipse.swt.SWTException
- VerifyListener
,
removeVerifyListener(org.eclipse.swt.events.VerifyListener)
protected void beforeDrop()
By default, do nothing.
protected void buttonEvent(org.eclipse.swt.widgets.Event event)
event
- eventprotected void comboEvent(org.eclipse.swt.widgets.Event event)
event
- eventprotected void contentEvent(org.eclipse.swt.widgets.Event event)
event
- eventpublic void copy()
The current selection is copied to the clipboard.
org.eclipse.swt.SWTException
- protected org.eclipse.swt.widgets.Button createButtonControl(int style)
style
- button styleprotected void createPopup()
protected abstract org.eclipse.swt.widgets.Control createPopupContent(org.eclipse.swt.widgets.Composite parent)
List
, a Table
or every other
control.popupContent
attribute must be set with the created
control. The parent must be the shell
attribute, that is
initialized by default with a FillLayout
.parent
- The parent Composite that will contain the controlprotected org.eclipse.swt.widgets.Text createTextControl(int style)
style
- text stylepublic void cut()
The current selection is first copied to the clipboard and then deleted from the widget.
org.eclipse.swt.SWTException
- protected abstract boolean doSelection()
protected void dropDown(boolean drop)
drop
- true
to drop the popup, false
to closepublic boolean getEditable()
org.eclipse.swt.SWTException
- public boolean getPopupVisible()
true
if the receiver's popup is visible,
and false
otherwise.
If one of the receiver's ancestors is not visible or some other condition makes the receiver not visible, this method may still indicate that it is considered visible even though it may not actually be showing.
org.eclipse.swt.SWTException
- public org.eclipse.swt.graphics.Point getSelection()
Point
whose x coordinate is the start of the
selection in the receiver's text field, and whose y coordinate is the end
of the selection. The returned values are zero-relative. An "empty"
selection as indicated by the the x and y coordinates having the same
value.org.eclipse.swt.SWTException
- public org.eclipse.swt.widgets.Shell getShell()
getShell
in class org.eclipse.swt.widgets.Control
public int getStyle()
getStyle
in class org.eclipse.swt.widgets.Widget
Widget.getStyle()
public java.lang.String getText()
public int getTextHeight()
org.eclipse.swt.SWTException
- public int getTextLimit()
setTextLimit()
, it will be the constant
Combo.LIMIT
.org.eclipse.swt.SWTException
- protected void handleFocus(int type)
type
- SWT.FocusIn or SWT.FocusOutprotected boolean isDropped()
true
if popup is dropped (visible), else false
.public boolean isFocusControl()
true
if the receiver has the user-interface focus,
and false
otherwise.isFocusControl
in class org.eclipse.swt.widgets.Control
Control.isFocusControl()
public boolean isShowButtonOnFocus()
true
if button is displayed only when the combo has
has focus and false
otherwise.public void paste()
The selected text is deleted from the widget and new text inserted from the clipboard.
org.eclipse.swt.SWTException
- protected void popupEvent(org.eclipse.swt.widgets.Event event)
event
- eventpublic void redraw()
redraw
in class org.eclipse.swt.widgets.Control
public void redraw(int x, int y, int width, int height, boolean all)
redraw
in class org.eclipse.swt.widgets.Control
x
- y
- width
- height
- all
- public void removeModifyListener(org.eclipse.swt.events.ModifyListener listener)
listener
- the listener which should no longer be notifiedjava.lang.IllegalArgumentException
- org.eclipse.swt.SWTException
- ModifyListener
,
addModifyListener(org.eclipse.swt.events.ModifyListener)
public void removeSelectionListener(org.eclipse.swt.events.SelectionListener listener)
listener
- the listener which should no longer be notifiedjava.lang.IllegalArgumentException
- org.eclipse.swt.SWTException
- SelectionListener
,
addSelectionListener(org.eclipse.swt.events.SelectionListener)
public void removeVerifyListener(org.eclipse.swt.events.VerifyListener listener)
listener
- the listener which should no longer be notifiedjava.lang.IllegalArgumentException
- org.eclipse.swt.SWTException
- VerifyListener
,
addVerifyListener(org.eclipse.swt.events.VerifyListener)
public void selectAll()
org.eclipse.swt.SWTException
- public void setBackground(org.eclipse.swt.graphics.Color color)
setBackground
in class org.eclipse.swt.widgets.Control
Control.setBackground(org.eclipse.swt.graphics.Color)
protected void setCreateOnDrop(boolean createOnDrop)
createOnDrop
- true if popup is recreated at each drop, else falsepublic void setEditable(boolean editable)
editable
- the new editable statepublic void setEnabled(boolean enabled)
true
, and disables it
otherwise.setEnabled
in class org.eclipse.swt.widgets.Control
Control.setEnabled(boolean)
public boolean setFocus()
setFocus
in class org.eclipse.swt.widgets.Composite
Control.setFocus()
public void setFont(org.eclipse.swt.graphics.Font font)
setFont
in class org.eclipse.swt.widgets.Control
Control.setFont(org.eclipse.swt.graphics.Font)
public void setForeground(org.eclipse.swt.graphics.Color color)
setForeground
in class org.eclipse.swt.widgets.Control
Control.setForeground(org.eclipse.swt.graphics.Color)
public void setLayout(org.eclipse.swt.widgets.Layout layout)
Note : No Layout can be set on this Control because it already manages the size and position of its children.
setLayout
in class org.eclipse.swt.widgets.Composite
layout
- the receiver's new layout or nullpublic void setMenu(org.eclipse.swt.widgets.Menu menu)
setMenu
in class org.eclipse.swt.widgets.Control
menu
- the new pop up menuprotected void setPopupLocation()
public void setSelection(org.eclipse.swt.graphics.Point selection)
selection
- a point representing the new selection start and endpublic void setShowButtonOnFocus(boolean showButtonOnFocus)
true
).showButtonOnFocus
- true if button must be shown on focus only
public void setTextLimit(int limit)
limit
- new text limitjava.lang.IllegalArgumentException
- org.eclipse.swt.SWTException
- public void setToolTipText(java.lang.String string)
setToolTipText
in class org.eclipse.swt.widgets.Control
string
- the new tool tip text (or null)public void setVisible(boolean visible)
true
, and
marks it invisible otherwise.setVisible
in class org.eclipse.swt.widgets.Control
Control.setVisible(boolean)
protected void textEvent(org.eclipse.swt.widgets.Event event)
event
- eventprotected void updateButtonDisplay()