use of org.eclipse.swt.custom.TableEditor in project eclipse.platform.swt by eclipse.
the class StackLayoutTab method createChildWidgets.
/**
* Creates the widgets in the "child" group.
*/
@Override
void createChildWidgets() {
/* Add common controls */
super.createChildWidgets();
/* Add TableEditors */
comboEditor = new TableEditor(table);
nameEditor = new TableEditor(table);
table.addMouseListener(MouseListener.mouseDownAdapter(e -> {
resetEditors();
index = table.getSelectionIndex();
if (index == -1)
return;
// set top layer of stack to the selected item
setTopControl(index);
TableItem oldItem = comboEditor.getItem();
newItem = table.getItem(index);
if (newItem == oldItem || newItem != lastSelected) {
lastSelected = newItem;
return;
}
table.showSelection();
combo = new CCombo(table, SWT.READ_ONLY);
createComboEditor(combo, comboEditor);
nameText = new Text(table, SWT.SINGLE);
nameText.setText(data.get(index)[NAME_COL]);
createTextEditor(nameText, nameEditor, NAME_COL);
}));
}
use of org.eclipse.swt.custom.TableEditor in project eclipse.platform.swt by eclipse.
the class MJ_Table method tableEditor_multiple_controls_Snippet149.
/**
* Snippet 149 was modified.
* - No added columns.
* - Button instead of progress bar.
*/
@Test
public void tableEditor_multiple_controls_Snippet149() {
knownToBeBrokenGtk3("Snippet is broken on Gtk3. See Bug 531885");
Shell shell = mkShell("Items should be replaced with Buttons (broken on Gtk3, Bug 531885)");
shell.setLayout(new FillLayout());
Table table = new Table(shell, SWT.BORDER);
for (int i = 0; i < 20; i++) {
TableItem item = new TableItem(table, SWT.NONE);
item.setText("Task " + i);
Button button = new Button(table, SWT.NONE);
button.setText("hello world " + i);
button.setVisible(true);
button.addSelectionListener(new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent e) {
System.out.println("Button pressed");
}
@Override
public void widgetDefaultSelected(SelectionEvent e) {
}
});
TableEditor editor = new TableEditor(table);
editor.grabHorizontal = editor.grabVertical = true;
editor.setEditor(button, item, 0);
}
shell.setSize(SWIDTH, SHEIGHT);
shell.open();
mainLoop(shell);
}
use of org.eclipse.swt.custom.TableEditor in project eclipse.platform.swt by eclipse.
the class Bug166720_TableEditorFlicker method main.
public static void main(String[] args) {
Display display = new Display();
Shell shell = new Shell(display);
shell.setLayout(new GridLayout());
Table table = new Table(shell, SWT.BORDER | SWT.MULTI);
GridData gd = new GridData(GridData.FILL_BOTH);
gd.heightHint = 200;
gd.widthHint = 200;
table.setLayoutData(gd);
TableColumn column = new TableColumn(table, SWT.NONE);
column.setWidth(100);
for (int i = 0; i < 100; i++) {
new TableItem(table, SWT.NONE);
}
TableItem[] items = table.getItems();
for (int i = 0; i < items.length; i++) {
TableEditor editor = new TableEditor(table);
editor = new TableEditor(table);
Text text = new Text(table, SWT.NONE);
text.setText("Text" + i);
editor.grabHorizontal = true;
editor.setEditor(text, items[i], 0);
editor = new TableEditor(table);
}
shell.pack();
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
display.dispose();
}
Aggregations