001package org.gwtbootstrap3.client.ui.html;
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.HasAlignment;
024import org.gwtbootstrap3.client.ui.base.HasEmphasis;
025import org.gwtbootstrap3.client.ui.base.helper.StyleHelper;
026import org.gwtbootstrap3.client.ui.base.mixin.HTMLMixin;
027import org.gwtbootstrap3.client.ui.constants.Alignment;
028import org.gwtbootstrap3.client.ui.constants.Emphasis;
029import org.gwtbootstrap3.client.ui.gwt.HTMLPanel;
030
031import com.google.gwt.dom.client.ParagraphElement;
032
033/**
034 * @author Sven Jacobs
035 */
036public class Paragraph extends HTMLPanel implements HasAlignment, HasEmphasis {
037
038    private final HTMLMixin<Paragraph> textMixin = new HTMLMixin<Paragraph>(this);
039
040    public Paragraph() {
041        this("");
042    }
043
044    public Paragraph(final String html) {
045        super(ParagraphElement.TAG, html);
046    }
047
048    public void setText(final String text) {
049        textMixin.setText(text);
050    }
051
052    public String getText() {
053        return textMixin.getText();
054    }
055
056    public String getHTML() {
057        return textMixin.getHTML();
058    }
059
060    public void setHTML(final String html) {
061        textMixin.setHTML(html);
062    }
063
064    @Override
065    public void setAlignment(final Alignment alignment) {
066        StyleHelper.addUniqueEnumStyleName(this, Alignment.class, alignment);
067    }
068
069    @Override
070    public Alignment getAlignment() {
071        return Alignment.fromStyleName(getStyleName());
072    }
073
074    @Override
075    public void setEmphasis(final Emphasis emphasis) {
076        StyleHelper.addUniqueEnumStyleName(this, Emphasis.class, emphasis);
077    }
078
079    @Override
080    public Emphasis getEmphasis() {
081        return Emphasis.fromStyleName(getStyleName());
082    }
083}