How can I insert a SWT Button control into JFace TableViewer ?
The answer given is nice a nice way to implement your own buttons with custom drawings, in or outside the a table. However, you can put SWT controls in JFace Tables.
http://www.java2s.com/Code/Java/SWT-JFace-Eclipse/PlacearbitrarycontrolsinaSWTtable.htm
The solution for building a table with columns containing comboboxes, text fields, and buttons provided by the link is:
Table table = new Table(shell, SWT.BORDER | SWT.MULTI);
table.setLinesVisible(true);
for (int i = 0; i < 3; i++) {
TableColumn column = new TableColumn(table, SWT.NONE);
column.setWidth(100);
}
for (int i = 0; i < 12; i++) {
new TableItem(table, SWT.NONE);
}
TableItem[] items = table.getItems();
for (int i = 0; i < items.length; i++) {
TableEditor editor = new TableEditor(table);
CCombo combo = new CCombo(table, SWT.NONE);
editor.grabHorizontal = true;
editor.setEditor(combo, items[i], 0);
editor = new TableEditor(table);
Text text = new Text(table, SWT.NONE);
editor.grabHorizontal = true;
editor.setEditor(text, items[i], 1);
editor = new TableEditor(table);
Button button = new Button(table, SWT.CHECK);
button.pack();
editor.minimumWidth = button.getSize().x;
editor.horizontalAlignment = SWT.LEFT;
editor.setEditor(button, items[i], 2);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With