Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package org.jboss.errai.ui.client.widget;
 
 
 import  javax.inject.Singleton;
 
 import  org.jboss.errai.ioc.client.api.ContextualTypeProvider;
 import  org.jboss.errai.ioc.client.api.IOCProvider;
 
import  com.google.gwt.user.client.ui.HTMLPanel;
import  com.google.gwt.user.client.ui.IsWidget;

Provides instances of ListWidget for cases where the app does not have any reason to provide its own subclass of ListWidget.

Author(s):
Christian Sadilek <csadilek@redhat.com>
Jonathan Fuerth <jfuerth@redhat.com>
edewit@redhat.com
@IOCProvider
@Singleton
public class ListWidgetProvider implements ContextualTypeProvider<ListWidget<?, ?>> {
  private static class GenericListWidget<M, W extends HasModel<M> & IsWidget> extends ListWidget<M, W> {
    private final Class<W> itemWidgetType;
    GenericListWidget(Class<W> itemWidgetType) {
      this. = itemWidgetType;
    }
    public GenericListWidget(Class<W> itemWidgetType, HTMLPanel panel) {
      super(panel);
      this. = itemWidgetType;
    }
    @Override
    protected Class<W> getItemWidgetType() {
      return ;
    }
  }
  @SuppressWarnings({ "rawtypes""unchecked" })
  public ListWidget provide(Class<?>[] typeargsAnnotation[] qualifiers) {
    Class<?> itemWidgetType = typeargs[1];
    if (qualifiers != null && qualifiers.length > 0) {
      Class<? extends Annotationanno = qualifiers[0].annotationType();
      if (anno.equals(OrderedList.class)) {
        return new GenericListWidget(itemWidgetTypenew HTMLPanel("ol"""));
      }
      else if (anno.equals(UnOrderedList.class)) {
        return new GenericListWidget(itemWidgetTypenew HTMLPanel("ul"""));
      }
      else if (anno.equals(Table.class)) {
        return new GenericListWidget(itemWidgetTypenew HTMLPanel(((Tablequalifiers[0]).root(), ""));
      }
    }
    return new GenericListWidget(itemWidgetType);
  }
New to GrepCode? Check out our FAQ X