}
}
+ protected void notifyItemCountChange() {
+ for (DataView<INPUT, T> view : views.keySet()) {
+ view.notifyItemCountChange();
+ }
+ }
+
@Override
public void addView(DataView<INPUT, T> view) {
views.put(view, new Object());
return columns.get(index);
}
+ @Override
public void addColumn(Column<T> column) {
columns.add(column);
}
import org.argeo.api.cms.ux.CmsIcon;
+/** A column in a data representation. */
+@FunctionalInterface
public interface Column<T> {
String getText(T model);
public interface DataView<INPUT,TYPE> {
void refresh();
+
+ void notifyItemCountChange();
}
import org.argeo.api.cms.ux.CmsIcon;
+/** A hierarchical representation of data. */
public interface HierarchicalPart<T> extends ColumnsPart<T, T> {
List<T> getChildren(T parent);
package org.argeo.cms.ux.widgets;
+/** A tabular presentation of data. */
public interface TabularPart<INPUT, T> extends ColumnsPart<INPUT, T> {
int getItemCount();
Column<T> getColumn(int index);
+ void addColumn(Column<T> column);
+
int getColumnCount();
}
import org.argeo.cms.swt.CmsSwtUtils;
import org.argeo.cms.ux.widgets.DataPart;
import org.argeo.cms.ux.widgets.DataView;
+import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.widgets.Composite;
protected final SelectionListener selectionListener;
@SuppressWarnings("unchecked")
- public AbstractSwtView(Composite parent, int style, DataPart<INPUT, TYPE> dataPart) {
- super(parent, style);
+ public AbstractSwtView(Composite parent, DataPart<INPUT, TYPE> dataPart) {
+ super(parent, SWT.NONE);
setLayout(CmsSwtUtils.noSpaceGridLayout());
this.dataPart = dataPart;
private CmsSwtTheme theme;
public SwtTableView(Composite parent, int style, TabularPart<INPUT, T> tabularPart) {
- super(parent, style, tabularPart);
+ super(parent, tabularPart);
theme = CmsSwtUtils.getCmsTheme(parent);
- table = new Table(this, SWT.VIRTUAL | SWT.BORDER);
+ table = new Table(this, SWT.VIRTUAL | style);
table.setLinesVisible(true);
table.setLayoutData(CmsSwtUtils.fillAll());
}
}
+ @Override
+ public void notifyItemCountChange() {
+ table.setItemCount(tabularPart.getItemCount());
+ }
+
protected Table getTable() {
return table;
}
private CmsSwtTheme theme;
public SwtTreeView(Composite parent, int style, HierarchicalPart<T> hierarchicalPart) {
- super(parent, style, hierarchicalPart);
+ super(parent, hierarchicalPart);
theme = CmsSwtUtils.getCmsTheme(parent);
- tree = new Tree(this, SWT.BORDER);
+ tree = new Tree(this, style);
tree.setLayoutData(CmsSwtUtils.fillAll());
this.hierarchicalPart = hierarchicalPart;
new TreeItem(item, SWT.NONE);
return item;
}
+
+
+
+ @Override
+ public void notifyItemCountChange() {
+ // TODO what to update ?
+
+ }
protected Tree getTree() {
return tree;