View Javadoc

1   /**
2    * Copyright 2005-2013 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.kuali.rice.krad.uif.container;
17  
18  import org.kuali.rice.krad.datadictionary.parse.BeanTag;
19  import org.kuali.rice.krad.datadictionary.parse.BeanTagAttribute;
20  import org.kuali.rice.krad.datadictionary.parse.BeanTags;
21  import org.kuali.rice.krad.uif.UifConstants;
22  import org.kuali.rice.krad.uif.component.Component;
23  import org.kuali.rice.krad.uif.view.View;
24  import org.kuali.rice.krad.uif.widget.Accordion;
25  
26  import java.util.HashSet;
27  import java.util.List;
28  import java.util.Set;
29  
30  /**
31   * Accordion group class used to stack groups by there header titles in an accordion layout
32   */
33  @BeanTags({@BeanTag(name = "accordionGroup-bean", parent = "Uif-AccordionGroup"),
34          @BeanTag(name = "accordionSection-bean", parent = "Uif-AccordionSection"),
35          @BeanTag(name = "accordionSubSection-bean", parent = "Uif-AccordionSubSection"),
36          @BeanTag(name = "disclosure-accordionSection-bean", parent = "Uif-Disclosure-AccordionSection"),
37          @BeanTag(name = "disclosure-accordionSubSection-bean", parent = "Uif-Disclosure-AccordionSubSection")})
38  public class AccordionGroup extends Group {
39  
40      private static final long serialVersionUID = 7230145606607506418L;
41  
42      private Accordion accordionWidget;
43  
44      /**
45       * @see org.kuali.rice.krad.uif.component.ComponentBase#getComponentsForLifecycle()
46       */
47      @Override
48      public List<Component> getComponentsForLifecycle() {
49          List<Component> components = super.getComponentsForLifecycle();
50  
51          components.add(accordionWidget);
52  
53          return components;
54      }
55  
56      /**
57       * @see org.kuali.rice.krad.uif.component.ComponentBase#performFinalize(org.kuali.rice.krad.uif.view.View, Object,
58       *      org.kuali.rice.krad.uif.component.Component)
59       */
60      @Override
61      public void performFinalize(View view, Object model, Component parent) {
62          super.performFinalize(view, model, parent);
63          this.addDataAttribute(UifConstants.DataAttributes.TYPE, "Uif-AccordionGroup");
64      }
65  
66      /**
67       * Only groups are supported for this group.
68       *
69       * @see org.kuali.rice.krad.web.view.container.ContainerBase#getSupportedComponents()
70       */
71      @Override
72      public Set<Class<? extends Component>> getSupportedComponents() {
73          Set<Class<? extends Component>> supportedComponents = new HashSet<Class<? extends Component>>();
74          supportedComponents.add(Group.class);
75  
76          return supportedComponents;
77      }
78  
79      /**
80       * Gets the widget which contains any configuration for the accordion widget component used to render
81       * this AccordionGroup
82       *
83       * @return the accordionWidget
84       */
85      @BeanTagAttribute(name = "accordionWidget", type = BeanTagAttribute.AttributeType.SINGLEBEAN)
86      public Accordion getAccordionWidget() {
87          return this.accordionWidget;
88      }
89  
90      /**
91       * Set the accordionWidget
92       *
93       * @param the accordionWidget to set
94       */
95      public void setAccordionWidget(Accordion accordionWidget) {
96          this.accordionWidget = accordionWidget;
97      }
98  
99      /**
100      * @see org.kuali.rice.krad.uif.component.ComponentBase#copy()
101      */
102     @Override
103     protected <T> void copyProperties(T component) {
104         super.copyProperties(component);
105         AccordionGroup accordionGroupCopy = (AccordionGroup) component;
106 
107         if (this.accordionWidget != null) {
108             accordionGroupCopy.setAccordionWidget((Accordion) this.accordionWidget.copy());
109         }
110     }
111 }