001    package org.gwtbootstrap3.client.ui;
002    
003    /*
004     * #%L
005     * GwtBootstrap3
006     * %%
007     * Copyright (C) 2013 - 2014 GwtBootstrap3
008     * %%
009     * Licensed under the Apache License, Version 2.0 (the "License");
010     * you may not use this file except in compliance with the License.
011     * You may obtain a copy of the License at
012     * 
013     *      http://www.apache.org/licenses/LICENSE-2.0
014     * 
015     * Unless required by applicable law or agreed to in writing, software
016     * distributed under the License is distributed on an "AS IS" BASIS,
017     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
018     * See the License for the specific language governing permissions and
019     * limitations under the License.
020     * #L%
021     */
022    
023    import org.gwtbootstrap3.client.ui.base.HasActive;
024    import org.gwtbootstrap3.client.ui.base.mixin.ActiveMixin;
025    import org.gwtbootstrap3.client.ui.constants.Styles;
026    import org.gwtbootstrap3.client.ui.html.Div;
027    
028    /**
029     * Container widget for the tab pane
030     * <p/>
031     * <a href="http://getbootstrap.com/javascript/#tabs">Bootstrap Documentation</a>
032     * <p/>
033     * <h3>UiBinder example</h3>
034     * <p/>
035     * <pre>
036     * {@code
037     * <b:TabContent>
038     *    <b:TabPane/>
039     *    <b:TabPane/>
040     * </b:TabContent>
041     * }
042     * </pre>
043     *
044     * @author Joshua Godi
045     * @see org.gwtbootstrap3.client.ui.TabContent
046     */
047    public class TabPane extends Div implements HasActive {
048        private final ActiveMixin<TabPane> activeMixin = new ActiveMixin<TabPane>(this);
049    
050        /**
051         * Creates the default widget with the default styles
052         */
053        public TabPane() {
054            setStyleName(Styles.TAB_PANE);
055        }
056    
057        /**
058         * Sets whether or not to fade the tab pane in/out when clicked
059         * Must set in="true" on the first tab if using fade!!
060         *
061         * @param fade true=fade content in/out, false=don't fade
062         */
063        public void setFade(final boolean fade) {
064            if (fade) {
065                addStyleName(Styles.FADE);
066            } else {
067                removeStyleName(Styles.FADE);
068            }
069        }
070    
071        /**
072         * When using fade, but set the first tabpane with in="true" to work properly
073         *
074         * @param in whether or not the first tab pane will be faded properly
075         */
076        public void setIn(final boolean in) {
077            if (in) {
078                addStyleName(Styles.IN);
079            } else {
080                removeStyleName(Styles.IN);
081            }
082        }
083    
084        /**
085         * {@inheritDoc}
086         */
087        @Override
088        public void setActive(final boolean active) {
089            activeMixin.setActive(active);
090        }
091    
092        /**
093         * {@inheritDoc}
094         */
095        @Override
096        public boolean isActive() {
097            return activeMixin.isActive();
098        }
099    }