So trying to wrap my head around the Editor Framework and ListEditor in 
particular...

I have a class that basically has 1 property, an ArrayList:

public class ArticlePaginator implements Iterable<ArticlePage> {
    
    ArrayList<ArticlePage> articlePages = new ArrayList<ArticlePage>();

    public ArticlePaginator(ThriftWidget tw) {
        
        for (ThriftWidget subTw : tw.getSubWidgets()) {
            articlePages.add(new ArticlePage(subTw));
        }
        
    }

    @Override
    public Iterator<ArticlePage> iterator() {
        Iterator<ArticlePage> iterator = articlePages.iterator();
        return iterator;
    }
    
    public void setArticlePages(ArrayList<ArticlePage> articlePages) {
        this.articlePages = articlePages;
    }
    
    public ArrayList<ArticlePage> getArticlePages() {
        return articlePages;
    }

}

Since I'd like my users to be able to add/remove the sub-widgets (in this case 
"ArticlePage" objects which have their own standard editor 
"ArticlePageEditor") I figured (correctly?) I needed to use the ListEditor 
adaptor class as my Editor.  I'm not sure if I have this correct 
conceptually, b/c when I try to run in dev mode I get the following error:
*Caused by: java.lang.Error: Unresolved compilation problem: Type mismatch: 
cannot convert from ArticlePaginator to List
*
Why is it trying to convert my ArticlePaginator to a List???

Any insight would be greatly appreciated.

Here's my attempted implementation of the ListEditor: 

public class ArticlePaginatorEditor extends Composite implements 
IsEditor<ListEditor<ArticlePage, ArticlePageEditor>> {
    
    private static ArticlePaginatorEditorUiBinder uiBinder = 
GWT.create(ArticlePaginatorEditorUiBinder.class);
    
    interface ArticlePaginatorEditorUiBinder extends UiBinder<Widget, 
ArticlePaginatorEditor> {}

    
    @UiField
    VerticalPanel container;
    
    private class ArticlePageEditorSource extends 
EditorSource<ArticlePageEditor> {

        @Override
        public ArticlePageEditor create(int index) {
            ArticlePageEditor subEditor = new ArticlePageEditor();
            container.add(subEditor);
            return subEditor;
        }
        
        @Override
        public void dispose(ArticlePageEditor subEditor) {
          subEditor.removeFromParent();
          
        }

        @Override
        public void setIndex(ArticlePageEditor subEditor, int index) {
            container.insert(subEditor, index);
        }

    }

    
    private ListEditor<ArticlePage, ArticlePageEditor> editor = 
ListEditor.of(new ArticlePageEditorSource());
    
    public ArticlePaginatorEditor() {
        
        initWidget(uiBinder.createAndBindUi(this));
        
    }

    @Override
    public ListEditor<ArticlePage, ArticlePageEditor> asEditor() {
        return editor;
    }



    @UiHandler("add")
    void onClickAdd(ClickEvent e) {
        
        ThriftWidget newMeta = new ThriftWidget(29, new String[]{}, null, 
new int[]{1, 2, 3});
        newMeta.subwidgets = new ThriftWidget[] {
            new ThriftWidget(41, new String[]{"huh?"}, null, null),
            new ThriftWidget(41, new String[]{""}, null, null),
            new ThriftWidget(41, new String[]{""}, null, null)
        };
        
        ThriftWidget newPage = new ThriftWidget(1, null, null, new 
int[]{1});
        newPage.subwidgets = new ThriftWidget[] { newMeta };
        
        ArticlePage ap = new ArticlePage(newPage);
        
        editor.getList().add(ap);

        
    }


}

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/google-web-toolkit/-/7S5Vxu-kIuIJ.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.

Reply via email to