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