Class GridColumn

All Implemented Interfaces:
Adaptable

public class GridColumn extends Item
Instances of this class represent a column in a grid widget.

Styles:
SWT.LEFT, SWT.RIGHT, SWT.CENTER
Events:
Move, Resize, Selection, Show, Hide
  • Constructor Summary

    Constructors
    Constructor
    Description
    GridColumn(GridColumnGroup parent, int style)
    Constructs a new instance of this class given its parent column group (which must be a GridColumnGroup), a style value describing its behavior and appearance, and the index at which to place it in the items maintained by its parent.
    GridColumn(Grid parent, int style)
    Constructs a new instance of this class given its parent (which must be a Grid) and a style value describing its behavior and appearance.
    GridColumn(Grid parent, int style, int index)
    Constructs a new instance of this class given its parent (which must be a Grid), a style value describing its behavior and appearance, and the index at which to place it in the items maintained by its parent.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Adds a listener to the list of listeners notified when the column is moved or resized.
    void
    Adds the listener to the collection of listeners who will be notified when the receiver's is pushed, by sending it one of the messages defined in the SelectionListener interface.
    void
    Disposes of the operating system resources associated with the receiver and all its descendents.
    <T> T
    getAdapter(Class<T> adapter)
    Implementation of the Adaptable interface.
    int
    Returns the column alignment.
    boolean
    Returns the checkable state.
    Returns the column group if this column was created inside a group, or null otherwise.
    Returns the font that the receiver will use to paint textual information for the footer.
    Returns the receiver's footer image if it has one, or null if it does not.
    Returns the receiver's footer text, which will be an empty string if it has never been set.
    Returns the font that the receiver will use to paint textual information for the header.
    Returns the tooltip of the column header.
    boolean
    Returns whether or not text is word-wrapped in the header for this column.
    int
     
    boolean
    Returns true if this column is moveable.
    Returns the parent grid.
    boolean
    Returns true if the column is resizeable.
    int
    Returns the sort indicator value.
    boolean
    Returns the visibility state as set with setVisible.
    int
    Returns the width of the column.
    boolean
    Returns the true if the cells in receiver wrap their text.
    boolean
    Returns true if the column includes a check box.
    boolean
    Returns true if this column is set as a detail column in a column group.
    boolean
    Returns true if this column is set as a summary column in a column group.
    protected boolean
     
    boolean
    Returns true if this column includes a tree toggle.
    boolean
    Returns true if the column is visible, false otherwise.
    void
    Causes the receiver to be resized to its preferred size.
    void
    Removes the given control listener.
    void
    Removes the listener from the collection of listeners who will be notified when the receiver's selection changes.
    void
    setAlignment(int alignment)
    Sets the column alignment.
    void
    setCheckable(boolean checkable)
    Sets the checkable state.
    void
    setData(String key, Object value)
    Sets the application defined property of the receiver with the specified name to the given value.
    void
    setDetail(boolean detail)
    Sets the column as a detail column in a column group.
    void
    Sets the Font to be used when displaying the Footer text.
    void
    Sets the receiver's footer image to the argument, which may be null indicating that no image should be displayed.
    void
    Sets the receiver's footer text.
    void
    Sets the Font to be used when displaying the Header text.
    void
    setHeaderTooltip(String toolTipText)
    Sets the tooltip text of the column header.
    void
    setHeaderWordWrap(boolean wordWrap)
    Sets whether or not text is word-wrapped in the header for this column.
    void
    setImage(Image image)
    Sets the receiver's image to the argument, which may be null indicating that no image should be displayed.
    void
    setMinimumWidth(int minimumWidth)
    Set the minimum width of the column
    void
    setMoveable(boolean moveable)
    Sets the column moveable or fixed.
    void
    setResizeable(boolean resizeable)
    Sets the column resizeable.
    void
    setSort(int style)
    Sets the sort indicator style for the column.
    void
    setSummary(boolean summary)
    Sets the column as a summary column in a column group.
    protected void
    setTableCheck(boolean tableCheck)
     
    void
    Sets the receiver's text.
    void
    setTree(boolean tree)
    Makes this column the one with tree toggle.
    void
    setVisible(boolean visible)
    Sets the column's visibility.
    void
    setWidth(int width)
    Sets the width of the column.
    void
    setWordWrap(boolean wordWrap)
    If the argument is true, wraps the text in the receiver's cells.

    Methods inherited from class org.eclipse.swt.widgets.Item

    getImage, getText

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • GridColumn

      public GridColumn(Grid parent, int style)
      Constructs a new instance of this class given its parent (which must be a Grid) and a style value describing its behavior and appearance. The item is added to the end of the items maintained by its parent.
      Parameters:
      parent - an Grid control which will be the parent of the new instance (cannot be null)
      style - the style of control to construct
      Throws:
      IllegalArgumentException -
      • ERROR_NULL_ARGUMENT - if the parent is null
      SWTException -
      • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent
      • ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass
    • GridColumn

      public GridColumn(Grid parent, int style, int index)
      Constructs a new instance of this class given its parent (which must be a Grid), a style value describing its behavior and appearance, and the index at which to place it in the items maintained by its parent.
      Parameters:
      parent - an Grid control which will be the parent of the new instance (cannot be null)
      style - the style of control to construct
      index - the index to store the receiver in its parent
      Throws:
      IllegalArgumentException -
      • ERROR_NULL_ARGUMENT - if the parent is null
      SWTException -
      • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent
      • ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass
    • GridColumn

      public GridColumn(GridColumnGroup parent, int style)
      Constructs a new instance of this class given its parent column group (which must be a GridColumnGroup), a style value describing its behavior and appearance, and the index at which to place it in the items maintained by its parent.
      Parameters:
      parent - an Grid control which will be the parent of the new instance (cannot be null)
      style - the style of control to construct
      Throws:
      IllegalArgumentException -
      • ERROR_NULL_ARGUMENT - if the parent is null
      SWTException -
      • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent
      • ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass
  • Method Details

    • dispose

      public void dispose()
      Disposes of the operating system resources associated with the receiver and all its descendents. After this method has been invoked, the receiver and all descendents will answer true when sent the message isDisposed(). Any internal connections between the widgets in the tree will have been removed to facilitate garbage collection.

      NOTE: This method is not called recursively on the descendents of the receiver. This means that, widget implementers can not detect when a widget is being disposed of by re-implementing this method, but should instead listen for the Dispose event.

      Overrides:
      dispose in class Widget
      See Also:
    • getParent

      public Grid getParent()
      Returns the parent grid.
      Returns:
      the parent grid.
      Throws:
      SWTException -
      • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
      • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    • getColumnGroup

      public GridColumnGroup getColumnGroup()
      Returns the column group if this column was created inside a group, or null otherwise.
      Returns:
      the column group.
      Throws:
      SWTException -
      • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
      • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    • addSelectionListener

      public void addSelectionListener(SelectionListener listener)
      Adds the listener to the collection of listeners who will be notified when the receiver's is pushed, by sending it one of the messages defined in the SelectionListener interface.
      Parameters:
      listener - the listener which should be notified
      Throws:
      IllegalArgumentException -
      • ERROR_NULL_ARGUMENT - if the listener is null
      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(SelectionListener listener)
      Removes the listener from the collection of listeners who will be notified when the receiver's selection changes.
      Parameters:
      listener - the listener which should no longer be notified
      Throws:
      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:
    • addControlListener

      public void addControlListener(ControlListener listener)
      Adds a listener to the list of listeners notified when the column is moved or resized.
      Parameters:
      listener - listener
      Throws:
      IllegalArgumentException -
      • ERROR_NULL_ARGUMENT - if the listener is null
      SWTException -
      • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
      • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    • removeControlListener

      public void removeControlListener(ControlListener listener)
      Removes the given control listener.
      Parameters:
      listener - listener.
      Throws:
      IllegalArgumentException -
      • ERROR_NULL_ARGUMENT - if the listener is null
      SWTException -
      • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
      • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    • setWidth

      public void setWidth(int width)
      Sets the width of the column.
      Parameters:
      width - new width
      Throws:
      SWTException -
      • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
      • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    • getWidth

      public int getWidth()
      Returns the width of the column.
      Returns:
      width of column
      Throws:
      SWTException -
      • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
      • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    • setMinimumWidth

      public void setMinimumWidth(int minimumWidth)
      Set the minimum width of the column
      Parameters:
      minimumWidth - the minimum width
    • getMinimumWidth

      public int getMinimumWidth()
      Returns:
      the minimum width
    • setText

      public void setText(String text)
      Description copied from class: Item
      Sets the receiver's text.
      Overrides:
      setText in class Item
      Parameters:
      text - the new text
    • setImage

      public void setImage(Image image)
      Description copied from class: Item
      Sets the receiver's image to the argument, which may be null indicating that no image should be displayed.
      Overrides:
      setImage in class Item
      Parameters:
      image - the image to display on the receiver (may be null)
    • setSort

      public void setSort(int style)
      Sets the sort indicator style for the column. This method does not actual sort the data in the table. Valid values include: SWT.UP, SWT.DOWN, SWT.NONE.
      Parameters:
      style - SWT.UP, SWT.DOWN, SWT.NONE
      Throws:
      SWTException -
      • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
      • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    • getSort

      public int getSort()
      Returns the sort indicator value.
      Returns:
      SWT.UP, SWT.DOWN, SWT.NONE
      Throws:
      SWTException -
      • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
      • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    • setMoveable

      public void setMoveable(boolean moveable)
      Sets the column moveable or fixed.
      Parameters:
      moveable - true to enable column moving
      Throws:
      SWTException -
      • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
      • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    • getMoveable

      public boolean getMoveable()
      Returns true if this column is moveable.
      Returns:
      true if moveable.
      Throws:
      SWTException -
      • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
      • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    • setResizeable

      public void setResizeable(boolean resizeable)
      Sets the column resizeable.
      Parameters:
      resizeable - true to make the column resizeable
      Throws:
      SWTException -
      • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
      • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    • getResizeable

      public boolean getResizeable()
      Returns true if the column is resizeable.
      Returns:
      true if the column is resizeable.
      Throws:
      SWTException -
      • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
      • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    • setCheckable

      public void setCheckable(boolean checkable)
      Sets the checkable state. If false the checkboxes in the column cannot be checked.
      Parameters:
      checkable - the new checkable state.
      Throws:
      SWTException -
      • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
      • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    • getCheckable

      public boolean getCheckable()
      Returns the checkable state. If false the checkboxes in the column cannot be checked.
      Returns:
      true if the column is checkable (only applicable when style is SWT.CHECK).
      Throws:
      SWTException -
      • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
      • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    • setDetail

      public void setDetail(boolean detail)
      Sets the column as a detail column in a column group. Detail columns are shown when a column group is expanded. If this column was not created in a column group, this method has no effect.
      Parameters:
      detail - true to show this column when the group is expanded.
      Throws:
      SWTException -
      • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
      • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    • isDetail

      public boolean isDetail()
      Returns true if this column is set as a detail column in a column group. Detail columns are shown when the group is expanded.
      Returns:
      true if the column is a detail column.
      Throws:
      SWTException -
      • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
      • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    • setSummary

      public void setSummary(boolean summary)
      Sets the column as a summary column in a column group. Summary columns are shown when a column group is collapsed. If this column was not created in a column group, this method has no effect.
      Parameters:
      summary - true to show this column when the group is collapsed.
      Throws:
      SWTException -
      • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
      • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    • isSummary

      public boolean isSummary()
      Returns true if this column is set as a summary column in a column group. Summary columns are shown when the group is collapsed.
      Returns:
      true if the column is a summary column.
      Throws:
      SWTException -
      • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
      • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    • setVisible

      public void setVisible(boolean visible)
      Sets the column's visibility.
      Parameters:
      visible - the visible to set
      Throws:
      SWTException -
      • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
      • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    • getVisible

      public boolean getVisible()
      Returns the visibility state as set with setVisible.
      Returns:
      the visible
      Throws:
      SWTException -
      • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
      • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    • isVisible

      public boolean isVisible()
      Returns true if the column is visible, false otherwise. If the column is in a group and the group is not expanded and this is a detail column, returns false (and vice versa).
      Returns:
      true if visible, false otherwise
      Throws:
      SWTException -
      • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
      • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    • isCheck

      public boolean isCheck()
      Returns true if the column includes a check box.
      Returns:
      true if the column includes a check box.
      Throws:
      SWTException -
      • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
      • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    • setTree

      public void setTree(boolean tree)
      Makes this column the one with tree toggle.
      Parameters:
      tree - true to add toggle.
      Throws:
      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.13
    • isTree

      public boolean isTree()
      Returns true if this column includes a tree toggle.
      Returns:
      true if the column includes the tree toggle.
      Throws:
      SWTException -
      • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
      • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    • setAlignment

      public void setAlignment(int alignment)
      Sets the column alignment.
      Parameters:
      alignment - SWT.LEFT, SWT.RIGHT, SWT.CENTER
      Throws:
      SWTException -
      • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
      • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    • getAlignment

      public int getAlignment()
      Returns the column alignment.
      Returns:
      SWT.LEFT, SWT.RIGHT, SWT.CENTER
      Throws:
      SWTException -
      • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
      • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    • getWordWrap

      public boolean getWordWrap()
      Returns the true if the cells in receiver wrap their text.
      Returns:
      true if the cells wrap their text.
      Throws:
      SWTException -
      • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
      • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    • setWordWrap

      public void setWordWrap(boolean wordWrap)
      If the argument is true, wraps the text in the receiver's cells. This feature will not cause the row height to expand to accommodate the wrapped text. Please use Grid#setItemHeight to change the height of each row.
      Parameters:
      wordWrap - true to make cells wrap their text.
      Throws:
      SWTException -
      • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
      • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    • setHeaderFont

      public void setHeaderFont(Font font)
      Sets the Font to be used when displaying the Header text.
      Parameters:
      font - the new header font (or null)
      Throws:
      IllegalArgumentException -
      • ERROR_INVALID_ARGUMENT - if the argument has been disposed
      SWTException -
      • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
      • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    • getHeaderFont

      public Font getHeaderFont()
      Returns the font that the receiver will use to paint textual information for the header.
      Returns:
      the receiver's font
      Throws:
      SWTException -
      • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
      • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    • setHeaderTooltip

      public void setHeaderTooltip(String toolTipText)
      Sets the tooltip text of the column header.
      Parameters:
      toolTipText - the tooltip text
      Throws:
      SWTException -
      • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
      • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    • getHeaderTooltip

      public String getHeaderTooltip()
      Returns the tooltip of the column header.
      Returns:
      the tooltip text (or null)
      Throws:
      SWTException -
      • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
      • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    • setHeaderWordWrap

      public void setHeaderWordWrap(boolean wordWrap)
      Sets whether or not text is word-wrapped in the header for this column. If Grid.setAutoHeight(true) is set, the row height is adjusted to accommodate word-wrapped text.
      Parameters:
      wordWrap - Set to true to wrap the text, false otherwise
      See Also:
    • getHeaderWordWrap

      public boolean getHeaderWordWrap()
      Returns whether or not text is word-wrapped in the header for this column.
      Returns:
      true if the header wraps its text.
      See Also:
    • setFooterText

      public void setFooterText(String text)
      Sets the receiver's footer text.
      Parameters:
      text - the new text
      Throws:
      IllegalArgumentException -
      • ERROR_NULL_ARGUMENT - if the text is null
      SWTException -
      • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
      • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    • getFooterText

      public String getFooterText()
      Returns the receiver's footer text, which will be an empty string if it has never been set.
      Returns:
      the receiver's text
      Throws:
      SWTException -
      • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
      • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    • setFooterImage

      public void setFooterImage(Image image)
      Sets the receiver's footer image to the argument, which may be null indicating that no image should be displayed.
      Parameters:
      image - the image to display on the receiver (may be null)
      Throws:
      IllegalArgumentException -
      • ERROR_INVALID_ARGUMENT - if the image has been disposed
      SWTException -
      • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
      • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    • getFooterImage

      public Image getFooterImage()
      Returns the receiver's footer image if it has one, or null if it does not.
      Returns:
      the receiver's image
      Throws:
      SWTException -
      • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
      • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    • setFooterFont

      public void setFooterFont(Font font)
      Sets the Font to be used when displaying the Footer text.
      Parameters:
      font - the new footer font (or null)
      Throws:
      IllegalArgumentException -
      • ERROR_INVALID_ARGUMENT - if the argument has been disposed
      SWTException -
      • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
      • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    • getFooterFont

      public Font getFooterFont()
      Returns the font that the receiver will use to paint textual information for the footer.
      Returns:
      the receiver's font
      Throws:
      SWTException -
      • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
      • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    • pack

      public void pack()
      Causes the receiver to be resized to its preferred size.
      Throws:
      SWTException -
      • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
      • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    • setData

      public void setData(String key, Object value)
      Description copied from class: Widget
      Sets the application defined property of the receiver with the specified name to the given value.

      Applications may associate arbitrary objects with the receiver in this fashion. If the objects stored in the properties need to be notified when the widget is disposed of, it is the application's responsibility to hook the Dispose event on the widget and do so.

      Overrides:
      setData in class Widget
      Parameters:
      key - the name of the property
      value - the new value for the property
      See Also:
    • getAdapter

      public <T> T getAdapter(Class<T> adapter)
      Description copied from class: Widget
      Implementation of the Adaptable interface.

      IMPORTANT: This method is not part of the RWT public API. It is marked public only so that it can be shared within the packages provided by RWT. It should never be accessed from application code.

      Specified by:
      getAdapter in interface Adaptable
      Overrides:
      getAdapter in class Widget
      Parameters:
      adapter - the lookup class
      Returns:
      an object that can be cast to the given class or null if there is no adapter associated with the given class.
    • isTableCheck

      protected boolean isTableCheck()
    • setTableCheck

      protected void setTableCheck(boolean tableCheck)