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.base;
017
018 import com.github.gwtbootstrap.client.ui.constants.Device;
019 import com.google.gwt.user.client.DOM;
020 import com.google.gwt.user.client.ui.HasText;
021 import com.google.gwt.user.client.ui.Widget;
022
023 /**
024 * Helper class for widgets that have text.
025 *
026 * @since 2.0.4.0
027 *
028 * @author Carlos Alexandro Becker
029 *
030 */
031 public abstract class AbstractTypography extends Widget implements HasText,
032 HasStyle, IsResponsive {
033
034 /**
035 * Creates a new widget without setting a DOM element.
036 */
037 public AbstractTypography() {
038 super();
039 }
040
041 /**
042 * Creates a new widget based on the given HTML tag.
043 *
044 * @param tag
045 * the HTML tag to be used
046 */
047 public AbstractTypography(String tag) {
048 setElement(DOM.createElement(tag));
049 }
050
051 /**
052 * {@inheritDoc}
053 */
054 public void setText(String text) {
055 getElement().setInnerText(text);
056 }
057
058 /**
059 * {@inheritDoc}
060 */
061 public String getText() {
062 return getElement().getInnerText();
063 }
064
065 /**
066 * {@inheritDoc}
067 */
068 public void setStyle(Style style) {
069 StyleHelper.setStyle(this, style);
070 }
071
072 /**
073 * {@inheritDoc}
074 */
075 public void addStyle(Style style) {
076 StyleHelper.addStyle(this, style);
077 }
078
079 /**
080 * {@inheritDoc}
081 */
082 public void removeStyle(Style style) {
083 StyleHelper.removeStyle(this, style);
084 }
085
086 /**
087 * {@inheritDoc}
088 */
089 public void setShowOn(Device device) {
090 ResponsiveHelper.setShowOn(this, device);
091 }
092
093 /**
094 * {@inheritDoc}
095 */
096 public void setHideOn(Device device) {
097 ResponsiveHelper.setHideOn(this, device);
098 }
099 }