com.ibm.commons.swt.controls
Class CTreeCombo

java.lang.Object
  extended by org.eclipse.swt.widgets.Widget
      extended by org.eclipse.swt.widgets.Control
          extended by org.eclipse.swt.widgets.Scrollable
              extended by org.eclipse.swt.widgets.Composite
                  extended by com.ibm.commons.swt.controls.CTreeCombo
All Implemented Interfaces:
ICustomControl, org.eclipse.swt.graphics.Drawable
Direct Known Subclasses:
DCTreeComboBox

public class CTreeCombo
extends org.eclipse.swt.widgets.Composite
implements ICustomControl

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, FLAT
Events:
Selection


Nested Class Summary
static interface CTreeCombo.IPathSerializer
          An interface that is used internally by the tree control to serialize the path to the item that was selected within the tree.
 
Field Summary
 
Fields inherited from class org.eclipse.swt.widgets.Control
handle
 
Constructor Summary
CTreeCombo(org.eclipse.swt.widgets.Composite parent, int style, java.lang.String id)
          Constructs a new instance of this class given its parent and a style value describing its behavior and appearance.
 
Method Summary
 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 addTreeFilter(org.eclipse.jface.viewers.ViewerFilter filter)
          Adds a filter to the tree control.
 org.eclipse.swt.graphics.Point computeSize(int wHint, int hHint, boolean changed)
           
 void expandTreeToLevel(int level)
           
 org.eclipse.swt.widgets.Control[] getChildren()
           
 int getCols()
          Returns the width of the widget in columns.
 boolean getEditable()
          Gets the editable state.
 java.lang.String getId()
          Returns a string identifier associated with the current widget/control
 org.eclipse.jface.viewers.ILabelProvider getLabelProvider()
           
 CTreeCombo.IPathSerializer getPathSerializer()
           
 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.
 int getStyle()
           
 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.
 org.eclipse.jface.viewers.ITreeContentProvider getTreeContentProvider()
           
 int getVisibleItemCount()
          Gets the number of items that are visible in the drop down portion of the receiver's list.
 boolean isFocusControl()
           
 void redraw()
           
 void redraw(int x, int y, int width, int height, boolean all)
           
 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 removeTreeFilter(org.eclipse.jface.viewers.ViewerFilter filter)
          Removes the provided filter from the tree control.
 void setBackground(org.eclipse.swt.graphics.Color color)
           
 void setCols(int cols)
          Sets the width of the widget in columns.
 void setEditable(boolean editable)
          Sets the editable state.
 void setEnabled(boolean enabled)
           
 boolean setFocus()
           
 void setFont(org.eclipse.swt.graphics.Font font)
           
 void setForeground(org.eclipse.swt.graphics.Color color)
           
 void setId(java.lang.String id)
          Sets a string identifier on the current widget/control.
 void setLabelProvider(org.eclipse.jface.viewers.ILabelProvider labelProvider)
           
 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 setPathSerializer(CTreeCombo.IPathSerializer pathSerializer)
           
 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 setText(java.lang.String string)
          Sets the contents of the receiver's text field to the given string.
 void setText(java.lang.String string, boolean setCaretToEnd)
          Sets the contents of the receiver's text field to the given string.
 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)
           
 void setTreeContent(org.eclipse.jface.viewers.ITreeContentProvider treeContent)
          Sets a content provider for the tree control part of the widget.
 void setTreeInput(java.lang.Object treeInput)
          The TreeViewer invokes inputChanged on the content provider and then the inputChanged hook method.
 void setVisible(boolean visible)
           
 void setVisibleItemCount(int count)
          Sets the number of items that are visible in the drop down portion of the receiver's list.
 
Methods inherited from class org.eclipse.swt.widgets.Composite
changed, checkSubclass, drawBackground, getBackgroundMode, getLayout, getLayoutDeferred, getTabList, isLayoutDeferred, layout, layout, layout, layout, layout, setBackgroundMode, setLayoutDeferred, setTabList
 
Methods inherited from class org.eclipse.swt.widgets.Scrollable
computeTrim, getBorderWidth, getClientArea, getHorizontalBar, getVerticalBar
 
