001/** 002 * Copyright 2005-2018 The Kuali Foundation 003 * 004 * Licensed under the Educational Community License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.opensource.org/licenses/ecl2.php 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package org.kuali.rice.krad.uif.widget; 017 018import java.util.HashMap; 019import java.util.Map; 020 021import org.apache.commons.collections.CollectionUtils; 022import org.apache.commons.lang.StringUtils; 023import org.kuali.rice.krad.datadictionary.parse.BeanTag; 024import org.kuali.rice.krad.datadictionary.parse.BeanTagAttribute; 025import org.kuali.rice.krad.uif.CssConstants; 026import org.kuali.rice.krad.uif.UifConstants; 027import org.kuali.rice.krad.uif.component.ClientSideState; 028import org.kuali.rice.krad.uif.component.Component; 029import org.kuali.rice.krad.uif.container.TabGroup; 030import org.kuali.rice.krad.uif.util.LifecycleElement; 031 032/** 033 * Widget used for configuring tab options, use componentOptions for most options. 034 * See http://jqueryui.com/demos/tabs/ for usable options 035 * 036 * @author Kuali Rice Team (rice.collab@kuali.org) 037 */ 038@BeanTag(name = "tabs", parent = "Uif-Tabs") 039public class Tabs extends WidgetBase { 040 private static final long serialVersionUID = 2L; 041 042 private String tabContentClass; 043 private String tabNavClass; 044 045 private UifConstants.Position position = UifConstants.Position.TOP; 046 047 public Tabs() { 048 super(); 049 } 050 051 /** 052 * The following is performed: 053 * 054 * <ul> 055 * <li>If the active tab id is configured, set the active plugin option</li> 056 * </ul> 057 */ 058 @Override 059 public void performFinalize(Object model, LifecycleElement parent) { 060 super.performFinalize(model, parent); 061 062 if (parent instanceof TabGroup) { 063 if (position.equals(UifConstants.Position.LEFT) || position.equals(UifConstants.Position.RIGHT)) { 064 tabNavClass = tabNavClass + " col-sm-3"; 065 tabContentClass = tabContentClass + " col-sm-9"; 066 } 067 068 if (position.equals(UifConstants.Position.LEFT)) { 069 ((TabGroup) parent).addStyleClass(CssConstants.Tabs.TABS_LEFT); 070 } else if (position.equals(UifConstants.Position.RIGHT)) { 071 ((TabGroup) parent).addStyleClass(CssConstants.Tabs.TABS_RIGHT); 072 } else if (position.equals(UifConstants.Position.BOTTOM)) { 073 ((TabGroup) parent).addStyleClass(CssConstants.Tabs.TABS_BOTTOM); 074 } 075 } 076 } 077 078 /** 079 * The position the tabs will appear related to the group, options are TOP, BOTTOM, RIGHT, or LEFT 080 * 081 * @return position for tabs 082 */ 083 @BeanTagAttribute 084 public UifConstants.Position getPosition() { 085 return position; 086 } 087 088 /** 089 * Setter for the tabs position 090 * 091 * @param position 092 */ 093 public void setPosition(UifConstants.Position position) { 094 this.position = position; 095 } 096 097 /** 098 * Css class for the div which wraps the tab content panels, the default bean defines this as "tabs-content" 099 * 100 * @return css tab content css class 101 */ 102 @BeanTagAttribute(name = "tabContentClass") 103 public String getTabContentClass() { 104 return tabContentClass; 105 } 106 107 /** 108 * @see org.kuali.rice.krad.uif.widget.Tabs#getTabContentClass() 109 */ 110 public void setTabContentClass(String tabContentClass) { 111 this.tabContentClass = tabContentClass; 112 } 113 114 /** 115 * Css class for the ul list of tab navigation links, the default bean defines this as "nav nav-tabs" 116 * 117 * @return the ul tab navigation css class 118 */ 119 @BeanTagAttribute(name = "tabNavClass") 120 public String getTabNavClass() { 121 return tabNavClass; 122 } 123 124 /** 125 * @see org.kuali.rice.krad.uif.widget.Tabs#getTabNavClass() 126 */ 127 public void setTabNavClass(String tabNavClass) { 128 this.tabNavClass = tabNavClass; 129 } 130}