001/*
002 *  Copyright 2012 GWT-Bootstrap
003 *
004 *  Licensed under the Apache 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.apache.org/licenses/LICENSE-2.0
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 com.github.gwtbootstrap.client.ui;
017
018import com.github.gwtbootstrap.client.ui.base.DivWidget;
019import com.github.gwtbootstrap.client.ui.base.StyleHelper;
020import com.github.gwtbootstrap.client.ui.constants.Constants;
021import com.github.gwtbootstrap.client.ui.constants.WellSize;
022import com.google.gwt.dom.client.Style;
023import com.google.gwt.dom.client.Style.Unit;
024import com.google.gwt.user.client.ui.Widget;
025
026//@formatter:off
027/**
028 * {@link NavList} in a {@link Well}.
029 * 
030 * @since 2.0.4.0
031 * 
032 * @author Dominik Mayer
033 */
034// @formatter:on
035public class WellNavList extends DivWidget {
036
037        private NavList navList = new NavList();
038
039        /**
040         * Creates an empty list.
041         */
042        public WellNavList() {
043                setStyleName(Constants.WELL);
044                super.add(navList);
045                setStyle();
046        }
047
048        private void setStyle() {
049                Style style = getElement().getStyle();
050                style.setPaddingTop(8, Unit.PX);
051                style.setPaddingBottom(8, Unit.PX);
052                style.setPaddingLeft(0, Unit.PX);
053                style.setPaddingRight(0, Unit.PX);
054        }
055
056        // TODO: Restrict type of widgets that can be added?
057        /**
058         * {@inheritDoc}
059         */
060        @Override
061        public void add(Widget child) {
062                navList.add(child);
063        }
064
065        /**
066         * {@inheritDoc}
067         */
068        @Override
069        public void insert(Widget w, int beforeIndex) {
070                navList.insert(w, beforeIndex);
071        }
072        
073        /**
074         * {@inheritDoc}
075         */
076        @Override
077        public void clear() {
078                navList.clear();
079        }
080
081        /**
082         * Set well size
083         * 
084         * @param size
085         *            size
086         */
087        public void setSize(WellSize size) {
088                StyleHelper.changeStyle(this, size, WellSize.class);
089        }
090
091}