Methods inherited from class org.eclipse.swt.widgets.Control
addControlListener, addDragDetectListener, addFocusListener, addHelpListener, addKeyListener, addMenuDetectListener, addMouseListener, addMouseMoveListener, addMouseTrackListener, addMouseWheelListener, addPaintListener, addTraverseListener, computeSize, dragDetect, dragDetect, forceFocus, getAccessible, getBackground, getBackgroundImage, getBounds, getCursor, getDragDetect, getEnabled, getFont, getForeground, getLayoutData, getLocation, getMenu, getMonitor, getParent, getRegion, getShell, getSize, getToolTipText, getVisible, internal_dispose_GC, internal_new_GC, isEnabled, isReparentable, isVisible, moveAbove, moveBelow, pack, pack, print, removeControlListener, removeDragDetectListener, removeFocusListener, removeHelpListener, removeKeyListener, removeMenuDetectListener, removeMouseListener, removeMouseMoveListener, removeMouseTrackListener, removeMouseWheelListener, removePaintListener, removeTraverseListener, setBackgroundImage, setBounds, setBounds, setCapture, setCursor, setDragDetect, setLayoutData, setLocation, setLocation, setMenu, setParent, setRedraw, setRegion, setSize, setSize, 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, isDisposed, isListening, notifyListeners, removeDisposeListener, removeListener, removeListener, reskin, setData, setData, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CTreeCombo

public CTreeCombo(org.eclipse.swt.widgets.Composite parent,
                  int style,
                  java.lang.String id)
Constructs a new instance of this class given its parent and a style value describing its behavior and appearance.

The style value is either one of the style constants defined in class SWT which is applicable to instances of this class, or must be built by bitwise OR'ing together (that is, using the int "|" operator) two or more of those SWT style constants. The class description lists the style constants that are applicable to the class. Style bits are also inherited from superclasses.

Parameters:
parent - a widget which will be the parent of the new instance (cannot be null)
style - the style of widget to construct
id - a String value that can be used to identify the widget at a later point
Throws:
java.lang.IllegalArgumentException -
  • ERROR_NULL_ARGUMENT - if the parent is null
org.eclipse.swt.SWTException -
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent
See Also:
SWT.BORDER, SWT.READ_ONLY, SWT.FLAT, Widget.getStyle()
Method Detail

getId

public java.lang.String getId()
Description copied from interface: ICustomControl
Returns a string identifier associated with the current widget/control

Specified by:
getId in interface ICustomControl
Returns:
String

setId

public void setId(java.lang.String id)
Description copied from interface: ICustomControl
Sets a string identifier on the current widget/control.

Specified by:
setId in interface ICustomControl

getCols

public int getCols()
Returns the width of the widget in columns. A column is defined as the average width of a character as defined by SWT's FontMetrics class.

Returns:
An int value representing the column width of this control
See Also:
org.eclipse.swt.graphics.FontMetrics}

setCols

public void setCols(int cols)
Sets the width of the widget in columns. A column is defined as the average width of a character as defined by SWT's FontMetrics class.

Parameters:
numberOfCols - An int value, representing the number of columns
See Also:
org.eclipse.swt.graphics.FontMetrics}

setTreeContent

public void setTreeContent(org.eclipse.jface.viewers.ITreeContentProvider treeContent)
Sets a content provider for the tree control part of the widget. The content provider is responsible for populating the tree when revealed.

Parameters:
treeContent - an instance of ITreeContentProvider that will be queried for elements by the tree control
See Also:
org.eclipse.jface.viewers.ITreeContentProvider}

setTreeInput

public void setTreeInput(java.lang.Object treeInput)
The TreeViewer invokes inputChanged on the content provider and then the inputChanged hook method. This method fails if this viewer does not have a content provider.

Parameters:
treeInput -

addTreeFilter

public void addTreeFilter(org.eclipse.jface.viewers.ViewerFilter filter)
Adds a filter to the tree control. The tree will be filtered in accordance with the criteria defined in the filter supplied.

Parameters:
filter - a viewer filter that will be added to the tree control.

removeTreeFilter

public void removeTreeFilter(org.eclipse.jface.viewers.ViewerFilter filter)
Removes the provided filter from the tree control.

Parameters:
filter -

getLabelProvider

public org.eclipse.jface.viewers.ILabelProvider getLabelProvider()

setLabelProvider

public void setLabelProvider(org.eclipse.jface.viewers.ILabelProvider labelProvider)

getPathSerializer

public CTreeCombo.IPathSerializer getPathSerializer()

setPathSerializer

public void setPathSerializer(CTreeCombo.IPathSerializer pathSerializer)

addModifyListener

public 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.

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:
ModifyListener, removeModifyListener(org.eclipse.swt.events.ModifyListener)

computeSize

public org.eclipse.swt.graphics.Point computeSize(int wHint,
                                                  int hHint,
                                                  boolean changed)
Overrides:
computeSize in class org.eclipse.swt.widgets.Composite

getChildren

