public class Grid extends Composite
NOTE: THIS WIDGET AND ITS API ARE STILL UNDER DEVELOPMENT. THIS IS A PRE-RELEASE ALPHA VERSION. USERS SHOULD EXPECT API CHANGES IN FUTURE VERSIONS.
Instances of this class implement a selectable user interface object that displays a list of images and strings and issue notification when selected.
The item children that may be added to instances of this class must be of
type GridItem
.
Constructor and Description |
---|
Grid(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 |
addSelectionListener(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 |
addTreeListener(TreeListener listener)
Adds the listener to the collection of listeners who will be notified
when the receiver's items changes, by sending it one of the messages
defined in the
TreeListener interface. |
void |
clear(int[] indices,
boolean allChildren)
Clears the items at the given zero-relative indices in the receiver.
|
void |
clear(int index,
boolean allChildren)
Clears the item at the given zero-relative index in the receiver.
|
void |
clear(int start,
int end,
boolean allChildren)
Clears the items in the receiver which are between the given
zero-relative start and end indices (inclusive).
|
void |
clearAll(boolean allChildren)
Clears all the items in the receiver.
|
Point |
computeSize(int wHint,
int hHint,
boolean changed)
Returns the preferred size of the receiver.
|
void |
deselect(int index)
Deselects the item at the given zero-relative index in the receiver.
|
void |
deselect(int[] indices)
Deselects the items at the given zero-relative indices in the receiver.
|
void |
deselect(int start,
int end)
Deselects the items at the given zero-relative indices in the receiver.
|
void |
deselectAll()
Deselects all selected items in the receiver.
|
<T> T |
getAdapter(java.lang.Class<T> adapter)
Implementation of the
Adaptable interface. |
GridColumn |
getColumn(int index)
Returns the column at the given, zero-relative index in the receiver.
|
int |
getColumnCount()
Returns the number of columns contained in the receiver.
|
GridColumnGroup |
getColumnGroup(int index)
Returns the column group at the given, zero-relative index in the receiver.
|
int |
getColumnGroupCount()
Returns the number of column groups contained in the receiver.
|
GridColumnGroup[] |
getColumnGroups()
Returns an array of
GridColumnGroup s which are the column groups 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.
|
GridColumn[] |
getColumns()
Returns an array of
GridColumn s which are the columns in the
receiver. |
GridItem |
getFocusItem()
Returns the current item in focus.
|
int |
getFooterHeight()
Returns the height of the column footers.
|
boolean |
getFooterVisible()
Returns
true if the receiver's footer is visible, and false otherwise |
int |
getGroupHeaderHeight()
Returns the height of the column group headers.
|
int |
getHeaderHeight()
Returns the height of the column headers.
|
boolean |
getHeaderVisible()
Returns
true if the receiver's header is visible, and
false otherwise. |
protected IScrollBarProxy |
getHorizontalScrollBarProxy() |
GridItem |
getItem(int index)
Returns the item at the given, zero-relative index in the receiver.
|
GridItem |
getItem(Point point)
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.
|
int |
getItemHeight()
Returns the default height of the items
in this
Grid . |
GridItem[] |
getItems()
Returns a (possibly empty) array of
GridItem s which are the
items in the receiver. |
boolean |
getLinesVisible()
Returns true if the lines are visible.
|
GridColumn |
getNextVisibleColumn(GridColumn column)
Returns the next visible column in the table.
|
GridItem |
getNextVisibleItem(GridItem item)
Returns the next visible item in the table.
|
GridColumn |
getPreviousVisibleColumn(GridColumn column)
Returns the previous visible column in the table.
|
GridItem |
getPreviousVisibleItem(GridItem item)
Returns the previous visible item in the table.
|
GridItem |
getRootItem(int index)
TODO: JavaDoc
|
int |
getRootItemCount()
Returns the number of root items contained in the receiver.
|
GridItem[] |
getRootItems()
Returns a (possibly empty) array of
GridItem s which are
the root items in the receiver. |
GridItem[] |
getSelection()
Returns a array of
GridItem s that are currently selected in the
receiver. |
int |
getSelectionCount()
Returns the number of selected items contained in the receiver.
|
boolean |
getSelectionEnabled()
Returns
true if selection is enabled, false otherwise. |
int |
getSelectionIndex()
Returns the zero-relative index of the item which is currently selected
in the receiver, or -1 if no item is selected.
|
int[] |
getSelectionIndices()
Returns the zero-relative indices of the items which are currently
selected in the receiver.
|
int |
getTopIndex()
Returns the zero-relative index of the item which is currently at the top
of the receiver.
|
protected IScrollBarProxy |
getVerticalScrollBarProxy() |
int |
indexOf(GridColumn column)
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.
|
int |
indexOf(GridItem item)
Searches the receiver's list starting at the first item (index 0) until
an item is found that is equal to the argument, and returns the index of
that item.
|
boolean |
isAutoHeight()
Returns the value of the auto-height feature, which resizes row heights and column header
heights based on word-wrapped content.
|
boolean |
isSelected(GridItem item)
Returns true if the given item is selected.
|
boolean |
isSelected(int index)
Returns
true if the item is selected, and false
otherwise. |
void |
remove(int index)
Removes the item from the receiver at the given zero-relative index.
|
void |
remove(int[] indices)
Removes the items from the receiver's list at the given zero-relative
indices.
|
void |
remove(int start,
int end)
Removes the items from the receiver which are between the given
zero-relative start and end indices (inclusive).
|
void |
removeAll()
Removes all of the items from the receiver.
|
void |
removeSelectionListener(SelectionListener listener)
Removes the listener from the collection of listeners who will be
notified when the receiver's selection changes.
|
void |
removeTreeListener(TreeListener listener)
Removes the listener from the collection of listeners who will be
notified when the receiver's items changes.
|
void |
select(int index)
Selects the item at the given zero-relative index in the receiver.
|
void |
select(int[] indices)
Selects the items at the given zero-relative indices in the receiver.
|
void |
select(int start,
int end)
Selects the items in the range specified by the given zero-relative
indices in the receiver.
|
void |
selectAll()
Selects all of the items in the receiver.
|
void |
setAutoHeight(boolean autoHeight)
Sets the value of the auto-height feature.
|
void |
setColumnOrder(int[] order)
Sets the order that the items in the receiver should be displayed in to
the given argument which is described in terms of the zero-relative
ordering of when the items were added.
|
void |
setData(java.lang.String key,
java.lang.Object value)
Sets the application defined property of the receiver
with the specified name to the given value.
|
void |
setFocusItem(GridItem item)
Sets the focused item to the given item.
|
void |
setFont(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 |
setFooterVisible(boolean show)
Marks the receiver's footer as visible if the argument is
true ,
and marks it invisible otherwise. |
void |
setHeaderVisible(boolean show)
Marks the receiver's header as visible if the argument is
true ,
and marks it invisible otherwise. |
void |
setItemCount(int count)
Sets the number of items contained in the receiver.
|
void |
setItemHeight(int height)
Sets the default height for this
Grid 's items. |
void |
setLinesVisible(boolean linesVisible)
Sets the line visibility.
|
void |
setSelection(GridItem[] items)
Sets the receiver's selection to be the given array of items.
|
void |
setSelection(int index)
Selects the item at the given zero-relative index in the receiver.
|
void |
setSelection(int[] indices)
Selects the items at the given zero-relative indices in the receiver.
|
void |
setSelection(int start,
int end)
Selects the items in the range specified by the given zero-relative
indices in the receiver.
|
void |
setSelectionEnabled(boolean selectionEnabled)
Enables selection highlighting if the argument is
true . |
void |
setTopIndex(int index)
Sets the zero-relative index of the item which is currently at the top of
the receiver.
|
void |
showColumn(GridColumn column)
Shows the column.
|
void |
showItem(GridItem item)
Shows the item.
|
void |
showSelection()
Shows the selection.
|
changed, getBackgroundMode, getChildren, getLayout, getLayoutDeferred, getTabList, isLayoutDeferred, layout, layout, layout, layout, layout, setBackgroundMode, setFocus, setLayout, setLayoutDeferred, setTabList
computeTrim, getClientArea, getHorizontalBar, getVerticalBar
addControlListener, addDragDetectListener, addFocusListener, addGestureListener, addHelpListener, addKeyListener, addMenuDetectListener, addMouseListener, addTouchListener, addTraverseListener, computeSize, forceFocus, getAccessible, getBackground, getBackgroundImage, getBorderWidth, getBounds, getCursor, getEnabled, getFont, getForeground, getLayoutData, getLocation, getMenu, getMonitor, getOrientation, getParent, getShell, getSize, getToolTipText, getTouchEnabled, getVisible, isEnabled, isFocusControl, isReparentable, isVisible, moveAbove, moveBelow, pack, pack, redraw, redraw, removeControlListener, removeDragDetectListener, removeFocusListener, removeGestureListener, removeHelpListener, removeKeyListener, removeMenuDetectListener, removeMouseListener, removeTouchListener, removeTraverseListener, requestLayout, setBackground, setBackgroundImage, setBounds, setBounds, setCursor, setEnabled, setForeground, setLayoutData, setLocation, setLocation, setMenu, setOrientation, setParent, setRedraw, setSize, setSize, setToolTipText, setTouchEnabled, setVisible, toControl, toControl, toDisplay, toDisplay, update
addDisposeListener, addListener, checkSubclass, checkWidget, dispose, getData, getData, getDisplay, getListeners, getStyle, isDisposed, isListening, notifyListeners, removeDisposeListener, removeListener, removeListener, reskin, setData, toString
public Grid(Composite parent, int style)
parent
- a composite control which will be the parent of the new
instance (cannot be null)style
- the style of control to constructjava.lang.IllegalArgumentException
- SWTException
- SWT.SINGLE
,
SWT.MULTI
public Point computeSize(int wHint, int hHint, boolean changed)
The preferred size of a control is the size that it would
best be displayed at. The width hint and height hint arguments
allow the caller to ask a control questions such as "Given a particular
width, how high does the control need to be to show all of the contents?"
To indicate that the caller does not wish to constrain a particular
dimension, the constant SWT.DEFAULT
is passed for the hint.
If the changed flag is true
, it indicates that the receiver's
contents have changed, therefore any caches that a layout manager
containing the control may have been keeping need to be flushed. When the
control is resized, the changed flag will be false
, so layout
manager caches can be retained.
computeSize
in class Composite
wHint
- the width hint (can be SWT.DEFAULT
)hHint
- the height hint (can be SWT.DEFAULT
)changed
- true
if the control's contents have changed, and false
otherwiseLayout
,
Control.getBorderWidth()
,
Control.getBounds()
,
Control.getSize()
,
Control.pack(boolean)
,
"computeTrim, getClientArea for controls that implement them"public void addSelectionListener(SelectionListener listener)
SelectionListener
interface.
Cell selection events may have Event.detail = SWT.DRAG
when the
user is drag selecting multiple cells. A follow up selection event will be generated
when the drag is complete.
listener
- the listener which should be notifiedjava.lang.IllegalArgumentException
- SWTException
- public void removeSelectionListener(SelectionListener listener)
listener
- the listener which should no longer be notifiedSWTException
- SelectionListener
,
addSelectionListener(SelectionListener)
public void addTreeListener(TreeListener listener)
TreeListener
interface.listener
- the listener which should be notifiedjava.lang.IllegalArgumentException
- SWTException
- TreeListener
,
removeTreeListener(org.eclipse.swt.events.TreeListener)
,
TreeEvent
public void removeTreeListener(TreeListener listener)
listener
- the listener which should no longer be notifiedSWTException
- TreeListener
,
addTreeListener(TreeListener)
public void setItemCount(int count)
count
- the number of itemsSWTException
- public int getItemCount()
SWTException
- public GridItem[] getItems()
GridItem
s which are the
items in the receiver.
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.
SWTException
- public GridItem getItem(int index)
index
- the index of the item to returnjava.lang.IllegalArgumentException
- SWTException
- public GridItem getItem(Point point)
point
- the point used to locate the itemjava.lang.IllegalArgumentException
- SWTException
- public int indexOf(GridItem item)
item
- the search itemjava.lang.IllegalArgumentException
- SWTException
- public int getRootItemCount()
SWTException
- public GridItem[] getRootItems()
GridItem
s which are
the root items in the receiver.
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.
SWTException
- public GridItem getRootItem(int index)
index
- public GridItem getNextVisibleItem(GridItem item)
item
- itemSWTException
- public GridItem getPreviousVisibleItem(GridItem item)
item
- item or nullSWTException
- public int getColumnCount()
GridColumn
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 table like a list, adding items
but never creating a column.SWTException
- public GridColumn[] getColumns()
GridColumn
s which are the columns in the
receiver. If no GridColumn
s were created by the programmer,
the array is empty, despite the fact that visually, one column of items
may be visible. This occurs when the programmer uses the table like a
list, adding items but never creating a column.
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.
SWTException
- public GridColumn getColumn(int index)
GridColumn
s were created by the programmer, this method will
throw ERROR_INVALID_RANGE
despite the fact that a single column
of data may be visible in the table. This occurs when the programmer uses
the table like a list, adding items but never creating a column.index
- the index of the column to returnjava.lang.IllegalArgumentException
- SWTException
- public int indexOf(GridColumn column)
column
- the search columnjava.lang.IllegalArgumentException
- SWTException
- public void setColumnOrder(int[] order)
order
- the new order to display the itemsSWTException
- java.lang.IllegalArgumentException
- public int[] getColumnOrder()
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.
SWTException
- public GridColumn getNextVisibleColumn(GridColumn column)
column
- columnSWTException
- public GridColumn getPreviousVisibleColumn(GridColumn column)
column
- columnSWTException
- public int getColumnGroupCount()
SWTException
- public GridColumnGroup[] getColumnGroups()
GridColumnGroup
s which are the column groups in the
receiver.
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.
SWTException
- public GridColumnGroup getColumnGroup(int index)
index
- the index of the column group to returnjava.lang.IllegalArgumentException
- SWTException
- public void clear(int index, boolean allChildren)
SWT.VIRTUAL
style,
these attributes are requested again as needed.index
- the index of the item to clearallChildren
- true
if all child items of the indexed item should be
cleared recursively, and false
otherwisejava.lang.IllegalArgumentException
- SWTException
- SWT.VIRTUAL
,
SWT.SetData
public void clear(int start, int end, boolean allChildren)
SWT.VIRTUAL
style,
these attributes are requested again as needed.start
- the start index of the item to clearend
- the end index of the item to clearallChildren
- true
if all child items of the range of items should be
cleared recursively, and false
otherwisejava.lang.IllegalArgumentException
- SWTException
- SWT.VIRTUAL
,
SWT.SetData
public void clear(int[] indices, boolean allChildren)
SWT.VIRTUAL
style,
these attributes are requested again as needed.indices
- the array of indices of the itemsallChildren
- true
if all child items of the indexed items should be
cleared recursively, and false
otherwisejava.lang.IllegalArgumentException
- SWTException
- SWT.VIRTUAL
,
SWT.SetData
public void clearAll(boolean allChildren)
SWT.VIRTUAL
style, these
attributes are requested again as needed.allChildren
- true
if all child items of each item should be
cleared recursively, and false
otherwiseSWTException
- SWT.VIRTUAL
,
SWT.SetData
public void setSelectionEnabled(boolean selectionEnabled)
true
.selectionEnabled
- the selection enabled stateSWTException
- public boolean getSelectionEnabled()
true
if selection is enabled, false otherwise.SWTException
- public void select(int index)
If cell selection is enabled, selects all cells at the given index.
index
- the index of the item to selectSWTException
- public void select(int start, int end)
If an item in the given range is not selected, it is selected. If an item in the given range was already selected, it remains selected. Indices that are out of range are ignored and no items will be selected if start is greater than end. If the receiver is single-select and there is more than one item in the given range, then all indices are ignored.
If cell selection is enabled, all cells within the given range are selected.
start
- the start of the rangeend
- the end of the rangeSWTException
- setSelection(int,int)
public void select(int[] indices)
If the item at a given index is not selected, it is selected. If the item at a given index was already selected, it remains selected. Indices that are out of range and duplicate indices are ignored. If the receiver is single-select and multiple indices are specified, then all indices are ignored.
If cell selection is enabled, all cells within the given indices are selected.
indices
- the array of indices for the items to selectjava.lang.IllegalArgumentException
- SWTException
- setSelection(int[])
public void selectAll()
If the receiver is single-select, do nothing. If cell selection is enabled, all cells are selected.
SWTException
- public void deselect(int index)
If cell selection is enabled, all cells in the specified item are deselected.
index
- the index of the item to deselectSWTException
- public void deselect(int start, int end)
If cell selection is enabled, all cells in the given range are deselected.
start
- the start index of the items to deselectend
- the end index of the items to deselectSWTException
- public void deselect(int[] indices)
If cell selection is enabled, all cells in the given items are deselected.
indices
- the array of indices for the items to deselectjava.lang.IllegalArgumentException
- SWTException
- public void deselectAll()
SWTException
- public void setSelection(int index)
If cell selection is enabled, all cells within the item at the given index are selected.
index
- the index of the item to selectSWTException
- public void setSelection(int start, int end)
Indices that are out of range are ignored and no items will be selected if start is greater than end. If the receiver is single-select and there is more than one item in the given range, then all indices are ignored.
If cell selection is enabled, all cells within the given range are selected.
start
- the start index of the items to selectend
- the end index of the items to selectSWTException
- deselectAll()
,
select(int,int)
public void setSelection(int[] indices)
Indices that are out of range and duplicate indices are ignored. If the receiver is single-select and multiple indices are specified, then all indices are ignored.
If cell selection is enabled, all cells within the given indices are selected.
indices
- the indices of the items to selectjava.lang.IllegalArgumentException
- SWTException
- deselectAll()
,
select(int[])
public void setSelection(GridItem[] items)
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. If cell selection is enabled, all cells within the given items are selected.
items
- the array of itemsjava.lang.IllegalArgumentException
- SWTException
- deselectAll()
,
select(int[])
,
setSelection(int[])
public GridItem[] getSelection()
GridItem
s that are currently selected in the
receiver. The order of the items is unspecified. An empty array indicates
that no items are selected.
Note: This is not the actual structure used by the receiver to maintain its selection, so modifying the array will not affect the receiver.
If cell selection is enabled, any items which contain at least one selected cell are returned.
SWTException
- public int getSelectionCount()
SWTException
- public int getSelectionIndex()
SWTException
- public int[] getSelectionIndices()
Note: This is not the actual structure used by the receiver to maintain its selection, so modifying the array will not affect the receiver.
If cell selection is enabled, returns the indices of any items which contain at least one selected cell.
SWTException
- public boolean isSelected(int index)
true
if the item is selected, and false
otherwise. Indices out of range are ignored. If cell selection is
enabled, returns true if the item at the given index contains at
least one selected cell.index
- the index of the itemSWTException
- public boolean isSelected(GridItem item)
item
- itemjava.lang.IllegalArgumentException
- SWTException
- public void remove(int index)
index
- the index for the itemjava.lang.IllegalArgumentException
- SWTException
- public void remove(int start, int end)
start
- the start of the rangeend
- the end of the rangejava.lang.IllegalArgumentException
- SWTException
- public void remove(int[] indices)
indices
- the array of indices of the itemsjava.lang.IllegalArgumentException
- SWTException
- public void removeAll()
SWTException
- public void setHeaderVisible(boolean show)
true
,
and marks it invisible otherwise.show
- the new visibility stateSWTException
- public boolean getHeaderVisible()
true
if the receiver's header is visible, and
false
otherwise.SWTException
- public int getHeaderHeight()
SWTException
- public void setFooterVisible(boolean show)
true
,
and marks it invisible otherwise.show
- the new visibility stateSWTException
- public boolean getFooterVisible()
true
if the receiver's footer is visible, and false
otherwiseSWTException
- public int getFooterHeight()
SWTException
- public int getGroupHeaderHeight()
SWTException
- public void setLinesVisible(boolean linesVisible)
linesVisible
- The linesVisible to set.SWTException
- public boolean getLinesVisible()
SWTException
- public void setFocusItem(GridItem item)
item
- item to focus.java.lang.IllegalArgumentException
- SWTException
- public GridItem getFocusItem()
null
.SWTException
- public void setItemHeight(int height)
Grid
's items. When
this method is called, all existing items are resized
to the specified height and items created afterwards will be
initially sized to this height.
As long as no default height was set by the client through this method,
the preferred height of the first item in this Grid
is
used as a default for all items (and is returned by getItemHeight()
).
height
- default height in pixelsjava.lang.IllegalArgumentException
- SWTException
- GridItem.getHeight()
public int getItemHeight()
Grid
. See setItemHeight(int)
for details.SWTException
- setItemHeight(int)
public void setFont(Font font)
Control
public void setTopIndex(int index)
index
- the index of the top itemSWTException
- public int getTopIndex()
SWTException
- public void showItem(GridItem item)
item
- the item to be shownSWTException
- public void showColumn(GridColumn column)
column
- the column to be shownSWTException
- public void showSelection()
SWTException
- public void setAutoHeight(boolean autoHeight)
autoHeight
- Set to true to enable this feature, false (default) otherwise.public boolean isAutoHeight()
setAutoHeight(boolean)
public <T> T getAdapter(java.lang.Class<T> adapter)
Widget
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.
getAdapter
in interface Adaptable
getAdapter
in class Composite
adapter
- the lookup classnull
if
there is no adapter associated with the given class.public void setData(java.lang.String key, java.lang.Object value)
Widget
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.
setData
in class Control
key
- the name of the propertyvalue
- the new value for the propertyWidget.getData(String)
protected IScrollBarProxy getHorizontalScrollBarProxy()
protected IScrollBarProxy getVerticalScrollBarProxy()
Copyright (c) EclipseSource and others 2002, 2017.
All rights reserved. This program and the accompanying materials
are made available under the terms of the
Eclipse Public License v1.0