0

我曾经ListEditor允许编辑儿童列表,我所做的一切就像我在一些示例中看到的那样。与示例的唯一区别是我希望将编辑儿童的小部件作为选项卡添加到某些TabLayoutPanel.

问题是我想给这个新选项卡一个标题,这个标题不是恒定的,而是取决于新创建的子编辑器正在编辑的对象(所以让标题是child.getName()),我不知道内部EditorSource#create()方法。

ListEditor<ChildProxy, ChildPanel> children = ListEditor
        .of(new EditorSource<ChildPanel>() {

            @Override
            public ChildPanel create(int index) {
                ChildPanel tab = new ChildPanel();
                //here's a problem, how I can get tabHeader here?
                tabPanel.add(tab,tabHeader);
            }

        });

如何将依赖于值的标题设置为由创建的选项卡create()?任何帮助/解决方法将不胜感激。

4

2 回答 2

0

这种方法是否适合您:

public class ChildrenEditor extends Composite implements
        IsEditor<ListEditor<Child, ChildInTabEditor>> {


    ListEditor<Child, ChildInTabEditor> editor;

    public ChildrenEditor() {
        initWidget(uiBinder.createAndBindUi(this));
        editor = ListEditor.of(new ChildInTabEditorSource());
    }


    private class ChildInTabEditorSource extends EditorSource<ChildInTabEditor> {

            public ChildInTabEditor create(int index) {
                ChildInTabEditor tab = new ChildInTabEditor();
                // here's the trick :
                Child child = editor.getList().get(index);
                tabPanel.add(tab,child.getTabTitle());
                return tab;
            }

      }

    @Override
    public ListEditor<Child, ChildInTabEditor> asEditor() {
        return editor;
    }


}

ChildInTabEditor也必须是实现的选项卡Editor<Child>

于 2012-05-05T21:58:13.427 回答
0

对我有用的是传递tabPanelindex新创建ChildPanel()并制作它ValueAwareEditor。然后我在给定的参考上setValue()设置标题。tabPanelindex

于 2012-05-06T06:45:29.117 回答