summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGrant Gayed <grant_gayed@ca.ibm.com>2011-11-14 16:43:40 -0500
committerGrant Gayed <grant_gayed@ca.ibm.com>2011-11-14 16:43:40 -0500
commit8408c47be362b7ceb8525d3e74f67c3e07c5b850 (patch)
tree385b8cc3ccd6371aadb2a2192d3c1e3a1295e5ad
parent795366956cb674108ab2225a723afd46205c3f87 (diff)
downloadeclipse.platform.swt-8408c47be362b7ceb8525d3e74f67c3e07c5b850.tar.gz
eclipse.platform.swt-8408c47be362b7ceb8525d3e74f67c3e07c5b850.tar.xz
eclipse.platform.swt-8408c47be362b7ceb8525d3e74f67c3e07c5b850.zip
javadoc fixes
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/TableCursor.java115
1 files changed, 8 insertions, 107 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/TableCursor.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/TableCursor.java
index 0408aa5fd7..a597b782e5 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/TableCursor.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/TableCursor.java
@@ -20,108 +20,9 @@ import org.eclipse.swt.events.*;
* A TableCursor provides a way for the user to navigate around a Table
* using the keyboard. It also provides a mechanism for selecting an
* individual cell in a table.
- *
- * <p> Here is an example of using a TableCursor to navigate to a cell and then edit it.
- *
- * <code><pre>
- * public static void main(String[] args) {
- * Display display = new Display();
- * Shell shell = new Shell(display);
- * shell.setLayout(new GridLayout());
- *
- * // create a a table with 3 columns and fill with data
- * final Table table = new Table(shell, SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION);
- * table.setLayoutData(new GridData(GridData.FILL_BOTH));
- * TableColumn column1 = new TableColumn(table, SWT.NONE);
- * TableColumn column2 = new TableColumn(table, SWT.NONE);
- * TableColumn column3 = new TableColumn(table, SWT.NONE);
- * for (int i = 0; i &lt; 100; i++) {
- * TableItem item = new TableItem(table, SWT.NONE);
- * item.setText(new String[] { "cell "+i+" 0", "cell "+i+" 1", "cell "+i+" 2"});
- * }
- * column1.pack();
- * column2.pack();
- * column3.pack();
- *
- * // create a TableCursor to navigate around the table
- * final TableCursor cursor = new TableCursor(table, SWT.NONE);
- * // create an editor to edit the cell when the user hits "ENTER"
- * // while over a cell in the table
- * final ControlEditor editor = new ControlEditor(cursor);
- * editor.grabHorizontal = true;
- * editor.grabVertical = true;
- *
- * cursor.addSelectionListener(new SelectionAdapter() {
- * // when the TableEditor is over a cell, select the corresponding row in
- * // the table
- * public void widgetSelected(SelectionEvent e) {
- * table.setSelection(new TableItem[] {cursor.getRow()});
- * }
- * // when the user hits "ENTER" in the TableCursor, pop up a text editor so that
- * // they can change the text of the cell
- * public void widgetDefaultSelected(SelectionEvent e){
- * final Text text = new Text(cursor, SWT.NONE);
- * TableItem row = cursor.getRow();
- * int column = cursor.getColumn();
- * text.setText(row.getText(column));
- * text.addKeyListener(new KeyAdapter() {
- * public void keyPressed(KeyEvent e) {
- * // close the text editor and copy the data over
- * // when the user hits "ENTER"
- * if (e.character == SWT.CR) {
- * TableItem row = cursor.getRow();
- * int column = cursor.getColumn();
- * row.setText(column, text.getText());
- * text.dispose();
- * }
- * // close the text editor when the user hits "ESC"
- * if (e.character == SWT.ESC) {
- * text.dispose();
- * }
- * }
- * });
- * editor.setEditor(text);
- * text.setFocus();
- * }
- * });
- * // Hide the TableCursor when the user hits the "MOD1" or "MOD2" key.
- * // This allows the user to select multiple items in the table.
- * cursor.addKeyListener(new KeyAdapter() {
- * public void keyPressed(KeyEvent e) {
- * if (e.keyCode == SWT.MOD1 ||
- * e.keyCode == SWT.MOD2 ||
- * (e.stateMask & SWT.MOD1) != 0 ||
- * (e.stateMask & SWT.MOD2) != 0) {
- * cursor.setVisible(false);
- * }
- * }
- * });
- * // Show the TableCursor when the user releases the "MOD2" or "MOD1" key.
- * // This signals the end of the multiple selection task.
- * table.addKeyListener(new KeyAdapter() {
- * public void keyReleased(KeyEvent e) {
- * if (e.keyCode == SWT.MOD1 && (e.stateMask & SWT.MOD2) != 0) return;
- * if (e.keyCode == SWT.MOD2 && (e.stateMask & SWT.MOD1) != 0) return;
- * if (e.keyCode != SWT.MOD1 && (e.stateMask & SWT.MOD1) != 0) return;
- * if (e.keyCode != SWT.MOD2 && (e.stateMask & SWT.MOD2) != 0) return;
- *
- * TableItem[] selection = table.getSelection();
- * TableItem row = (selection.length == 0) ? table.getItem(table.getTopIndex()) : selection[0];
- * table.showItem(row);
- * cursor.setSelection(row, 0);
- * cursor.setVisible(true);
- * cursor.setFocus();
- * }
- * });
- *
- * shell.open();
- * while (!shell.isDisposed()) {
- * if (!display.readAndDispatch())
- * display.sleep();
- * }
- * display.dispose();
- * }
- * </pre></code>
+ * <p>
+ * For a detailed example of using a TableCursor to navigate to a cell and then edit it see
+ * http://git.eclipse.org/c/platform/eclipse.platform.swt.git/tree/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet96.java .
*
* <dl>
* <dt><b>Styles:</b></dt>
@@ -144,7 +45,7 @@ public class TableCursor extends Canvas {
Color background = null;
Color foreground = null;
- // By default, invert the list selection colors
+ /* By default, invert the list selection colors */
static final int BACKGROUND = SWT.COLOR_LIST_SELECTION_TEXT;
static final int FOREGROUND = SWT.COLOR_LIST_SELECTION;
@@ -414,7 +315,6 @@ void paint(Event event) {
if (row == null) return;
int columnIndex = column == null ? 0 : table.indexOf(column);
GC gc = event.gc;
- Display display = getDisplay();
gc.setBackground(getBackground());
gc.setForeground(getForeground());
gc.fillRectangle(event.x, event.y, event.width, event.height);
@@ -472,6 +372,7 @@ void paint(Event event) {
gc.drawString(text, x, textY);
}
if (isFocusControl()) {
+ Display display = getDisplay();
gc.setBackground(display.getSystemColor(SWT.COLOR_BLACK));
gc.setForeground(display.getSystemColor(SWT.COLOR_WHITE));
gc.drawFocus(0, 0, size.x, size.y);
@@ -621,9 +522,9 @@ void _resize() {
}
}
/**
- * Returns the column over which the TableCursor is positioned.
+ * Returns the index of the column over which the TableCursor is positioned.
*
- * @return the column for the current position
+ * @return the column index for the current position
*
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
@@ -661,7 +562,7 @@ public Color getForeground() {
/**
* Returns the row over which the TableCursor is positioned.
*
- * @return the item for the current position
+ * @return the item for the current position, or <code>null</code> if none
*
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>