我不确定这是否是一个有效的问题,但我有一个CompositeCell作为参数来构造DefaultNodeInfo,它是TreeViewModel.
基本上,CompositeCell看起来像这样:
Tree item1[button1]
Tree item2[button2]
...
现在我想设置树项目和按钮之间的间距:
Tree item1 [button1]
我不确定如何实现这一目标。也许CompositeCell不适合我,因为它没有setSpacing方法?
但无论如何我都需要一个 Cell 来构建一个NodeInfo.
=========================================
让我把我的问题说得更清楚。
我唯一Widget拥有的是CellTree。要构建一个CellTree我需要提供一个TreeViewModel:
cellTree = new CellTree(
new SomeTreeViewModel(), null);
要构建一个TreeViewModel我需要提供的DefaultNodeInfo. 换句话说,要覆盖以下方法TreeViewModel:
public <T> NodeInfo<?> getNodeInfo(final T value)
构造一个DefaultNodeInfo:
public DefaultNodeInfo(AbstractDataProvider<T> dataProvider, Cell<T> cell)
我必须提供一个Cell(终于来到我的问题......)
Cell不是一个Widget接口,而只是一个接口。
在这里我需要一个CompositeCell包含一个AbstractCell:
Tree item1
和一个ButtonCell:
[button1]
将CompositeCell如下所示:
Tree item1[button1]
我想在其中一个或任何上设置样式ButtonCell以CompositeCell添加Cell间距:
Tree item1 [button1]
我认为 apply css onCellTree不会有帮助,因为它只会影响树的样式,但不会影响树的项目......
实际上我找到了一种解决方法,但我认为不鼓励这样做,即覆盖ButtonCell'srender方法:
public void render(final Context context, final SafeHtml data,
final SafeHtmlBuilder sb) {
sb.appendHtmlConstant("<button type=\"button\" tabindex=\"-1\" style=\"margin-left:10px;\">");
if (data != null) {
sb.append(data);
}
sb.appendHtmlConstant("</button>");
}
还有其他想法吗?