View Javadoc

1   package org.shortbrain.vaadin.container;
2   
3   import org.shortbrain.vaadin.container.property.HierarchicalBeanBuilder;
4   
5   import com.vaadin.data.util.AbstractHierarchicalBeanContainer;
6   import com.vaadin.data.util.BeanContainer;
7   import com.vaadin.data.util.ContainerHierarchicalWrapper;
8   
9   /**
10   * An extension of {@link ShortcutBeanItemContainer} that is {@link com.vaadin.data.Container.Hierarchical}.
11   * 
12   * <p>
13   * Behind the scene it uses {@link ContainerHierarchicalWrapper}.
14   * </p>
15   * 
16   * @author Vincent Demeester <vincent@shortbrain.org>
17   * 
18   * @param <BEANTYPE>
19   *            The type of the Bean
20   * 
21   * @since 0.2.0
22   * 
23   * @see AbstractHierarchicalBeanContainer
24   * @see BeanContainer
25   * @see ContainerHierarchicalWrapper
26   */
27  public class HierarchicalShortcutBeanItemContainer<BEANTYPE> extends
28          AbstractHierarchicalBeanContainer<BEANTYPE, BEANTYPE> implements IShortcutBeanContainer {
29  
30      private static final long serialVersionUID = 3022071979651114886L;
31  
32      /**
33       * Create a {@link HierarchicalShortcutBeanItemContainer} with the given IDTYPE and BEANTYPE.
34       * 
35       * @param type
36       *            The type of the Bean
37       */
38      public HierarchicalShortcutBeanItemContainer(Class<BEANTYPE> type) {
39          super(type, new ShortcutBeanItemContainer<BEANTYPE>(type));
40      }
41  
42      /**
43       * Create a {@link HierarchicalShortcutBeanItemContainer} with the given IDTYPE and BEANTYPE.
44       * 
45       * @param type
46       *            The type of the Bean
47       * @param hierarchicalBeanBuilder
48       *            builder for the {@link com.vaadin.data.Container.Hierarchical}
49       */
50      public HierarchicalShortcutBeanItemContainer(Class<BEANTYPE> type,
51              HierarchicalBeanBuilder<BEANTYPE, BEANTYPE> hierarchicalBeanBuilder) {
52          this(type);
53          setHierarchicalBeanBuilder(hierarchicalBeanBuilder);
54      }
55  
56      @Override
57      public void setBeanIdProperty(Object propertyId) {
58          throw new UnsupportedOperationException("BeanItemContainer always uses an IdentityBeanIdResolver");
59      }
60  
61      @Override
62      public boolean addShortcutContainerProperty(String propertyId, String propertyPath) {
63          return ((ShortcutBeanItemContainer<BEANTYPE>) getContainer()).addShortcutContainerProperty(propertyId,
64                  propertyPath);
65      }
66  }