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     */
016    package com.github.gwtbootstrap.client.ui;
017    
018    import com.github.gwtbootstrap.client.ui.base.HasAlignment;
019    import com.github.gwtbootstrap.client.ui.base.ListItem;
020    import com.github.gwtbootstrap.client.ui.constants.Alignment;
021    import com.github.gwtbootstrap.client.ui.constants.NavbarConstants;
022    import com.google.gwt.user.client.ui.HasText;
023    
024    //@formatter:off
025    /**
026     * A Text in the Navbar.
027     * 
028     * @since 2.0.4.0
029     * 
030     * @author Dominik Mayer
031     * 
032     * @see <a href="http://twitter.github.com/bootstrap/components.html#navbar">Bootstrap documentation</a>
033     */
034    //@formatter:on
035    public class NavText extends ListItem implements HasText, HasAlignment {
036    
037            private Paragraph paragraph = new Paragraph();
038    
039            public NavText() {
040                    paragraph.addStyleName(NavbarConstants.NAVBAR_TEXT);
041                    super.add(paragraph);
042            }
043    
044            public NavText(String text) {
045                    this();
046                    setText(text);
047            }
048    
049            /**
050             * {@inheritDoc}
051             */
052            public void setAlignment(Alignment alignment) {
053                    removeStyle(Alignment.RIGHT);
054                    removeStyle(Alignment.LEFT);
055                    addStyle(alignment);
056            }
057    
058            /**
059             * {@inheritDoc}
060             */
061            public String getText() {
062                    return paragraph.getText();
063            }
064    
065            /**
066             * {@inheritDoc}
067             */
068            public void setText(String text) {
069                    paragraph.setText(text);
070            }
071    }