I’ma having an issue retrieving data from the table that I’ve created. It displays a check box, string (taken from all_mapping_objects which is added first) and drop down combo with values 0.0 to 1.0. How do I retrieve the all the values once they have been edited in the table, i.e. check box boolean, string value and combo value.
Tried some variations of TableItem[] items = table.getItems() but I only get back empty values.
final Table table = new Table(sectionsInfo, SWT.BORDER | SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
table.setLinesVisible(true);
InfogridData = new GridData();
InfogridData.horizontalSpan = 4;
InfogridData.horizontalAlignment = GridData.BEGINNING;
InfogridData.horizontalAlignment = GridData.FILL;
InfogridData.grabExcessHorizontalSpace = true;
InfogridData.verticalAlignment = GridData.BEGINNING;
InfogridData.verticalAlignment = GridData.FILL;
InfogridData.grabExcessVerticalSpace= true;
TableColumn column = new TableColumn(table, SWT.NONE);
column.setWidth(500);
TableColumn column2 = new TableColumn(table, SWT.NONE);
column2.setWidth(50);
table.setLayoutData(InfogridData);
for (int i = 0; i < all_mapping_objects.size(); i++) {
new TableItem(table, SWT.NONE);
}
TableItem[] items = table.getItems();
for (int i = 0; i < items.length; i++) {
TableEditor editor = new TableEditor(table); //defines editor which controls objects put in
CCombo combo = new CCombo(table, SWT.NONE | SWT.READ_ONLY);
editor.grabHorizontal = true;
for (float me = 0; me <= 10; me++) {
combo.add("" + me/10);
}
combo.setText("1.0");
editor.setEditor(combo, items[i], 1); // sets the column
editor = new TableEditor(table);
Button button = new Button(table, SWT.CHECK);
button.setText(all_mapping_objects.get(i).getTextf()); // mapping objects written to the table
button.pack();
editor.minimumWidth = button.getSize().x;
editor.horizontalAlignment = SWT.LEFT;
editor.setEditor(button, items[i], 0); // sets the column
}
You should use SelectionListener on
Button ( SWT.CHECK)and similarly forCCombo. I suggest you to start usingTableViewerinstead working with SWT Table.