001package org.gwtbootstrap3.client.ui;
002
003/*
004 * #%L
005 * GwtBootstrap3
006 * %%
007 * Copyright (C) 2013 GwtBootstrap3
008 * %%
009 * Licensed under the Apache License, Version 2.0 (the "License");
010 * you may not use this file except in compliance with the License.
011 * You may obtain a copy of the License at
012 * 
013 *      http://www.apache.org/licenses/LICENSE-2.0
014 * 
015 * Unless required by applicable law or agreed to in writing, software
016 * distributed under the License is distributed on an "AS IS" BASIS,
017 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
018 * See the License for the specific language governing permissions and
019 * limitations under the License.
020 * #L%
021 */
022
023import org.gwtbootstrap3.client.ui.base.HasResponsiveness;
024import org.gwtbootstrap3.client.ui.base.helper.StyleHelper;
025import org.gwtbootstrap3.client.ui.constants.DeviceSize;
026import org.gwtbootstrap3.client.ui.constants.Styles;
027
028import com.google.gwt.dom.client.Document;
029import com.google.gwt.user.client.ui.HasText;
030import com.google.gwt.user.client.ui.Widget;
031
032/**
033 * Header element within {@link DropDownMenu}
034 * <p/>
035 * <h3>UiBinder example</h3>
036 * <p/>
037 * <pre>
038 * {@code
039 *     <b:DropDownMenu>
040 *         <b:DropDownHeader>Header 1</b:DropDownHeader>
041 *         <b:AnchorListItem>Action 1</b:AnchorListItem>
042 *         <b:AnchorListItem>Action 2</b:AnchorListItem>
043 *         <b:DropDownHeader>Header 2</b:DropDownHeader>
044 *         <b:AnchorListItem>Action 3</b:AnchorListItem>
045 *         <b:AnchorListItem>Action 4</b:AnchorListItem>
046 *     </b:DropDownMenu>
047 * }
048 * </pre>
049 *
050 * @author Sven Jacobs
051 * @author Joshua Godi
052 */
053public class DropDownHeader extends Widget implements HasText, HasResponsiveness {
054
055    public DropDownHeader() {
056        setElement(Document.get().createLIElement());
057        setStyleName(Styles.DROPDOWN_HEADER);
058    }
059
060    public DropDownHeader(final String text) {
061        this();
062        setText(text);
063    }
064
065    @Override
066    public void setText(final String text) {
067        getElement().setInnerText(text);
068    }
069
070    @Override
071    public String getText() {
072        return getElement().getInnerText();
073    }
074
075    @Override
076    public void setVisibleOn(final DeviceSize deviceSize) {
077        StyleHelper.setVisibleOn(this, deviceSize);
078    }
079
080    @Override
081    public void setHiddenOn(final DeviceSize deviceSize) {
082        StyleHelper.setHiddenOn(this, deviceSize);
083    }
084}