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.Tabs;
25  
26  import java.util.HashSet;
27  import java.util.List;
28  import java.util.Set;
29  
30  /**
31   * A group that presents its child Groups as tabs.  Items in this group's item list must be Groups
32   * themselves.
33   *
34   * @author Kuali Rice Team (rice.collab@kuali.org)
35   * @see Group
36   */
37  @BeanTags(
38          {@BeanTag(name = "tabGroup-bean", parent = "Uif-TabGroup"), @BeanTag(name = "tabSection-bean", parent = "Uif-TabSection"),
39                  @BeanTag(name = "tabSubSection-bean", parent = "Uif-TabSubSection")})
40  public class TabGroup extends Group {
41      private static final long serialVersionUID = 3L;
42  
43      private Tabs tabsWidget;
44  
45      public TabGroup() {
46          super();
47      }
48  
49      /**
50       * @see org.kuali.rice.krad.uif.component.ComponentBase#getComponentsForLifecycle()
51       */
52      @Override
53      public List<Component> getComponentsForLifecycle() {
54          List<Component> components = super.getComponentsForLifecycle();
55  
56          components.add(tabsWidget);
57  
58          return components;
59      }
60  
61      @Override
62      public void performFinalize(View view, Object model, Component parent) {
63          super.performFinalize(view, model, parent);
64          this.addDataAttribute(UifConstants.DataAttributes.TYPE, "Uif-TabGroup");
65      }
66  
67      /**
68       * Only groups are supported for this group.
69       *
70       * @see org.kuali.rice.krad.web.view.container.ContainerBase#getSupportedComponents()
71       */
72      @Override
73      public Set<Class<? extends Component>> getSupportedComponents() {
74          Set<Class<? extends Component>> supportedComponents = new HashSet<Class<? extends Component>>();
75          supportedComponents.add(Group.class);
76  
77          return supportedComponents;
78      }
79  
80      /**
81       * Gets the widget which contains any configuration for the tab widget component used to render
82       * this TabGroup
83       *
84       * @return the tabsWidget
85       */
86      @BeanTagAttribute(name = "tabsWidget", type = BeanTagAttribute.AttributeType.SINGLEBEAN)
87      public Tabs getTabsWidget() {
88          return this.tabsWidget;
89      }
90  
91      /**
92       * @param tabsWidget the tabsWidget to set
93       */
94      public void setTabsWidget(Tabs tabsWidget) {
95          this.tabsWidget = tabsWidget;
96      }
97  
98      /**
99       * @see org.kuali.rice.krad.uif.component.ComponentBase#copy()
100      */
101     @Override
102     protected <T> void copyProperties(T component) {
103         super.copyProperties(component);
104         TabGroup tabGroupCopy = (TabGroup) component;
105 
106         if(tabsWidget != null) {
107             tabGroupCopy.setTabsWidget((Tabs)this.getTabsWidget().copy());
108         }
109     }
110 
111 }