下面列出了org.eclipse.swt.widgets.TableItem#getParent ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@Override
public void update(@Nullable ViewerCell cell) {
if (cell == null) {
return;
}
/* Create a button if it doesn't exist */
ChartSeriesDialog series = (ChartSeriesDialog) cell.getViewerRow().getElement();
Button button = series.getButton();
/* Set the position of the button into the cell */
TableItem item = (TableItem) cell.getItem();
TableEditor editor = new TableEditor(item.getParent());
editor.grabHorizontal = true;
editor.grabVertical = true;
editor.setEditor(button, item, cell.getColumnIndex());
editor.layout();
}
public static TableEditor createCheckBoxTableEditor(TableItem tableItem,
boolean selection, int column) {
Table table = tableItem.getParent();
final Button checkBox = new Button(table, SWT.CHECK);
checkBox.pack();
TableEditor editor = new TableEditor(table);
editor.minimumWidth = checkBox.getSize().x;
editor.horizontalAlignment = SWT.CENTER;
editor.setEditor(checkBox, tableItem, column);
checkBox.setSelection(selection);
return editor;
}
public static TableEditor createCheckBoxTableEditor(TableItem tableItem, boolean selection, int column) {
final Table table = tableItem.getParent();
final Button checkBox = new Button(table, SWT.CHECK);
checkBox.pack();
final TableEditor editor = new TableEditor(table);
editor.minimumWidth = checkBox.getSize().x;
editor.horizontalAlignment = SWT.CENTER;
editor.setEditor(checkBox, tableItem, column);
checkBox.setSelection(selection);
return editor;
}
/**
* Gets the index.
*
* @param item the item
* @return the index
*/
public static int getIndex(TableItem item) {
Table parent = item.getParent();
TableItem[] items = parent.getItems();
for (int i = items.length - 1; i >= 0; i--) {
if (items[i] == item)
return i;
}
throw new InternalErrorCDE("invalid state"); //$NON-NLS-1$
}
/**
* Swap table items.
*
* @param itemBelow the item below
* @param newSelection the new selection
*/
public static void swapTableItems(TableItem itemBelow, int newSelection) {
Table parent = itemBelow.getParent();
int i = getIndex(itemBelow);
TableItem itemAbove = parent.getItems()[i - 1];
TableItem newItemAbove = new TableItem(parent, SWT.NONE, i - 1);
copyTableItem(newItemAbove, itemBelow);
TableItem newItemBelow = new TableItem(parent, SWT.NONE, i);
copyTableItem(newItemBelow, itemAbove);
itemAbove.dispose();
itemBelow.dispose();
parent.setSelection(newSelection);
}
public static TableEditor createCheckBoxTableEditor(final TableItem tableItem, final boolean selection, final int column) {
final Table table = tableItem.getParent();
final Button checkBox = new Button(table, SWT.CHECK);
checkBox.pack();
final TableEditor editor = new TableEditor(table);
editor.minimumWidth = checkBox.getSize().x;
editor.horizontalAlignment = SWT.CENTER;
editor.setEditor(checkBox, tableItem, column);
checkBox.setSelection(selection);
return editor;
}