-
Notifications
You must be signed in to change notification settings - Fork 4
/
TableWithCheckbox.java
52 lines (44 loc) · 1.84 KB
/
TableWithCheckbox.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package org.eclipse.swt.table;
import org.eclipse.jface.layout.GridDataFactory;
import org.eclipse.jface.layout.GridLayoutFactory;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.widgets.TableItem;
import com.xored.q7.quality.mockups.issues.BaseMockupPart;
public class TableWithCheckbox extends BaseMockupPart {
public Control construct(Composite parent) {
final Composite composite = new Composite(parent, SWT.NONE);
GridDataFactory.swtDefaults().align(SWT.FILL, SWT.FILL)
.grab(true, true).applyTo(composite);
GridLayoutFactory.swtDefaults().numColumns(2).applyTo(composite);
// GridLayout layout = new GridLayout();
Table table = new Table (composite, SWT.CHECK | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
table.setLinesVisible (true);
table.setHeaderVisible (true);
TableColumn column1 = new TableColumn(table, SWT.NONE);
column1.setText("Column with checkbox ");
column1.setWidth(100);
TableColumn column2 = new TableColumn(table, SWT.NONE);
column2.setText("Description");
column2.setWidth(100);
for (int i=0; i<12; i++) {
TableItem item = new TableItem (table, SWT.NONE);
item.setText ("Item " + i);
}
Rectangle clientArea = composite.getClientArea ();
table.setBounds (clientArea.x, clientArea.y, 100, 100);
table.addListener (SWT.Selection, new Listener () {
public void handleEvent (Event event) {
String string = event.detail == SWT.CHECK ? "Checked" : "Selected";
System.out.println (event.item + " " + string);
}
});
return null;
}
}