All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.eclipse.swt.widgets.Table Maven / Gradle / Ivy

The newest version!
/*******************************************************************************
 * Copyright (c) 2000, 2011, 2012 IBM Corporation, Gerhardt Informatics Kft. and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *     Gerhardt Informatics Kft. - GEFGWT port
 *******************************************************************************/
package org.eclipse.swt.widgets;

import org.eclipse.swt.SWT;
import org.eclipse.swt.SWTException;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.internal.gwt.GdkColor;

/**
 * Instances of this class implement a selectable user interface object that
 * displays a list of images and strings and issues notification when selected.
 * 

* The item children that may be added to instances of this class must be of * type TableItem. *

*

* Style VIRTUAL is used to create a Table whose * TableItems are to be populated by the client on an on-demand * basis instead of up-front. This can provide significant performance * improvements for tables that are very large or for which * TableItem population is expensive (for example, retrieving * values from an external source). *

*

* Here is an example of using a Table with style * VIRTUAL:

 *  final Table table = new Table (parent, SWT.VIRTUAL | SWT.BORDER);
 *  table.setItemCount (1000000);
 *  table.addListener (SWT.SetData, new Listener () {
 *      public void handleEvent (Event event) {
 *          TableItem item = (TableItem) event.item;
 *          int index = table.indexOf (item);
 *          item.setText ("Item " + index);
 *          System.out.println (item.getText ());
 *      }
 *  }); 
 * 
*

*

* Note that although this class is a subclass of Composite, it * does not normally make sense to add Control children to it, or * set a layout on it, unless implementing something like a cell editor. *

*

*

*
Styles:
*
SINGLE, MULTI, CHECK, FULL_SELECTION, HIDE_SELECTION, VIRTUAL, NO_SCROLL
*
Events:
*
Selection, DefaultSelection, SetData, MeasureItem, EraseItem, PaintItem
*
*

*

* Note: Only one of the styles SINGLE, and MULTI may be specified. *

*

* IMPORTANT: This class is not intended to be subclassed. *

* * @see Table, TableItem, * TableColumn snippets * @see SWT Example: * ControlExample * @see Sample code and further * information * @noextend This class is not intended to be subclassed by clients. */ public class Table extends Composite { long /* int */modelHandle, checkRenderer; int itemCount, columnCount, lastIndexOf, sortDirection; long /* int */ignoreCell; TableItem[] items; TableColumn[] columns; TableItem currentItem; TableColumn sortColumn; ImageList imageList, headerImageList; boolean firstCustomDraw; int drawState, drawFlags; GdkColor drawForeground; boolean ownerDraw, ignoreSize, ignoreAccessibility; static final int CHECKED_COLUMN = 0; static final int GRAYED_COLUMN = 1; static final int FOREGROUND_COLUMN = 2; static final int BACKGROUND_COLUMN = 3; static final int FONT_COLUMN = 4; static final int FIRST_COLUMN = FONT_COLUMN + 1; static final int CELL_PIXBUF = 0; static final int CELL_TEXT = 1; static final int CELL_FOREGROUND = 2; static final int CELL_BACKGROUND = 3; static final int CELL_FONT = 4; static final int CELL_TYPES = CELL_FONT + 1; /** * 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. *

* * @param parent * a composite control which will be the parent of the new * instance (cannot be null) * @param style * the style of control to construct * * @exception IllegalArgumentException *
    *
  • ERROR_NULL_ARGUMENT - if the parent is null
  • *
* @exception 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
  • *
* * @see SWT#SINGLE * @see SWT#MULTI * @see SWT#CHECK * @see SWT#FULL_SELECTION * @see SWT#HIDE_SELECTION * @see SWT#VIRTUAL * @see SWT#NO_SCROLL * @see Widget#checkSubclass * @see Widget#getStyle */ public Table(Composite parent, int style) { super(parent, checkStyle(style)); } void _addListener(int eventType, Listener listener) { super._addListener(eventType, listener); if (!ownerDraw) { switch (eventType) { case SWT.MeasureItem: case SWT.EraseItem: case SWT.PaintItem: ownerDraw = true; recreateRenderers(); break; } } } TableItem _getItem(int index) { if ((style & SWT.VIRTUAL) == 0) return items[index]; if (items[index] != null) return items[index]; return items[index] = new TableItem(this, SWT.NONE, index, false); } static int checkStyle(int style) { /* * Feature in Windows. Even when WS_HSCROLL or WS_VSCROLL is not * specified, Windows creates trees and tables with scroll bars. The fix * is to set H_SCROLL and V_SCROLL. * * NOTE: This code appears on all platforms so that applications have * consistent scroll bar behavior. */ if ((style & SWT.NO_SCROLL) == 0) { style |= SWT.H_SCROLL | SWT.V_SCROLL; } /* GTK is always FULL_SELECTION */ style |= SWT.FULL_SELECTION; return checkBits(style, SWT.SINGLE, SWT.MULTI, 0, 0, 0, 0); } boolean checkData(TableItem item) { return true; } protected void checkSubclass() { if (!isValidSubclass()) error(SWT.ERROR_INVALID_SUBCLASS); } /** * 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 the SelectionListener interface. *

* When widgetSelected is called, the item field of the event * object is valid. If the receiver has the SWT.CHECK style and * the check selection changes, the event object detail field contains the * value SWT.CHECK. widgetDefaultSelected is * typically called when an item is double-clicked. The item field of the * event object is valid for default selection, but the detail field is not * used. *

* * @param listener * the listener which should be notified when the user changes * the receiver's selection * * @exception IllegalArgumentException *
    *
  • ERROR_NULL_ARGUMENT - if the listener is null
  • *
* @exception 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 SelectionListener * @see #removeSelectionListener * @see SelectionEvent */ public void addSelectionListener(SelectionListener listener) { checkWidget(); if (listener == null) error(SWT.ERROR_NULL_ARGUMENT); TypedListener typedListener = new TypedListener(listener); addListener(SWT.Selection, typedListener); addListener(SWT.DefaultSelection, typedListener); } /** * 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 table was created with the SWT.VIRTUAL style, these * attributes are requested again as needed. * * @param index * the index of the item to clear * * @exception IllegalArgumentException *
    *
  • ERROR_INVALID_RANGE - if the index is not between 0 * and the number of elements in the list minus 1 (inclusive) *
  • *
* @exception 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 SWT#VIRTUAL * @see SWT#SetData * * @since 3.0 */ public void clear(int index) { checkWidget(); if (!(0 <= index && index < itemCount)) { error(SWT.ERROR_INVALID_RANGE); } TableItem item = items[index]; if (item != null) item.clear(); } /** * Removes the items from the receiver which are between the given * zero-relative start and end indices (inclusive). The text, icon and other * attributes of the items are set to their default values. If the table was * created with the SWT.VIRTUAL style, these attributes are * requested again as needed. * * @param start * the start index of the item to clear * @param end * the end index of the item to clear * * @exception IllegalArgumentException *
    *
  • ERROR_INVALID_RANGE - if either the start or end are * not between 0 and the number of elements in the list minus * 1 (inclusive)
  • *
* @exception 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 SWT#VIRTUAL * @see SWT#SetData * * @since 3.0 */ public void clear(int start, int end) { checkWidget(); if (start > end) return; if (!(0 <= start && start <= end && end < itemCount)) { error(SWT.ERROR_INVALID_RANGE); } if (start == 0 && end == itemCount - 1) { clearAll(); } else { for (int i = start; i <= end; i++) { TableItem item = items[i]; if (item != null) item.clear(); } } } /** * Clears the items at the given zero-relative indices in the receiver. The * text, icon and other attributes of the items are set to their default * values. If the table was created with the SWT.VIRTUAL style, * these attributes are requested again as needed. * * @param indices * the array of indices of the items * * @exception IllegalArgumentException *
    *
  • ERROR_INVALID_RANGE - if the index is not between 0 * and the number of elements in the list minus 1 (inclusive) *
  • *
  • ERROR_NULL_ARGUMENT - if the indices array is null
  • *
* @exception 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 SWT#VIRTUAL * @see SWT#SetData * * @since 3.0 */ public void clear(int[] indices) { checkWidget(); if (indices == null) error(SWT.ERROR_NULL_ARGUMENT); if (indices.length == 0) return; for (int i = 0; i < indices.length; i++) { if (!(0 <= indices[i] && indices[i] < itemCount)) { error(SWT.ERROR_INVALID_RANGE); } } for (int i = 0; i < indices.length; i++) { TableItem item = items[indices[i]]; if (item != null) item.clear(); } } /** * Clears all the items in the receiver. The text, icon and other attributes * of the items are set to their default values. If the table was created * with the SWT.VIRTUAL style, these attributes are requested * again as needed. * * @exception 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 SWT#VIRTUAL * @see SWT#SetData * * @since 3.0 */ public void clearAll() { checkWidget(); for (int i = 0; i < itemCount; i++) { TableItem item = items[i]; if (item != null) item.clear(); } } public Point computeSize(int wHint, int hHint, boolean changed) { return null; } void createHandle(int index) { } void createItem(TableColumn column, int index) { } void createWidget(int index) { super.createWidget(index); items = new TableItem[4]; columns = new TableColumn[4]; itemCount = columnCount = 0; } /** * Deselects the item at the given zero-relative index in the receiver. If * the item at the index was already deselected, it remains deselected. * Indices that are out of range are ignored. * * @param index * the index of the item to deselect * * @exception SWTException *
    *
  • ERROR_WIDGET_DISPOSED - if the receiver has been * disposed
  • *
  • ERROR_THREAD_INVALID_ACCESS - if not called from the * thread that created the receiver
  • *
*/ public void deselect(int index) { } /** * Deselects the items at the given zero-relative indices in the receiver. * If the item at the given zero-relative index in the receiver is selected, * it is deselected. If the item at the index was not selected, it remains * deselected. The range of the indices is inclusive. Indices that are out * of range are ignored. * * @param start * the start index of the items to deselect * @param end * the end index of the items to deselect * * @exception SWTException *
    *
  • ERROR_WIDGET_DISPOSED - if the receiver has been * disposed
  • *
  • ERROR_THREAD_INVALID_ACCESS - if not called from the * thread that created the receiver
  • *
*/ public void deselect(int start, int end) { } /** * Deselects the items at the given zero-relative indices in the receiver. * If the item at the given zero-relative index in the receiver is selected, * it is deselected. If the item at the index was not selected, it remains * deselected. Indices that are out of range and duplicate indices are * ignored. * * @param indices * the array of indices for the items to deselect * * @exception IllegalArgumentException *
    *
  • ERROR_NULL_ARGUMENT - if the set of indices is null
  • *
* @exception SWTException *
    *
  • ERROR_WIDGET_DISPOSED - if the receiver has been * disposed
  • *
  • ERROR_THREAD_INVALID_ACCESS - if not called from the * thread that created the receiver
  • *
*/ public void deselect(int[] indices) { } /** * Deselects all selected items in the receiver. * * @exception SWTException *
    *
  • ERROR_WIDGET_DISPOSED - if the receiver has been * disposed
  • *
  • ERROR_THREAD_INVALID_ACCESS - if not called from the * thread that created the receiver
  • *
*/ public void deselectAll() { } void destroyItem(TableColumn column) { } void destroyItem(TableItem item) { } boolean dragDetect(int x, int y, boolean filter, boolean dragOnTimeout, boolean[] consume) { return false; } GdkColor getBackgroundColor() { return getBaseColor(); } public Rectangle getClientArea() { return null; } int getClientWidth() { return 0; } /** * 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 no TableColumns 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. * * @param index * the index of the column to return * @return the column at the given index * * @exception IllegalArgumentException *
    *
  • ERROR_INVALID_RANGE - if the index is not between 0 * and the number of elements in the list minus 1 (inclusive) *
  • *
* @exception 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 Table#getColumnOrder() * @see Table#setColumnOrder(int[]) * @see TableColumn#getMoveable() * @see TableColumn#setMoveable(boolean) * @see SWT#Move */ public TableColumn getColumn(int index) { checkWidget(); if (!(0 <= index && index < columnCount)) error(SWT.ERROR_INVALID_RANGE); return columns[index]; } /** * Returns the number of columns contained in the receiver. If no * TableColumns 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. * * @return the number of columns * * @exception SWTException *
    *
  • ERROR_WIDGET_DISPOSED - if the receiver has been * disposed
  • *
  • ERROR_THREAD_INVALID_ACCESS - if not called from the * thread that created the receiver
  • *
*/ public int getColumnCount() { checkWidget(); return columnCount; } /** * 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. *

* * @return the current visual order of the receiver's items * * @exception 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 Table#setColumnOrder(int[]) * @see TableColumn#getMoveable() * @see TableColumn#setMoveable(boolean) * @see SWT#Move * * @since 3.1 */ public int[] getColumnOrder() { return null; } /** * Returns an array of TableColumns which are the columns in * the receiver. Columns are returned in the order that they were created. * If no TableColumns 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. *

* * @return the items in the receiver * * @exception 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 Table#getColumnOrder() * @see Table#setColumnOrder(int[]) * @see TableColumn#getMoveable() * @see TableColumn#setMoveable(boolean) * @see SWT#Move */ public TableColumn[] getColumns() { checkWidget(); TableColumn[] result = new TableColumn[columnCount]; System.arraycopy(columns, 0, result, 0, columnCount); return result; } TableItem getFocusItem() { return null; } GdkColor getForegroundColor() { return getTextColor(); } /** * Returns the width in pixels of a grid line. * * @return the width of a grid line in pixels * * @exception SWTException *
    *
  • ERROR_WIDGET_DISPOSED - if the receiver has been * disposed
  • *
  • ERROR_THREAD_INVALID_ACCESS - if not called from the * thread that created the receiver
  • *
*/ public int getGridLineWidth() { checkWidget(); return 0; } /** * Returns the height of the receiver's header * * @return the height of the header or zero if the header is not visible * * @exception 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 2.0 */ public int getHeaderHeight() { return 0; } /** * Returns true if the receiver's header is visible, and * false otherwise. *

* If one of the receiver's ancestors is not visible or some other condition * makes the receiver not visible, this method may still indicate that it is * considered visible even though it may not actually be showing. *

* * @return the receiver's header's visibility state * * @exception SWTException *
    *
  • ERROR_WIDGET_DISPOSED - if the receiver has been * disposed
  • *
  • ERROR_THREAD_INVALID_ACCESS - if not called from the * thread that created the receiver
  • *
*/ public boolean getHeaderVisible() { return false; } /** * Returns the item at the given, zero-relative index in the receiver. * Throws an exception if the index is out of range. * * @param index * the index of the item to return * @return the item at the given index * * @exception IllegalArgumentException *
    *
  • ERROR_INVALID_RANGE - if the index is not between 0 * and the number of elements in the list minus 1 (inclusive) *
  • *
* @exception SWTException *
    *
  • ERROR_WIDGET_DISPOSED - if the receiver has been * disposed
  • *
  • ERROR_THREAD_INVALID_ACCESS - if not called from the * thread that created the receiver
  • *
*/ public TableItem getItem(int index) { checkWidget(); if (!(0 <= index && index < itemCount)) error(SWT.ERROR_INVALID_RANGE); return _getItem(index); } /** * 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. *

* * @param point * the point used to locate the item * @return the item at the given point, or null if the point is not in a * selectable item * * @exception IllegalArgumentException *
    *
  • ERROR_NULL_ARGUMENT - if the point is null
  • *
* @exception SWTException *
    *
  • ERROR_WIDGET_DISPOSED - if the receiver has been * disposed
  • *
  • ERROR_THREAD_INVALID_ACCESS - if not called from the * thread that created the receiver
  • *
*/ public TableItem getItem(Point point) { return null; } /** * Returns the number of items contained in the receiver. * * @return the number of items * * @exception SWTException *
    *
  • ERROR_WIDGET_DISPOSED - if the receiver has been * disposed
  • *
  • ERROR_THREAD_INVALID_ACCESS - if not called from the * thread that created the receiver
  • *
*/ public int getItemCount() { checkWidget(); return itemCount; } /** * Returns the height of the area which would be used to display * one of the items in the receiver. * * @return the height of one item * * @exception SWTException *
    *
  • ERROR_WIDGET_DISPOSED - if the receiver has been * disposed
  • *
  • ERROR_THREAD_INVALID_ACCESS - if not called from the * thread that created the receiver
  • *
*/ public int getItemHeight() { return 0; } /** * Returns a (possibly empty) array of TableItems 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. *

* * @return the items in the receiver * * @exception SWTException *
    *
  • ERROR_WIDGET_DISPOSED - if the receiver has been * disposed
  • *
  • ERROR_THREAD_INVALID_ACCESS - if not called from the * thread that created the receiver
  • *
*/ public TableItem[] getItems() { checkWidget(); TableItem[] result = new TableItem[itemCount]; if ((style & SWT.VIRTUAL) != 0) { for (int i = 0; i < itemCount; i++) { result[i] = _getItem(i); } } else { System.arraycopy(items, 0, result, 0, itemCount); } return result; } /** * Returns true if the receiver's lines are visible, and * false otherwise. Note that some platforms draw grid lines * while others may draw alternating row colors. *

* If one of the receiver's ancestors is not visible or some other condition * makes the receiver not visible, this method may still indicate that it is * considered visible even though it may not actually be showing. *

* * @return the visibility state of the lines * * @exception SWTException *
    *
  • ERROR_WIDGET_DISPOSED - if the receiver has been * disposed
  • *
  • ERROR_THREAD_INVALID_ACCESS - if not called from the * thread that created the receiver
  • *
*/ public boolean getLinesVisible() { return false; } /** * Returns an array of TableItems 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. *

* * @return an array representing the selection * * @exception SWTException *
    *
  • ERROR_WIDGET_DISPOSED - if the receiver has been * disposed
  • *
  • ERROR_THREAD_INVALID_ACCESS - if not called from the * thread that created the receiver
  • *
*/ public TableItem[] getSelection() { return null; } /** * Returns the number of selected items contained in the receiver. * * @return the number of selected items * * @exception SWTException *
    *
  • ERROR_WIDGET_DISPOSED - if the receiver has been * disposed
  • *
  • ERROR_THREAD_INVALID_ACCESS - if not called from the * thread that created the receiver
  • *
*/ public int getSelectionCount() { return 0; } /** * Returns the zero-relative index of the item which is currently selected * in the receiver, or -1 if no item is selected. * * @return the index of the selected item * * @exception SWTException *
    *
  • ERROR_WIDGET_DISPOSED - if the receiver has been * disposed
  • *
  • ERROR_THREAD_INVALID_ACCESS - if not called from the * thread that created the receiver
  • *
*/ public int getSelectionIndex() { return -1; } /** * Returns the zero-relative indices of the items which are currently * selected in the receiver. The order of the indices is unspecified. The * array is empty if 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. *

* * @return the array of indices of the selected items * * @exception SWTException *
    *
  • ERROR_WIDGET_DISPOSED - if the receiver has been * disposed
  • *
  • ERROR_THREAD_INVALID_ACCESS - if not called from the * thread that created the receiver
  • *
*/ public int[] getSelectionIndices() { return new int[0]; } /** * Returns the column which shows the sort indicator for the receiver. The * value may be null if no column shows the sort indicator. * * @return the sort indicator * * @exception 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 #setSortColumn(TableColumn) * * @since 3.2 */ public TableColumn getSortColumn() { checkWidget(); return sortColumn; } /** * Returns the direction of the sort indicator for the receiver. The value * will be one of UP, DOWN or NONE. * * @return the sort direction * * @exception 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 #setSortDirection(int) * * @since 3.2 */ public int getSortDirection() { checkWidget(); return sortDirection; } /** * Returns the zero-relative index of the item which is currently at the top * of the receiver. This index can change when items are scrolled or new * items are added or removed. * * @return the index of the top item * * @exception SWTException *
    *
  • ERROR_WIDGET_DISPOSED - if the receiver has been * disposed
  • *
  • ERROR_THREAD_INVALID_ACCESS - if not called from the * thread that created the receiver
  • *
*/ public int getTopIndex() { return 0; } void hideFirstColumn() { } void hookEvents() { } /** * 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. * * @param column * the search column * @return the index of the column * * @exception IllegalArgumentException *
    *
  • ERROR_NULL_ARGUMENT - if the column is null
  • *
* @exception SWTException *
    *
  • ERROR_WIDGET_DISPOSED - if the receiver has been * disposed
  • *
  • ERROR_THREAD_INVALID_ACCESS - if not called from the * thread that created the receiver
  • *
*/ public int indexOf(TableColumn column) { checkWidget(); if (column == null) error(SWT.ERROR_NULL_ARGUMENT); for (int i = 0; i < columnCount; i++) { if (columns[i] == column) return i; } return -1; } /** * 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. If no item is found, returns -1. * * @param item * the search item * @return the index of the item * * @exception IllegalArgumentException *
    *
  • ERROR_NULL_ARGUMENT - if the item is null
  • *
* @exception SWTException *
    *
  • ERROR_WIDGET_DISPOSED - if the receiver has been * disposed
  • *
  • ERROR_THREAD_INVALID_ACCESS - if not called from the * thread that created the receiver
  • *
*/ public int indexOf(TableItem item) { checkWidget(); if (item == null) error(SWT.ERROR_NULL_ARGUMENT); if (1 <= lastIndexOf && lastIndexOf < itemCount - 1) { if (items[lastIndexOf] == item) return lastIndexOf; if (items[lastIndexOf + 1] == item) return ++lastIndexOf; if (items[lastIndexOf - 1] == item) return --lastIndexOf; } if (lastIndexOf < itemCount / 2) { for (int i = 0; i < itemCount; i++) { if (items[i] == item) return lastIndexOf = i; } } else { for (int i = itemCount - 1; i >= 0; --i) { if (items[i] == item) return lastIndexOf = i; } } return -1; } /** * Returns true if the item is selected, and false * otherwise. Indices out of range are ignored. * * @param index * the index of the item * @return the selection state of the item at the index * * @exception SWTException *
    *
  • ERROR_WIDGET_DISPOSED - if the receiver has been * disposed
  • *
  • ERROR_THREAD_INVALID_ACCESS - if not called from the * thread that created the receiver
  • *
*/ public boolean isSelected(int index) { return false; } boolean mnemonicHit(char key) { for (int i = 0; i < columnCount; i++) { long /* int */labelHandle = columns[i].labelHandle; if (labelHandle != 0 && mnemonicHit(labelHandle, key)) return true; } return false; } boolean mnemonicMatch(char key) { for (int i = 0; i < columnCount; i++) { long /* int */labelHandle = columns[i].labelHandle; if (labelHandle != 0 && mnemonicMatch(labelHandle, key)) return true; } return false; } void recreateRenderers() { } void redrawBackgroundImage() { Control control = findBackgroundControl(); if (control != null && control.backgroundImage != null) { redrawWidget(0, 0, 0, 0, true, false, false); } } void register() { } void releaseChildren(boolean destroy) { if (items != null) { for (int i = 0; i < itemCount; i++) { TableItem item = items[i]; if (item != null && !item.isDisposed()) { item.release(false); } } items = null; } if (columns != null) { for (int i = 0; i < columnCount; i++) { TableColumn column = columns[i]; if (column != null && !column.isDisposed()) { column.release(false); } } columns = null; } super.releaseChildren(destroy); } void releaseWidget() { } /** * Removes the item from the receiver at the given zero-relative index. * * @param index * the index for the item * * @exception IllegalArgumentException *
    *
  • ERROR_INVALID_RANGE - if the index is not between 0 * and the number of elements in the list minus 1 (inclusive) *
  • *
* @exception SWTException *
    *
  • ERROR_WIDGET_DISPOSED - if the receiver has been * disposed
  • *
  • ERROR_THREAD_INVALID_ACCESS - if not called from the * thread that created the receiver
  • *
*/ public void remove(int index) { } /** * Removes the items from the receiver which are between the given * zero-relative start and end indices (inclusive). * * @param start * the start of the range * @param end * the end of the range * * @exception IllegalArgumentException *
    *
  • ERROR_INVALID_RANGE - if either the start or end are * not between 0 and the number of elements in the list minus * 1 (inclusive)
  • *
* @exception SWTException *
    *
  • ERROR_WIDGET_DISPOSED - if the receiver has been * disposed
  • *
  • ERROR_THREAD_INVALID_ACCESS - if not called from the * thread that created the receiver
  • *
*/ public void remove(int start, int end) { } /** * Removes the items from the receiver's list at the given zero-relative * indices. * * @param indices * the array of indices of the items * * @exception IllegalArgumentException *
    *
  • ERROR_INVALID_RANGE - if the index is not between 0 * and the number of elements in the list minus 1 (inclusive) *
  • *
  • ERROR_NULL_ARGUMENT - if the indices array is null
  • *
* @exception SWTException *
    *
  • ERROR_WIDGET_DISPOSED - if the receiver has been * disposed
  • *
  • ERROR_THREAD_INVALID_ACCESS - if not called from the * thread that created the receiver
  • *
*/ public void remove(int[] indices) { } /** * Removes all of the items from the receiver. * * @exception SWTException *
    *
  • ERROR_WIDGET_DISPOSED - if the receiver has been * disposed
  • *
  • ERROR_THREAD_INVALID_ACCESS - if not called from the * thread that created the receiver
  • *
*/ public void removeAll() { } /** * Removes the listener from the collection of listeners who will be * notified when the user changes the receiver's selection. * * @param listener * the listener which should no longer be notified * * @exception IllegalArgumentException *
    *
  • ERROR_NULL_ARGUMENT - if the listener is null
  • *
* @exception 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 SelectionListener * @see #addSelectionListener(SelectionListener) */ public void removeSelectionListener(SelectionListener listener) { checkWidget(); if (listener == null) error(SWT.ERROR_NULL_ARGUMENT); if (eventTable == null) return; eventTable.unhook(SWT.Selection, listener); eventTable.unhook(SWT.DefaultSelection, listener); } void reskinChildren(int flags) { if (items != null) { for (int i = 0; i < itemCount; i++) { TableItem item = items[i]; if (item != null) item.reskin(flags); } } if (columns != null) { for (int i = 0; i < columnCount; i++) { TableColumn column = columns[i]; if (!column.isDisposed()) column.reskin(flags); } } super.reskinChildren(flags); } /** * Selects the item at the given zero-relative index in the receiver. If the * item at the index was already selected, it remains selected. Indices that * are out of range are ignored. * * @param index * the index of the item to select * * @exception SWTException *
    *
  • ERROR_WIDGET_DISPOSED - if the receiver has been * disposed
  • *
  • ERROR_THREAD_INVALID_ACCESS - if not called from the * thread that created the receiver
  • *
*/ public void select(int index) { } /** * Selects the items in the range specified by the given zero-relative * indices in the receiver. The range of indices is inclusive. The current * selection is not cleared before the new items are selected. *

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

* * @param start * the start of the range * @param end * the end of the range * * @exception 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 Table#setSelection(int,int) */ public void select(int start, int end) { } /** * Selects the items at the given zero-relative indices in the receiver. The * current selection is not cleared before the new items are selected. *

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

* * @param indices * the array of indices for the items to select * * @exception IllegalArgumentException *
    *
  • ERROR_NULL_ARGUMENT - if the array of indices is null
  • *
* @exception 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 Table#setSelection(int[]) */ public void select(int[] indices) { } /** * Selects all of the items in the receiver. *

* If the receiver is single-select, do nothing. *

* * @exception SWTException *
    *
  • ERROR_WIDGET_DISPOSED - if the receiver has been * disposed
  • *
  • ERROR_THREAD_INVALID_ACCESS - if not called from the * thread that created the receiver
  • *
*/ public void selectAll() { } void selectFocusIndex(int index) { } int setBounds(int x, int y, int width, int height, boolean move, boolean resize) { return 0; } /** * 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. * * @param order * the new order to display the items * * @exception SWTException *
    *
  • ERROR_WIDGET_DISPOSED - if the receiver has been * disposed
  • *
  • ERROR_THREAD_INVALID_ACCESS - if not called from the * thread that created the receiver
  • *
* @exception IllegalArgumentException *
    *
  • ERROR_NULL_ARGUMENT - if the item order is null
  • *
  • ERROR_INVALID_ARGUMENT - if the item order is not the * same length as the number of items
  • *
* * @see Table#getColumnOrder() * @see TableColumn#getMoveable() * @see TableColumn#setMoveable(boolean) * @see SWT#Move * * @since 3.1 */ public void setColumnOrder(int[] order) { } void setFontDescription(long /* int */font) { super.setFontDescription(font); TableColumn[] columns = getColumns(); for (int i = 0; i < columns.length; i++) { if (columns[i] != null) { columns[i].setFontDescription(font); } } } /** * Marks the receiver's header as visible if the argument is * true, and marks it invisible otherwise. *

* If one of the receiver's ancestors is not visible or some other condition * makes the receiver not visible, marking it visible may not actually cause * it to be displayed. *

* * @param show * the new visibility state * * @exception SWTException *
    *
  • ERROR_WIDGET_DISPOSED - if the receiver has been * disposed
  • *
  • ERROR_THREAD_INVALID_ACCESS - if not called from the * thread that created the receiver
  • *
*/ public void setHeaderVisible(boolean show) { } /** * Sets the number of items contained in the receiver. * * @param count * the number of items * * @exception 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 */ public void setItemCount(int count) { } /** * Marks the receiver's lines as visible if the argument is * true, and marks it invisible otherwise. Note that some * platforms draw grid lines while others may draw alternating row colors. *

* If one of the receiver's ancestors is not visible or some other condition * makes the receiver not visible, marking it visible may not actually cause * it to be displayed. *

* * @param show * the new visibility state * * @exception SWTException *
    *
  • ERROR_WIDGET_DISPOSED - if the receiver has been * disposed
  • *
  • ERROR_THREAD_INVALID_ACCESS - if not called from the * thread that created the receiver
  • *
*/ public void setLinesVisible(boolean show) { } void setOrientation(boolean create) { super.setOrientation(create); for (int i = 0; i < itemCount; i++) { if (items[i] != null) items[i].setOrientation(create); } for (int i = 0; i < columnCount; i++) { if (columns[i] != null) columns[i].setOrientation(create); } } public void setRedraw(boolean redraw) { checkWidget(); super.setRedraw(redraw); if (redraw && drawCount == 0) { /* Resize the item array to match the item count */ if (items.length > 4 && items.length - itemCount > 3) { int length = Math.max(4, (itemCount + 3) / 4 * 4); TableItem[] newItems = new TableItem[length]; System.arraycopy(items, 0, newItems, 0, itemCount); items = newItems; } } } /** * Sets the column used by the sort indicator for the receiver. A null value * will clear the sort indicator. The current sort column is cleared before * the new column is set. * * @param column * the column used by the sort indicator or null * * @exception IllegalArgumentException *
    *
  • ERROR_INVALID_ARGUMENT - if the column is disposed
  • *
* @exception 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.2 */ public void setSortColumn(TableColumn column) { } /** * Sets the direction of the sort indicator for the receiver. The value can * be one of UP, DOWN or NONE. * * @param direction * the direction of the sort indicator * * @exception 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.2 */ public void setSortDirection(int direction) { } /** * Selects the item at the given zero-relative index in the receiver. The * current selection is first cleared, then the new item is selected. * * @param index * the index of the item to select * * @exception 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 Table#deselectAll() * @see Table#select(int) */ public void setSelection(int index) { checkWidget(); boolean fixColumn = showFirstColumn(); deselectAll(); selectFocusIndex(index); showSelection(); if (fixColumn) hideFirstColumn(); } /** * Selects the items in the range specified by the given zero-relative * indices in the receiver. The range of indices is inclusive. The current * selection is cleared before the new items are 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. *

* * @param start * the start index of the items to select * @param end * the end index of the items to select * * @exception 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 Table#deselectAll() * @see Table#select(int,int) */ public void setSelection(int start, int end) { checkWidget(); deselectAll(); if (end < 0 || start > end || ((style & SWT.SINGLE) != 0 && start != end)) return; if (itemCount == 0 || start >= itemCount) return; boolean fixColumn = showFirstColumn(); start = Math.max(0, start); end = Math.min(end, itemCount - 1); selectFocusIndex(start); if ((style & SWT.MULTI) != 0) { select(start, end); } showSelection(); if (fixColumn) hideFirstColumn(); } /** * Selects the items at the given zero-relative indices in the receiver. The * current selection is cleared before the new items are 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. *

* * @param indices * the indices of the items to select * * @exception IllegalArgumentException *
    *
  • ERROR_NULL_ARGUMENT - if the array of indices is null
  • *
* @exception 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 Table#deselectAll() * @see Table#select(int[]) */ public void setSelection(int[] indices) { checkWidget(); if (indices == null) error(SWT.ERROR_NULL_ARGUMENT); deselectAll(); int length = indices.length; if (length == 0 || ((style & SWT.SINGLE) != 0 && length > 1)) return; boolean fixColumn = showFirstColumn(); selectFocusIndex(indices[0]); if ((style & SWT.MULTI) != 0) { select(indices); } showSelection(); if (fixColumn) hideFirstColumn(); } /** * Sets the receiver's selection to the given item. The current selection is * cleared before the new item is selected. *

* If the item is not in the receiver, then it is ignored. *

* * @param item * the item to select * * @exception IllegalArgumentException *
    *
  • ERROR_NULL_ARGUMENT - if the item is null
  • *
  • ERROR_INVALID_ARGUMENT - if the item has been disposed *
  • *
* @exception 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.2 */ public void setSelection(TableItem item) { if (item == null) error(SWT.ERROR_NULL_ARGUMENT); setSelection(new TableItem[] { item }); } /** * Sets the receiver's selection to be the given array of items. The current * selection is cleared before the new items are selected. *

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

* * @param items * the array of items * * @exception IllegalArgumentException *
    *
  • ERROR_NULL_ARGUMENT - if the array of items is null
  • *
  • ERROR_INVALID_ARGUMENT - if one of the items has been * disposed
  • *
* @exception 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 Table#deselectAll() * @see Table#select(int[]) * @see Table#setSelection(int[]) */ public void setSelection(TableItem[] items) { checkWidget(); if (items == null) error(SWT.ERROR_NULL_ARGUMENT); boolean fixColumn = showFirstColumn(); deselectAll(); int length = items.length; if (!(length == 0 || ((style & SWT.SINGLE) != 0 && length > 1))) { boolean first = true; for (int i = 0; i < length; i++) { int index = indexOf(items[i]); if (index != -1) { if (first) { first = false; selectFocusIndex(index); } else { select(index); } } } showSelection(); } if (fixColumn) hideFirstColumn(); } /** * Sets the zero-relative index of the item which is currently at the top of * the receiver. This index can change when items are scrolled or new items * are added and removed. * * @param index * the index of the top item * * @exception SWTException *
    *
  • ERROR_WIDGET_DISPOSED - if the receiver has been * disposed
  • *
  • ERROR_THREAD_INVALID_ACCESS - if not called from the * thread that created the receiver
  • *
*/ public void setTopIndex(int index) { } /** * Shows the column. If the column is already showing in the receiver, this * method simply returns. Otherwise, the columns are scrolled until the * column is visible. * * @param column * the column to be shown * * @exception IllegalArgumentException *
    *
  • ERROR_NULL_ARGUMENT - if the column is null
  • *
  • ERROR_INVALID_ARGUMENT - if the column has been * disposed
  • *
* @exception 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 */ public void showColumn(TableColumn column) { } boolean showFirstColumn() { return true; } /** * Shows the item. If the item is already showing in the receiver, this * method simply returns. Otherwise, the items are scrolled until the item * is visible. * * @param item * the item to be shown * * @exception IllegalArgumentException *
    *
  • ERROR_NULL_ARGUMENT - if the item is null
  • *
  • ERROR_INVALID_ARGUMENT - if the item has been disposed *
  • *
* @exception 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 Table#showSelection() */ public void showItem(TableItem item) { } /** * Shows the selection. If the selection is already showing in the receiver, * this method simply returns. Otherwise, the items are scrolled until the * selection is visible. * * @exception 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 Table#showItem(TableItem) */ public void showSelection() { } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy