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.constants.Constants;
019import com.google.gwt.i18n.shared.DirectionEstimator;
020import com.google.gwt.i18n.shared.HasDirectionEstimator;
021import com.google.gwt.user.client.ui.DirectionalTextHelper;
022
023/**
024 * ControlLabel is a form widget.That can show form input label.
025 * <p>
026 * ControlLabel can include html and widget
027 * <h3>UiBinder Usage:</h3>
028 * 
029 * <pre>
030 * {@code
031 * <b:ControlLabel>
032 *      ControlLabel can include html and widgets<br/>
033 *      <b:Code>Code</b:Code>
034 *      <a href="#"></a>
035 * </b:ControlLabel>
036 * }
037 * </pre>
038 * </p>
039 * 
040 * @since 2.0.4.0
041 * 
042 * @author kokubo yusuke 
043 * @author ohashi keisuke
044 * 
045 * @see ControlGroup
046 * @see ControlLabel
047 * @see <a href="http://twitter.github.com/bootstrap/base-css.html#forms">Bootstrap documentation</a>
048 */
049public class ControlLabel extends FormLabel implements HasDirectionEstimator {
050
051        final DirectionalTextHelper directionalTextHelper;
052
053        /**
054         * Creates a widget with  the html set..
055         * @param html content html
056         */
057        public ControlLabel(String html) {
058                super(html);
059                setStyleName(Constants.CONTROL_LABEL);
060                directionalTextHelper = new DirectionalTextHelper(getElement(), true);
061        }
062
063        /**
064         * Creates an empty widget.
065         */
066        public ControlLabel() {
067                this("");
068        }
069
070        /**
071         * {@inheritDoc}
072         */
073        public DirectionEstimator getDirectionEstimator() {
074                return directionalTextHelper.getDirectionEstimator();
075        }
076
077        /**
078         * {@inheritDoc}
079         */
080        public void setDirectionEstimator(boolean enabled) {
081                directionalTextHelper.setDirectionEstimator(enabled);
082        }
083
084        /**
085         * {@inheritDoc}
086         */
087        public void setDirectionEstimator(DirectionEstimator directionEstimator) {
088                directionalTextHelper.setDirectionEstimator(directionEstimator);
089        }
090}