public org.eclipse.swt.widgets.Control[] getChildren()
Overrides:
getChildren in class org.eclipse.swt.widgets.Composite

getEditable

public boolean getEditable()
Gets the editable state.

Returns:
whether or not the reciever 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
Since:
3.0

getSelection

public 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. The returned values are zero-relative. An "empty" selection as indicated by the the x and y coordinates having the same value.

Returns:
a point representing the selection start and end
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

getStyle

public int getStyle()
Overrides:
getStyle in class org.eclipse.swt.widgets.Widget

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

getTextHeight

public int getTextHeight()
Returns the height of the receivers's text field.

Returns:
the text height
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

getTextLimit

public int getTextLimit()
Returns the maximum number of characters that the receiver's text field is capable of holding. If this has not been changed by setTextLimit(), it will be the constant Combo.LIMIT.

Returns:
the text limit
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

getVisibleItemCount

public int getVisibleItemCount()
Gets the number of items that are visible in the drop down portion of the receiver's list.

Returns:
the number of items that are visible
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.0

isFocusControl

public boolean isFocusControl()
Overrides:
isFocusControl in class org.eclipse.swt.widgets.Control

redraw

public void redraw()
Overrides:
redraw in class org.eclipse.swt.widgets.Control

redraw

public void redraw(int x,
                   int y,
                   int width,
                   int height,
                   boolean all)
Overrides:
redraw in class org.eclipse.swt.widgets.Control

removeModifyListener

public 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.

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:
ModifyListener, addModifyListener(org.eclipse.swt.events.ModifyListener)

setBackground

public void setBackground(org.eclipse.swt.graphics.Color color)
Overrides:
setBackground in class org.eclipse.swt.widgets.Control

setEditable

public void setEditable(boolean editable)
Sets the editable state.

Parameters:
editable - the new editable state
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.0

setEnabled

public void setEnabled(boolean enabled)
Overrides:
setEnabled in class org.eclipse.swt.widgets.Control

setFocus

public boolean setFocus()
Overrides:
setFocus in class org.eclipse.swt.widgets.Composite

setFont

public void setFont(org.eclipse.swt.graphics.Font font)
Overrides:
setFont in class org.eclipse.swt.widgets.Control

setForeground

public void setForeground(org.eclipse.swt.graphics.Color color)
Overrides:
setForeground in class org.eclipse.swt.widgets.Control

setLayout

public 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.

Note : No Layout can be set on this Control because it already manages the size and position of its children.

Overrides:
setLayout in class org.eclipse.swt.widgets.Composite
Parameters:
layout - the receiver's new layout or null
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

public 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.

Parameters:
selection - a point representing the new selection start and end
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

setText

public void setText(java.lang.String string)
Sets the contents of the receiver's text field to the given string.

Note: The text field in a Combo is typically only capable of displaying a single line of text. Thus, setting the text to a string containing line breaks or other special characters will probably cause it to display incorrectly.

Parameters:
string - the new text
Throws:
java.lang.IllegalArgumentException -
  • ERROR_NULL_ARGUMENT - if the string 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

setText

public void setText(java.lang.String string,
                    boolean setCaretToEnd)
Sets the contents of the receiver's text field to the given string.

Note: The text field in a Combo is typically only capable of displaying a single line of text. Thus, setting the text to a string containing line breaks or other special characters will probably cause it to display incorrectly.

Parameters:
string - the new text
boolean - Sets whether or not to select all of the text in the control. If true the caret will be placed at the end of the new text. If false then this method has the same behavior as: setText(String)
Throws:
java.lang.IllegalArgumentException -
  • ERROR_NULL_ARGUMENT - if the string 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

setTextLimit

public void setTextLimit(int limit)
Sets the maximum number of characters that the receiver's text field is capable of holding to be the argument.

Parameters:
limit - new text limit
Throws:
java.lang.IllegalArgumentException -
  • ERROR_CANNOT_BE_ZERO - if the limit is zero
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

setToolTipText

public void setToolTipText(java.lang.String string)
Overrides:
setToolTipText in class org.eclipse.swt.widgets.Control

setVisible

public void setVisible(boolean visible)
Overrides:
setVisible in class org.eclipse.swt.widgets.Control

setVisibleItemCount

public void setVisibleItemCount(int count)
Sets the number of items that are visible in the drop down portion of the receiver's list.

Parameters:
count - the new number of items to be visible
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.0

getTreeContentProvider

public org.eclipse.jface.viewers.ITreeContentProvider getTreeContentProvider()

expandTreeToLevel

public void expandTreeToLevel(int level)