X-Git-Url: https://git.argeo.org/?a=blobdiff_plain;f=swt%2Forg.argeo.cms.swt%2Fsrc%2Forg%2Fargeo%2Fcms%2Fswt%2Fwidgets%2FSwtTreeView.java;h=778ed41387459453c5625eb899e27b5f7e80f9b6;hb=84914c5224fe7d441cc10f30b8418bf4ac4b0a0f;hp=a0ac24836c4cb3aa393f11e1d868e91972501be3;hpb=1afc194a1c02c9b1287ae7b319f831792fe96e8d;p=lgpl%2Fargeo-commons.git diff --git a/swt/org.argeo.cms.swt/src/org/argeo/cms/swt/widgets/SwtTreeView.java b/swt/org.argeo.cms.swt/src/org/argeo/cms/swt/widgets/SwtTreeView.java index a0ac24836..778ed4138 100644 --- a/swt/org.argeo.cms.swt/src/org/argeo/cms/swt/widgets/SwtTreeView.java +++ b/swt/org.argeo.cms.swt/src/org/argeo/cms/swt/widgets/SwtTreeView.java @@ -2,9 +2,11 @@ package org.argeo.cms.swt.widgets; import java.util.List; +import org.argeo.api.cms.CmsLog; import org.argeo.api.cms.ux.CmsIcon; import org.argeo.cms.swt.CmsSwtTheme; import org.argeo.cms.swt.CmsSwtUtils; +import org.argeo.cms.ux.widgets.Column; import org.argeo.cms.ux.widgets.HierarchicalPart; import org.eclipse.swt.SWT; import org.eclipse.swt.graphics.Image; @@ -14,6 +16,8 @@ import org.eclipse.swt.widgets.TreeItem; /** View of a {@link HierarchicalPart} based on a {@link Tree}. */ public class SwtTreeView extends AbstractSwtView { + private final static CmsLog log = CmsLog.getLog(SwtTreeView.class); + private static final long serialVersionUID = -6247710601465713047L; private final Tree tree; @@ -42,7 +46,12 @@ public class SwtTreeView extends AbstractSwtView { List rootItems = hierarchicalPart.getChildren(hierarchicalPart.getInput()); for (T child : rootItems) { - addTreeItem(null, child); + try { + addTreeItem(null, child); + } catch (Exception e) { + if (log.isTraceEnabled()) + log.error("Cannot retrieve child", e); + } } tree.addListener(SWT.Expand, event -> { @@ -68,27 +77,28 @@ public class SwtTreeView extends AbstractSwtView { protected TreeItem addTreeItem(TreeItem parent, T data) { TreeItem item = parent == null ? new TreeItem(tree, SWT.NONE) : new TreeItem(parent, SWT.NONE); item.setData(data); - String txt = hierarchicalPart.getText(data); - if (txt != null) - item.setText(hierarchicalPart.getText(data)); - CmsIcon icon = hierarchicalPart.getIcon(data); - if (icon != null) { - Image image = theme.getSmallIcon(icon); - item.setImage(image); + for (int i = 0; i < hierarchicalPart.getColumnCount(); i++) { + Column column = hierarchicalPart.getColumn(i); + String txt = column.getText(data); + if (txt != null) + item.setText(txt); + CmsIcon icon = column.getIcon(data); + if (icon != null) { + Image image = theme.getSmallIcon(icon); + item.setImage(image); + } } - // TODO optimize + // TODO optimise List grandChildren = hierarchicalPart.getChildren(data); if (grandChildren.size() != 0) new TreeItem(item, SWT.NONE); return item; } - - @Override public void notifyItemCountChange() { // TODO what to update ? - + } protected Tree getTree() {