Class CTreeCombo
- All Implemented Interfaces:
org.eclipse.swt.graphics.Drawable
public class CTreeCombo
extends org.eclipse.swt.widgets.Composite
-
Field Summary
Fields Modifier and Type Field Description (package private) org.eclipse.swt.widgets.Button
arrow
(package private) org.eclipse.swt.graphics.Color
background
(package private) java.util.List<CTreeComboColumn>
columns
(package private) org.eclipse.swt.widgets.Listener
filter
(package private) org.eclipse.swt.graphics.Font
font
(package private) org.eclipse.swt.graphics.Color
foreground
(package private) boolean
hasFocus
(package private) java.util.List<CTreeComboItem>
items
(package private) org.eclipse.swt.widgets.Listener
listener
(package private) org.eclipse.swt.widgets.Shell
popup
(package private) org.eclipse.swt.widgets.Text
text
(package private) org.eclipse.swt.widgets.Tree
tree
(package private) java.util.List<org.eclipse.swt.events.TreeListener>
treeListeners
(package private) int
visibleItemCount
-
Constructor Summary
Constructors Constructor Description CTreeCombo(org.eclipse.swt.widgets.Composite parent, int style)
The CTreeCombo class represents a selectable user interface object that combines a text field and a tree and issues notification when an item is selected from the tree. -
Method Summary
Modifier and Type Method Description (package private) char
_findMnemonic(java.lang.String string)
void
addSelectionListener(org.eclipse.swt.events.SelectionListener listener)
Adds the listener to the collection of listeners who will be notified when the user changes the receiver's selection, by sending it one of the messages defined in theSelectionListener
interface.void
addTreeListener(org.eclipse.swt.events.TreeListener listener)
Adds the listener to the collection of listeners who will be notified when an item in the receiver is expanded or collapsed by sending it one of the messages defined in theTreeListener
interface.(package private) void
arrowEvent(org.eclipse.swt.widgets.Event event)
(package private) static int
checkStyle(int style)
void
clear(int index, boolean all)
Clears the item at the given zero-relative index in the receiver.void
clearAll(boolean all)
Clears all the items in the receiver.(package private) void
comboEvent(org.eclipse.swt.widgets.Event event)
org.eclipse.swt.graphics.Point
computeSize(int wHint, int hHint, boolean changed)
(package private) void
createPopup(java.util.Collection<CTreeComboItem> items, CTreeComboItem selectedItem)
void
deselectAll()
Deselects all selected items in the receiver.(package private) void
dropDown(boolean drop)
(package private) org.eclipse.swt.widgets.Label
getAssociatedLabel()
CTreeComboColumn
getColumn(int columnIndex)
Returns the column at the given, zero-relative index in the receiver.int
getColumnCount()
Returns the number of columns contained in the receiver.int[]
getColumnOrder()
Returns an array of zero-relative integers that map the creation order of the receiver's items to the order in which they are currently being displayed.boolean
getEditable()
Gets the editable state.CTreeComboItem
getItem(int index)
Returns the item at the given, zero-relative index in the receiver.CTreeComboItem
getItem(org.eclipse.swt.graphics.Point p)
Returns the item at the given point in the receiver or null if no such item exists.int
getItemCount()
Returns the number of items contained in the receiver that are direct item children of the receiver.CTreeComboItem[]
getItems()
Returns a (possibly empty) array of items contained in the receiver that are direct item children of the receiver.CTreeComboItem[]
getSelection()
Returns an array ofCTreeComboItem
s that are currently selected in the receiver.java.lang.String
getText()
Returns a string containing a copy of the contents of the receiver's text field.(package private) void
handleFocus(int type)
int
indexOf(CTreeComboItem item)
Searches the receiver's list starting at the first column (index 0) until a column is found that is equal to the argument, and returns the index of that column.(package private) void
initAccessible()
(package private) void
internalLayout(boolean changed)
(package private) boolean
isDropped()
(package private) void
popupEvent(org.eclipse.swt.widgets.Event event)
void
removeAll()
Removes all of the items from the receiver.void
removeSelectionListener(org.eclipse.swt.events.SelectionListener listener)
Removes the listener from the collection of listeners who will be notified when the user changes the receiver's selection.void
removeTreeListener(org.eclipse.swt.events.TreeListener listener)
Removes the listener from the collection of listeners who will be notified when items in the receiver are expanded or collapsed.void
select(CTreeComboItem item)
Selects an item in the receiver.void
setItemCount(int count)
Sets the number of root-level items contained in the receiver.void
setSelection(CTreeComboItem[] newItems)
Sets the receiver's selection to be the given array of items.void
showItem(CTreeComboItem item)
Shows the item.(package private) java.lang.String
stripMnemonic(java.lang.String string)
(package private) void
textEvent(org.eclipse.swt.widgets.Event event)
(package private) void
treeEvent(org.eclipse.swt.widgets.Event event)
Methods inherited from class org.eclipse.swt.widgets.Composite
changed, checkSubclass, drawBackground, getBackgroundMode, getChildren, getLayout, getLayoutDeferred, getTabList, isLayoutDeferred, layout, layout, layout, layout, layout, setBackgroundMode, setFocus, setLayout, setLayoutDeferred, setTabList, toString
Methods inherited from class org.eclipse.swt.widgets.Scrollable
computeTrim, getClientArea, getHorizontalBar, getScrollbarsMode, getVerticalBar
Methods inherited from class org.eclipse.swt.widgets.Control
addControlListener, addDragDetectListener, addFocusListener, addGestureListener, addHelpListener, addKeyListener, addMenuDetectListener, addMouseListener, addMouseMoveListener, addMouseTrackListener, addMouseWheelListener, addPaintListener, addTouchListener, addTraverseListener, computeSize, dragDetect, dragDetect, forceFocus, getAccessible, getBackground, getBackgroundImage, getBorderWidth, getBounds, getCursor, getDragDetect, getEnabled, getFont, getForeground, getLayoutData, getLocation, getMenu, getMonitor, getOrientation, getParent, getRegion, getShell, getSize, getTextDirection, getToolTipText, getTouchEnabled, getVisible, internal_dispose_GC, internal_new_GC, isEnabled, isFocusControl, isReparentable, isVisible, moveAbove, moveBelow, pack, pack, print, redraw, redraw, removeControlListener, removeDragDetectListener, removeFocusListener, removeGestureListener, removeHelpListener, removeKeyListener, removeMenuDetectListener, removeMouseListener, removeMouseMoveListener, removeMouseTrackListener, removeMouseWheelListener, removePaintListener, removeTouchListener, removeTraverseListener, requestLayout, setBackground, setBackgroundImage, setBounds, setBounds, setCapture, setCursor, setDragDetect, setEnabled, setFont, setForeground, setLayoutData, setLocation, setLocation, setMenu, setOrientation, setParent, setRedraw, setRegion, setSize, setSize, setTextDirection, setToolTipText, setTouchEnabled, setVisible, toControl, toControl, toDisplay, toDisplay, traverse, traverse, traverse, update
Methods inherited from class org.eclipse.swt.widgets.Widget
addDisposeListener, addListener, checkWidget, dispose, getData, getData, getDisplay, getListeners, getStyle, isAutoDirection, isDisposed, isListening, notifyListeners, removeDisposeListener, removeListener, removeListener, reskin, setData, setData
-
Field Details
-
text
org.eclipse.swt.widgets.Text text -
tree
org.eclipse.swt.widgets.Tree tree -
arrow
org.eclipse.swt.widgets.Button arrow -
listener
org.eclipse.swt.widgets.Listener listener -
filter
org.eclipse.swt.widgets.Listener filter -
popup
org.eclipse.swt.widgets.Shell popup -
hasFocus
boolean hasFocus -
visibleItemCount
int visibleItemCount -
foreground
org.eclipse.swt.graphics.Color foreground -
background
org.eclipse.swt.graphics.Color background -
font
org.eclipse.swt.graphics.Font font -
items
java.util.List<CTreeComboItem> items -
columns
java.util.List<CTreeComboColumn> columns -
treeListeners
java.util.List<org.eclipse.swt.events.TreeListener> treeListeners
-
-
Constructor Details
-
CTreeCombo
public CTreeCombo(org.eclipse.swt.widgets.Composite parent, int style)The CTreeCombo class represents a selectable user interface object that combines a text field and a tree and issues notification when an item is selected from the tree.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.- Styles:
- BORDER, READ_ONLY, FLAT
- Events:
- DefaultSelection, Modify, Selection, Verify
-
-
Method Details
-
checkStyle
static int checkStyle(int style) -
_findMnemonic
char _findMnemonic(java.lang.String string) -
addSelectionListener
public void addSelectionListener(org.eclipse.swt.events.SelectionListener listener)Adds the listener to the collection of listeners who will be notified when the user changes the receiver's selection, by sending it one of the messages defined in theSelectionListener
interface.widgetSelected
is called when the combo's list selection changes.widgetDefaultSelected
is typically called when ENTER is pressed the combo's text area.- Parameters:
listener
- the listener which should be notified when the user changes the receiver's selection- Throws:
java.lang.IllegalArgumentException
-- ERROR_NULL_ARGUMENT - if the listener is null
org.eclipse.swt.SWTException
-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
- See Also:
SelectionListener
,removeSelectionListener(org.eclipse.swt.events.SelectionListener)
,SelectionEvent
-
addTreeListener
public void addTreeListener(org.eclipse.swt.events.TreeListener listener)Adds the listener to the collection of listeners who will be notified when an item in the receiver is expanded or collapsed by sending it one of the messages defined in theTreeListener
interface.- Parameters:
listener
- the listener which should be notified- Throws:
java.lang.IllegalArgumentException
-- ERROR_NULL_ARGUMENT - if the listener is null
org.eclipse.swt.SWTException
-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
- See Also:
TreeListener
,removeTreeListener(org.eclipse.swt.events.TreeListener)
-
arrowEvent
void arrowEvent(org.eclipse.swt.widgets.Event event) -
clear
public void clear(int index, boolean all)Clears the item at the given zero-relative index in the receiver. The text, icon and other attributes of the item are set to the default value. If the tree was created with theSWT.VIRTUAL
style, these attributes are requested again as needed.- Parameters:
index
- the index of the item to clearall
-true
if all child items of the indexed item should be cleared recursively, andfalse
otherwise- Throws:
java.lang.IllegalArgumentException
-- ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)
org.eclipse.swt.SWTException
-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
- See Also:
SWT.VIRTUAL
,SWT.SetData
-
clearAll
public void clearAll(boolean all)Clears all the items in the receiver. The text, icon and other attributes of the items are set to their default values. If the tree was created with theSWT.VIRTUAL
style, these attributes are requested again as needed.- Parameters:
all
-true
if all child items should be cleared recursively, andfalse
otherwise- Throws:
org.eclipse.swt.SWTException
-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
- See Also:
SWT.VIRTUAL
,SWT.SetData
-
comboEvent
void comboEvent(org.eclipse.swt.widgets.Event event) -
computeSize
public org.eclipse.swt.graphics.Point computeSize(int wHint, int hHint, boolean changed)- Overrides:
computeSize
in classorg.eclipse.swt.widgets.Control
- See Also:
Control.computeSize(int, int, boolean)
-
createPopup
-
deselectAll
public void deselectAll()Deselects all selected items in the receiver.- Throws:
org.eclipse.swt.SWTException
-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
-
dropDown
void dropDown(boolean drop) -
getAssociatedLabel
org.eclipse.swt.widgets.Label getAssociatedLabel() -
getColumn
Returns the column at the given, zero-relative index in the receiver. Throws an exception if the index is out of range. Columns are returned in the order that they were created. If noTreeColumn
s were created by the programmer, this method will throwERROR_INVALID_RANGE
despite the fact that a single column of data may be visible in the tree. This occurs when the programmer uses the tree like a list, adding items but never creating a column.- Parameters:
index
- the index of the column to return- Returns:
- the column at the given index
- Throws:
java.lang.IllegalArgumentException
-- ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)
org.eclipse.swt.SWTException
-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
-
getColumnCount
public int getColumnCount()Returns the number of columns contained in the receiver. If noTreeColumn
s were created by the programmer, this value is zero, despite the fact that visually, one column of items may be visible. This occurs when the programmer uses the tree like a list, adding items but never creating a column.- Returns:
- the number of columns
- Throws:
org.eclipse.swt.SWTException
-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
- Since:
- 3.1
-
getColumnOrder
public int[] getColumnOrder()Returns an array of zero-relative integers that map the creation order of the receiver's items to the order in which they are currently being displayed.Specifically, the indices of the returned array represent the current visual order of the items, and the contents of the array represent the creation order of the items.
Note: This is not the actual structure used by the receiver to maintain its list of items, so modifying the array will not affect the receiver.
- Returns:
- the current visual order of the receiver's items
- Throws:
org.eclipse.swt.SWTException
-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
-
getEditable
public boolean getEditable()Gets the editable state.- Returns:
- whether or not the receiver is editable
- Throws:
org.eclipse.swt.SWTException
-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
-
getItem
Returns the item at the given, zero-relative index in the receiver. Throws an exception if the index is out of range.- Parameters:
index
- the index of the item to return- Returns:
- the item at the given index
- Throws:
java.lang.IllegalArgumentException
-- ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)
org.eclipse.swt.SWTException
-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
-
getItem
Returns the item at the given point in the receiver or null if no such item exists. The point is in the coordinate system of the receiver.The item that is returned represents an item that could be selected by the user. For example, if selection only occurs in items in the first column, then null is returned if the point is outside of the item. Note that the SWT.FULL_SELECTION style hint, which specifies the selection policy, determines the extent of the selection.
- Parameters:
point
- the point used to locate the item- Returns:
- the item at the given point, or null if the point is not in a selectable item
- Throws:
java.lang.IllegalArgumentException
-- ERROR_NULL_ARGUMENT - if the point is null
org.eclipse.swt.SWTException
-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
-
getItemCount
public int getItemCount()Returns the number of items contained in the receiver that are direct item children of the receiver. The number that is returned is the number of roots in the tree.- Returns:
- the number of items
- Throws:
org.eclipse.swt.SWTException
-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
-
getItems
Returns a (possibly empty) array of items contained in the receiver that are direct item children of the receiver. These are the roots of the tree.Note: This is not the actual structure used by the receiver to maintain its list of items, so modifying the array will not affect the receiver.
- Returns:
- the items
- Throws:
org.eclipse.swt.SWTException
-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
-
getSelection
Returns an array ofCTreeComboItem
s that are currently selected in the receiver. The order of the items is unspecified. An empty array indicates that no items are selected.
This array could not have more than 1 element (because it is a single selection)Note: This is not the actual structure used by the receiver to maintain its selection, so modifying the array will not affect the receiver.
- Returns:
- an array representing the selection
- Throws:
org.eclipse.swt.SWTException
-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
-
getText
public java.lang.String getText()Returns a string containing a copy of the contents of the receiver's text field.- Returns:
- the receiver's text
- Throws:
org.eclipse.swt.SWTException
-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
-
handleFocus
void handleFocus(int type) -
indexOf
Searches the receiver's list starting at the first column (index 0) until a column is found that is equal to the argument, and returns the index of that column. If no column is found, returns -1.- Parameters:
column
- the search column- Returns:
- the index of the column
- Throws:
java.lang.IllegalArgumentException
-- ERROR_NULL_ARGUMENT - if the column is null
org.eclipse.swt.SWTException
-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
-
initAccessible
void initAccessible() -
internalLayout
void internalLayout(boolean changed) -
isDropped
boolean isDropped() -
popupEvent
void popupEvent(org.eclipse.swt.widgets.Event event) -
removeAll
public void removeAll()Removes all of the items from the receiver.- Throws:
org.eclipse.swt.SWTException
-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
-
removeSelectionListener
public void removeSelectionListener(org.eclipse.swt.events.SelectionListener listener)Removes the listener from the collection of listeners who will be notified when the user changes the receiver's selection.- Parameters:
listener
- the listener which should no longer be notified- Throws:
java.lang.IllegalArgumentException
-- ERROR_NULL_ARGUMENT - if the listener is null
org.eclipse.swt.SWTException
-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
- See Also:
SelectionListener
,addSelectionListener(org.eclipse.swt.events.SelectionListener)
-
removeTreeListener
public void removeTreeListener(org.eclipse.swt.events.TreeListener listener)Removes the listener from the collection of listeners who will be notified when items in the receiver are expanded or collapsed.- Parameters:
listener
- the listener which should no longer be notified- Throws:
java.lang.IllegalArgumentException
-- ERROR_NULL_ARGUMENT - if the listener is null
org.eclipse.swt.SWTException
-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
- See Also:
TreeListener
,addTreeListener(org.eclipse.swt.events.TreeListener)
-
select
Selects an item in the receiver. If the item was already selected, it remains selected.- Parameters:
item
- the item to be selected- Throws:
java.lang.IllegalArgumentException
-- ERROR_NULL_ARGUMENT - if the item is null
- ERROR_INVALID_ARGUMENT - if the item has been disposed
org.eclipse.swt.SWTException
-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
-
setItemCount
public void setItemCount(int count)Sets the number of root-level items contained in the receiver.- Parameters:
count
- the number of items- Throws:
org.eclipse.swt.SWTException
-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
-
setSelection
Sets the receiver's selection to be the given array of items. The current selection is cleared before the new items are selected, and if necessary the receiver is scrolled to make the new selection visible.Items that are not in the receiver are ignored. If the receiver is single-select and multiple items are specified, then all items are ignored.
- Parameters:
items
- the array of items- Throws:
java.lang.IllegalArgumentException
-- ERROR_NULL_ARGUMENT - if the array of items is null
- ERROR_INVALID_ARGUMENT - if one of the items has been disposed
org.eclipse.swt.SWTException
-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
- See Also:
Tree.deselectAll()
-
showItem
Shows the item. If the item is already showing in the receiver, this method simply returns. Otherwise, the items are scrolled and expanded until the item is visible.- Parameters:
item
- the item to be shown- Throws:
java.lang.IllegalArgumentException
-- ERROR_NULL_ARGUMENT - if the item is null
- ERROR_INVALID_ARGUMENT - if the item has been disposed
org.eclipse.swt.SWTException
-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
- See Also:
Tree.showSelection()
-
stripMnemonic
java.lang.String stripMnemonic(java.lang.String string) -
textEvent
void textEvent(org.eclipse.swt.widgets.Event event) -
treeEvent
void treeEvent(org.eclipse.swt.widgets.Event event)
-