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.HtmlWidget;
019import com.google.gwt.dom.client.LabelElement;
020
021
022/**
023 * Simple wrapper for an HTML {@code <label>} tag.
024 * 
025 * <p>
026 * <h3>UiBinder Usage:</h3>
027 * 
028 * <pre>
029 * {@code
030 * <b:FormLabel>
031 *      FormLabel can include html and widgets<br/>
032 *      <b:Code>code</b:Code>
033 *      <a href="#"></a>
034 * </b:FormLabel>
035 * }
036 * </pre>
037 * </p>
038 *
039 * @since 2.0.4.0
040 * 
041 * @author ohashi keisuke
042 * 
043 * @see <a href="http://twitter.github.com/bootstrap/base-css.html#forms">Bootstrap documentation</a>
044 */
045public class FormLabel extends HtmlWidget {
046
047        /**
048         * Creates a widget with  the html set..
049         * @param html content html
050         */
051        public FormLabel(String html) {
052                super("label" ,html);
053        }
054        
055        /**
056         * Creates an empty widget.
057         */
058        public FormLabel() {
059                this("");
060        }
061        
062        /**
063         * Set <code>for</code> attribute.
064         * @param id set attribute value
065         */
066        public void setFor(String id) {
067                getLabelElement().setHtmlFor(id);
068        }
069        
070        /**
071         * Get <code>for</code> attribute
072         * @return for attribute value
073         */
074        public String getFor() {
075                return getLabelElement().getHtmlFor();
076        }
077        
078        protected LabelElement getLabelElement() {
079                return getElement().cast();
080        }
081
082}