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.DropdownBase;
019import com.github.gwtbootstrap.client.ui.base.IconAnchor;
020import com.github.gwtbootstrap.client.ui.constants.IconSize;
021import com.github.gwtbootstrap.client.ui.constants.IconType;
022
023//@formatter:off
024/**
025 * Dropdown menus that are usually used in a navigation context.
026 * 
027 * <p>
028 * <h3>UiBinder Usage:</h3>
029 * 
030 * <pre>
031 * {@code
032 * <b:Dropdown text="I am the Caption">
033 *     <b:NavHeader>Header</b:NavHeader>
034 *     <b:NavLink>Link 1</b:NavLink>
035 *     <b:NavLink>Link 2</b:NavLink>
036 * </b:Dropdown>
037 * }
038 * </pre>
039 * </p>
040 * 
041 * @since 2.0.4.0
042 * 
043 * @author Carlos Alexandro Becker
044 * @author Dominik Mayer
045 * 
046 * @see <a href="http://twitter.github.com/bootstrap/javascript.html#dropdowns">Bootstrap documentation</a>
047 * @see DropdownButton
048 * @see SplitDropdownButton
049 */
050//@formatter:on
051public class Dropdown extends DropdownBase {
052
053        /**
054         * Creates an empty Dropdown without a caption.
055         */
056        public Dropdown() {
057                super("li");
058                addStyleName("dropdown");
059        }
060
061        /**
062         * Creates an empty Dropdown with the given caption.
063         * 
064         * @param caption
065         *            the dropdown's caption
066         */
067        public Dropdown(final String caption) {
068                this();
069                setText(caption);
070        }
071
072        /**
073         * {@inheritDoc}
074         */
075        @Override
076        protected IconAnchor createTrigger() {
077                final IconAnchor trigger = new IconAnchor();
078                trigger.setCaret(true);
079                return trigger;
080        }
081
082    /**
083     * {@inheritDoc}
084     */
085    @Override
086    public void setIcon(IconType type) {
087        trigger.setIcon(type);
088    }
089
090    /**
091     * {@inheritDoc}
092     */
093    @Override
094    public void setIconSize(IconSize size) {
095        trigger.setIconSize(size);
096    }
097    
098    /**
099     * {@inheritDoc}
100     */
101    @Override
102    public void setCustomIconStyle(String customIconStyle) {
103        trigger.setCustomIconStyle(customIconStyle);
104    }
105
106}