Class AbstractNativeHeader
java.lang.Object
org.eclipse.swt.widgets.Widget
org.eclipse.swt.widgets.Control
org.eclipse.swt.widgets.Scrollable
org.eclipse.swt.widgets.Composite
org.eclipse.nebula.widgets.compositetable.AbstractNativeHeader
- All Implemented Interfaces:
org.eclipse.swt.graphics.Drawable
public abstract class AbstractNativeHeader
extends org.eclipse.swt.widgets.Composite
Class AbstractHeader. A Header class making it easier to implement a
sorted table where clicking on a header column sets or changes the sort
order.
-
Field Summary
Fields Modifier and Type Field Description (package private) org.eclipse.swt.widgets.Table
headerTable
(package private) java.util.List
tableColumns
-
Constructor Summary
Constructors Constructor Description AbstractNativeHeader(org.eclipse.swt.widgets.Composite parent, int style)
A Header object for CompositeTable that can tell clients to re-sort, and can move/resize the columns (if used with an appropriate layout manager). -
Method Summary
Modifier and Type Method Description void
addColumnControlListener(org.eclipse.swt.events.ControlListener c)
org.eclipse.swt.graphics.Point
computeSize(int wHint, int hHint)
org.eclipse.swt.graphics.Point
computeSize(int wHint, int hHint, boolean changed)
org.eclipse.swt.widgets.TableColumn[]
getColumns()
int
getSortDirection()
Returns the current sort direction.int[]
getWeights()
Method getWeights.int
indexOfSortColumn()
The index of the currently sorted table columnboolean
isFittingHorizontally()
Method isFittingHorizontally.boolean
isMovable()
Returns if the columns are movable.boolean
isResizable()
Returns if the columns are resizable.void
removeColumnControlListener(org.eclipse.swt.events.ControlListener c)
void
setColumnText(java.lang.String[] columnTextStrings)
Clients must call this method (or its overloaded cousin) exactly once in their constructor to set the column text strings.void
setColumnText(java.lang.String[] columnTextStrings, int[] alignments)
Clients must call this method (or its overloaded cousin) exactly once in their constructor to set the column text strings and alignments.AbstractNativeHeader
setFittingHorizontally(boolean fittingHorizontally)
Method setFittingHorizontally.void
setMovable(boolean movable)
Sets if the columns are movable.void
setResizable(boolean resizable)
Sets if the columns are resizable.void
setSortColumn(int index)
Sets the sort indicator onto the specified column.void
setSortDirection(int direction)
Set the sort direction.AbstractNativeHeader
setWeights(int[] weights)
Method setWeights.protected boolean
sortOnColumn(int column, int sortDirection)
Clients must override this method to reset the current sort column/order if they want to support sorting.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, 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
-
headerTable
org.eclipse.swt.widgets.Table headerTable -
tableColumns
java.util.List tableColumns
-
-
Constructor Details
-
AbstractNativeHeader
public AbstractNativeHeader(org.eclipse.swt.widgets.Composite parent, int style)A Header object for CompositeTable that can tell clients to re-sort, and can move/resize the columns (if used with an appropriate layout manager).- Parameters:
parent
- The SWT parentstyle
- SWT style bits. The same style bits accepted by Composite.
-
-
Method Details
-
sortOnColumn
protected boolean sortOnColumn(int column, int sortDirection)Clients must override this method to reset the current sort column/order if they want to support sorting.- Parameters:
column
- The column on which to sort.sortDirection
- SWT.NONE, SWT.UP, or SWT.DOWN.- Returns:
- boolean true if sorting occurred; false otherwise.
-
setMovable
public void setMovable(boolean movable)Sets if the columns are movable.- Parameters:
movable
- true if the columns are movable; false otherwise.
-
isMovable
public boolean isMovable()Returns if the columns are movable.- Returns:
- boolean true if the columns are movable; false otherwise.
-
setResizable
public void setResizable(boolean resizable)Sets if the columns are resizable.- Parameters:
resizable
- true if the columns should be resizable; false otherwise.
-
isResizable
public boolean isResizable()Returns if the columns are resizable.- Returns:
- boolean true if the columns should be resizable; false otherwise.
-
setColumnText
public void setColumnText(java.lang.String[] columnTextStrings)Clients must call this method (or its overloaded cousin) exactly once in their constructor to set the column text strings. All alignments will be set to SWT.LEFT.- Parameters:
columnTextStrings
- String[] The text strings to display in each column
-
setColumnText
public void setColumnText(java.lang.String[] columnTextStrings, int[] alignments)Clients must call this method (or its overloaded cousin) exactly once in their constructor to set the column text strings and alignments.- Parameters:
columnTextStrings
- String[] The text strings to display in each columnalignments
- An array of SWT style bits. Each element is one of: SWT.LEFT, SWT.CENTER, or SWT.RIGHT.
-
getColumns
public org.eclipse.swt.widgets.TableColumn[] getColumns() -
setSortColumn
public void setSortColumn(int index)Sets the sort indicator onto the specified column.- Parameters:
index
- the 0-based column index or -1 if no column is sorted- See Also:
setSortDirection(int)
-
indexOfSortColumn
public int indexOfSortColumn()The index of the currently sorted table column- Returns:
- a 0-based index or -1 if no column is sorted
-
setSortDirection
public void setSortDirection(int direction)Set the sort direction.- Parameters:
direct
- one of SWT.UP, SWT.DOWN, SWT.NONE- Throws:
java.lang.RuntimeException
- if direction has an invalid value
-
getSortDirection
public int getSortDirection()Returns the current sort direction.- Returns:
- one of SWT.UP, SWT.DOWN, SWT.NONE
-
addColumnControlListener
public void addColumnControlListener(org.eclipse.swt.events.ControlListener c) -
removeColumnControlListener
public void removeColumnControlListener(org.eclipse.swt.events.ControlListener c) -
computeSize
public org.eclipse.swt.graphics.Point computeSize(int wHint, int hHint)- Overrides:
computeSize
in classorg.eclipse.swt.widgets.Control
-
computeSize
public org.eclipse.swt.graphics.Point computeSize(int wHint, int hHint, boolean changed)- Overrides:
computeSize
in classorg.eclipse.swt.widgets.Control
-
getWeights
public int[] getWeights()Method getWeights. If isFittingHorizontally, returns an array representing the percentage of the total width each column is allocated or null if no weights have been specified.If !isFittingHorizontally, returns an array where each element is the minimum width in pixels of the corresponding column.
- Returns:
- the current weights array or null if no weights have been specified.
-
setWeights
Method setWeights. If isFittingHorizontally, specifies an array representing the percentage of the total width each column is allocated or null if no weights have been specified.If !isFittingHorizontally, specifies an array where each element is the minimum width in pixels of the corresponding column.
This property is ignored if the programmer has set a layout manager on the header and/or the row prototype objects.
The number of elements in the array must match the number of columns and if isFittingHorizontally, the sum of all elements must equal 100. If either of these constraints is not true, this property will be ignored and all columns will be created equal in width.
- Parameters:
weights
- the weights to use if the CompositeTable is automatically laying out controls.- Returns:
- this
-
isFittingHorizontally
public boolean isFittingHorizontally()Method isFittingHorizontally. Returns if the CompositeTable control will scale the widths of all columns so that they all fit into the available space. The default value is false.- Returns:
- Returns true if the table's actual width is set to equal the visible width; false otherwise.
-
setFittingHorizontally
Method setFittingHorizontally. Sets if the CompositeTable control will scale the widths of all columns so that they all fit into the available space. The default value is false.- Parameters:
fittingHorizontally
- true if the table's actual width is set to equal the visible width; false otherwise.- Returns:
- this
-