View Javadoc

1   package com.vaadin.data.util;
2   
3   import org.shortbrain.vaadin.container.property.HierarchicalBeanBuilder;
4   
5   import com.vaadin.data.Container.Hierarchical;
6   
7   /**
8    * An extension of {@link BeanContainer} that is {@link Hierarchical}.
9    * 
10   * <p>
11   * Behind the scene it uses {@link ContainerHierarchicalWrapper}.
12   * </p>
13   * 
14   * @author Vincent Demeester <vincent@shortbrain.org>
15   * 
16   * @param <IDTYPE>
17   *            The type of the item identifier
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   * @see Hierarchical
27   */
28  public class HierarchicalBeanContainer<IDTYPE, BEANTYPE> extends AbstractHierarchicalBeanContainer<IDTYPE, BEANTYPE> {
29  
30      private static final long serialVersionUID = 2360235181091674900L;
31  
32      /**
33       * Create a {@link HierarchicalBeanContainer} with the given IDTYPE and BEANTYPE.
34       * 
35       * @param type
36       *            The type of the Bean
37       */
38      public HierarchicalBeanContainer(Class<BEANTYPE> type) {
39          super(type, new BeanContainer<IDTYPE, BEANTYPE>(type));
40      }
41  
42      /**
43       * Create a {@link HierarchicalBeanContainer} with the given IDTYPE and BEANTYPE.
44       * 
45       * @param type
46       *            The type of the Bean
47       * @param hierarchicalBeanBuilder
48       *            The builder for {@link Hierarchical}
49       */
50      public HierarchicalBeanContainer(Class<BEANTYPE> type, HierarchicalBeanBuilder<IDTYPE, BEANTYPE> hierarchicalBeanBuilder) {
51          this(type);
52          setHierarchicalBeanBuilder(hierarchicalBeanBuilder);
53      }
54  
55      @Override
56      public void setBeanIdProperty(Object propertyId) {
57          ((BeanContainer<IDTYPE, BEANTYPE>) getContainer()).setBeanIdProperty(propertyId);
58      }
59  
60  }