X-Git-Url: https://git.argeo.org/?a=blobdiff_plain;f=eclipse%2Forg.argeo.cms.swt%2Fsrc%2Forg%2Fargeo%2Fcms%2Fswt%2Fwidgets%2FSwtTabularPart.java;h=9872551be31546742f86287f520442915c53f43f;hb=5c9bae758b5bb13ff3b046ad680886ae540865e8;hp=02f2f815354e332d0c8617f9fd4f7173b37295e6;hpb=3b4d58678c32d2ca70c79e128e3bde0f6c9cd291;p=lgpl%2Fargeo-commons.git diff --git a/eclipse/org.argeo.cms.swt/src/org/argeo/cms/swt/widgets/SwtTabularPart.java b/eclipse/org.argeo.cms.swt/src/org/argeo/cms/swt/widgets/SwtTabularPart.java index 02f2f8153..9872551be 100644 --- a/eclipse/org.argeo.cms.swt/src/org/argeo/cms/swt/widgets/SwtTabularPart.java +++ b/eclipse/org.argeo.cms.swt/src/org/argeo/cms/swt/widgets/SwtTabularPart.java @@ -3,12 +3,14 @@ package org.argeo.cms.swt.widgets; 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}. */ @@ -24,6 +26,7 @@ public class SwtTabularPart implements TabularPart { area = new Composite(parent, style); area.setLayout(CmsSwtUtils.noSpaceGridLayout()); table = new Table(area, SWT.VIRTUAL | SWT.BORDER); + table.setLinesVisible(true); } @Override @@ -67,13 +70,23 @@ public class SwtTabularPart implements TabularPart { } protected void refreshItem(TableItem item) { - + int row = getTable().indexOf(item); + for (int i = 0; i < item.getParent().getColumnCount(); i++) { + Column column = (Column) 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; } @@ -86,4 +99,16 @@ public class SwtTabularPart implements TabularPart { 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; + } + }