001    package 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    
023    import java.util.List;
024    
025    import org.gwtbootstrap3.client.ui.base.HasDataParent;
026    import org.gwtbootstrap3.client.ui.base.HasDataTarget;
027    import org.gwtbootstrap3.client.ui.base.HasDataToggle;
028    import org.gwtbootstrap3.client.ui.base.mixin.DataParentMixin;
029    import org.gwtbootstrap3.client.ui.base.mixin.DataTargetMixin;
030    import org.gwtbootstrap3.client.ui.base.mixin.DataToggleMixin;
031    import org.gwtbootstrap3.client.ui.constants.Styles;
032    import org.gwtbootstrap3.client.ui.constants.Toggle;
033    import org.gwtbootstrap3.client.ui.html.Div;
034    import org.gwtbootstrap3.client.ui.html.Text;
035    
036    import com.google.gwt.user.client.ui.HasText;
037    import com.google.gwt.user.client.ui.HasWidgets;
038    import com.google.gwt.user.client.ui.Widget;
039    
040    /**
041     * @author Joshua Godi
042     */
043    public class PanelHeader extends Div implements HasWidgets, HasText, HasDataToggle, HasDataTarget, HasDataParent {
044        private final DataParentMixin<PanelHeader> parentMixin = new DataParentMixin<PanelHeader>(this);
045        private final DataTargetMixin<PanelHeader> targetMixin = new DataTargetMixin<PanelHeader>(this);
046        private final DataToggleMixin<PanelHeader> toggleMixin = new DataToggleMixin<PanelHeader>(this);
047        private final Text text = new Text();
048    
049        public PanelHeader() {
050            setStyleName(Styles.PANEL_HEADING);
051        }
052    
053        /**
054         * {@inheritDoc}
055         */
056        @Override
057        public String getText() {
058            return text.getText();
059        }
060    
061        /**
062         * {@inheritDoc}
063         */
064        @Override
065        public void setText(final String text) {
066            this.text.setText(text);
067            insert(this.text, 0);
068        }
069    
070        @Override
071        public void setDataTargetWidgets(final List<Widget> widgets) {
072            targetMixin.setDataTargetWidgets(widgets);
073        }
074    
075        @Override
076        public void setDataTargetWidget(final Widget widget) {
077            targetMixin.setDataTargetWidget(widget);
078        }
079    
080        /**
081         * {@inheritDoc}
082         */
083        @Override
084        public void setDataTarget(final String dataTarget) {
085            targetMixin.setDataTarget(dataTarget);
086        }
087    
088        /**
089         * {@inheritDoc}
090         */
091        @Override
092        public String getDataTarget() {
093            return targetMixin.getDataTarget();
094        }
095    
096        /**
097         * {@inheritDoc}
098         */
099        @Override
100        public void setDataToggle(final Toggle toggle) {
101            toggleMixin.setDataToggle(toggle);
102        }
103    
104        /**
105         * {@inheritDoc}
106         */
107        @Override
108        public Toggle getDataToggle() {
109            return toggleMixin.getDataToggle();
110        }
111    
112        /**
113         * {@inheritDoc}
114         */
115        @Override
116        public void setDataParent(final String dataParent) {
117            parentMixin.setDataParent(dataParent);
118        }
119    
120        /**
121         * {@inheritDoc}
122         */
123        @Override
124        public String getDataParent() {
125            return parentMixin.getDataParent();
126        }
127    }