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 ShortcutBeanContainer} 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 <IDTYPE>
19   *            The type of the item identifier
20   * @param <BEANTYPE>
21   *            The type of the Bean
22   * 
23   * @since 0.2.0
24   * 
25   * @see AbstractHierarchicalBeanContainer
26   * @see BeanContainer
27   * @see ContainerHierarchicalWrapper
28   * @see com.vaadin.data.Container.Hierarchical
29   */
30  public class HierarchicalShortcutBeanContainer<IDTYPE, BEANTYPE> extends
31          AbstractHierarchicalBeanContainer<IDTYPE, BEANTYPE> implements IShortcutBeanContainer {
32  
33      private static final long serialVersionUID = -4643557075868038241L;
34  
35      /**
36       * Create a {@link HierarchicalShortcutBeanContainer} with the given IDTYPE and BEANTYPE.
37       * 
38       * @param type
39       *            The type of the Bean
40       */
41      public HierarchicalShortcutBeanContainer(Class<BEANTYPE> type) {
42          super(type, new ShortcutBeanContainer<IDTYPE, BEANTYPE>(type));
43      }
44  
45      /**
46       * Create a {@link HierarchicalShortcutBeanContainer} with the given IDTYPE and BEANTYPE.
47       * 
48       * @param type
49       *            The type of the Bean
50       * @param hierarchicalBeanBuilder
51       *            The builder for {@link com.vaadin.data.Container.Hierarchical}
52       */
53      public HierarchicalShortcutBeanContainer(Class<BEANTYPE> type,
54              HierarchicalBeanBuilder<IDTYPE, BEANTYPE> hierarchicalBeanBuilder) {
55          this(type);
56          setHierarchicalBeanBuilder(hierarchicalBeanBuilder);
57      }
58  
59      @Override
60      public void setBeanIdProperty(Object propertyId) {
61          ((ShortcutBeanContainer<IDTYPE, BEANTYPE>) getContainer()).setBeanIdProperty(propertyId);
62      }
63  
64      @Override
65      public boolean addShortcutContainerProperty(String propertyId, String propertyPath) {
66          return ((ShortcutBeanContainer<IDTYPE, BEANTYPE>) getContainer()).addShortcutContainerProperty(propertyId, propertyPath);
67      }
68  }