import java.util.function.Consumer;
import org.argeo.cms.swt.CmsSwtUtils;
+import org.argeo.cms.ux.widgets.Column;
import org.argeo.cms.ux.widgets.TabularPart;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.widgets.TableItem;
/** {@link TabularPart} implementation based on a {@link Table}. */
area = new Composite(parent, style);
area.setLayout(CmsSwtUtils.noSpaceGridLayout());
table = new Table(area, SWT.VIRTUAL | SWT.BORDER);
+ table.setLinesVisible(true);
}
@Override
}
protected void refreshItem(TableItem item) {
-
+ int row = getTable().indexOf(item);
+ for (int i = 0; i < item.getParent().getColumnCount(); i++) {
+ Column<Object> column = (Column<Object>) item.getParent().getColumn(i).getData();
+ Object data = getData(row);
+ String text = data != null ? column.getText(data) : "";
+ item.setText(i, text);
+ }
}
protected int getItemCount() {
return 0;
}
+ protected Object getData(int row) {
+ return null;
+ }
+
protected Table getTable() {
return table;
}
this.onAction = onAction;
}
+ @Override
+ public void addColumn(Column<?> column) {
+ TableColumn swtColumn = new TableColumn(table, SWT.NONE);
+ swtColumn.setWidth(column.getWidth());
+ swtColumn.setData(column);
+
+ }
+
+ public Composite getArea() {
+ return area;
+ }
+
}