001 package org.gwtbootstrap3.client.ui.gwt;
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
023 import java.util.List;
024
025 import org.gwtbootstrap3.client.ui.base.HasContextualBackground;
026 import org.gwtbootstrap3.client.ui.base.HasDataSpy;
027 import org.gwtbootstrap3.client.ui.base.HasDataTarget;
028 import org.gwtbootstrap3.client.ui.base.HasId;
029 import org.gwtbootstrap3.client.ui.base.HasInlineStyle;
030 import org.gwtbootstrap3.client.ui.base.HasResponsiveness;
031 import org.gwtbootstrap3.client.ui.base.helper.StyleHelper;
032 import org.gwtbootstrap3.client.ui.base.mixin.DataSpyMixin;
033 import org.gwtbootstrap3.client.ui.base.mixin.DataTargetMixin;
034 import org.gwtbootstrap3.client.ui.base.mixin.IdMixin;
035 import org.gwtbootstrap3.client.ui.constants.ContextualBackground;
036 import org.gwtbootstrap3.client.ui.constants.DeviceSize;
037 import org.gwtbootstrap3.client.ui.constants.Spy;
038
039 import com.google.gwt.dom.client.Style;
040 import com.google.gwt.safehtml.shared.SafeHtml;
041 import com.google.gwt.user.client.ui.Widget;
042
043 /**
044 * @author Sven Jacobs
045 * @author Grant Slender
046 * @author David Buhler
047 */
048 public class HTMLPanel extends com.google.gwt.user.client.ui.HTMLPanel implements HasId, HasDataSpy, HasDataTarget, HasResponsiveness, HasInlineStyle, HasContextualBackground {
049
050 private final DataSpyMixin<HTMLPanel> spyMixin = new DataSpyMixin<HTMLPanel>(this);
051 private final DataTargetMixin<HTMLPanel> targetMixin = new DataTargetMixin<HTMLPanel>(this);
052 private final IdMixin<HTMLPanel> idMixin = new IdMixin<HTMLPanel>(this);
053
054 public HTMLPanel(final String html) {
055 super(html);
056 }
057
058 public HTMLPanel(final SafeHtml safeHtml) {
059 super(safeHtml);
060 }
061
062 public HTMLPanel(final String tag, final String html) {
063 super(tag, html);
064 }
065
066 @Override
067 public void setId(final String id) {
068 idMixin.setId(id);
069 }
070
071 @Override
072 public String getId() {
073 return idMixin.getId();
074 }
075
076 @Override
077 public void setDataSpy(final Spy spy) {
078 spyMixin.setDataSpy(spy);
079 }
080
081 @Override
082 public Spy getDataSpy() {
083 return spyMixin.getDataSpy();
084 }
085
086 @Override
087 public void setDataTargetWidgets(final List<Widget> widgets) {
088 targetMixin.setDataTargetWidgets(widgets);
089 }
090
091 @Override
092 public void setDataTargetWidget(final Widget widget) {
093 targetMixin.setDataTargetWidget(widget);
094 }
095
096 @Override
097 public void setDataTarget(final String dataTarget) {
098 targetMixin.setDataTarget(dataTarget);
099 }
100
101 @Override
102 public String getDataTarget() {
103 return targetMixin.getDataTarget();
104 }
105
106 @Override
107 public void setVisibleOn(final DeviceSize deviceSize) {
108 StyleHelper.setVisibleOn(this, deviceSize);
109 }
110
111 @Override
112 public void setHiddenOn(final DeviceSize deviceSize) {
113 StyleHelper.setHiddenOn(this, deviceSize);
114 }
115
116 @Override
117 public void setMarginTop(final double margin) {
118 getElement().getStyle().setMarginTop(margin, Style.Unit.PX);
119 }
120
121 @Override
122 public void setMarginLeft(final double margin) {
123 getElement().getStyle().setMarginLeft(margin, Style.Unit.PX);
124 }
125
126 @Override
127 public void setMarginRight(final double margin) {
128 getElement().getStyle().setMarginRight(margin, Style.Unit.PX);
129 }
130
131 @Override
132 public void setMarginBottom(final double margin) {
133 getElement().getStyle().setMarginBottom(margin, Style.Unit.PX);
134 }
135
136 @Override
137 public void setPaddingTop(final double padding) {
138 getElement().getStyle().setPaddingTop(padding, Style.Unit.PX);
139 }
140
141 @Override
142 public void setPaddingLeft(final double padding) {
143 getElement().getStyle().setPaddingLeft(padding, Style.Unit.PX);
144 }
145
146 @Override
147 public void setPaddingRight(final double padding) {
148 getElement().getStyle().setPaddingRight(padding, Style.Unit.PX);
149 }
150
151 @Override
152 public void setPaddingBottom(final double padding) {
153 getElement().getStyle().setPaddingBottom(padding, Style.Unit.PX);
154 }
155
156 /**
157 * {@inheritDoc}
158 */
159 @Override
160 public void setColor(String color) {
161 getElement().getStyle().setColor(color);
162 }
163
164 /**
165 * {@inheritDoc}
166 */
167 @Override
168 public void setContextualBackground(ContextualBackground contextualBackground) {
169 StyleHelper.addUniqueEnumStyleName(this, ContextualBackground.class, contextualBackground);
170 }
171
172 /**
173 * {@inheritDoc}
174 */
175 @Override
176 public ContextualBackground getContextualBackground() {
177 return ContextualBackground.fromStyleName(getStyleName());
178 }
179 }