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 */
016package com.github.gwtbootstrap.client.ui;
017
018import com.github.gwtbootstrap.client.ui.base.AlertBase;
019import com.github.gwtbootstrap.client.ui.constants.AlertType;
020
021/**
022 * Simple Alert widget that uses bold text as a heading.
023 * <p>
024 * <h3>UiBinder Usage:</h3>
025 * <code>{@code <b:Alert heading="Warning." type="ERROR">Something went wrong...</b:Alert>}</code>
026 * </p>
027 * <p>
028 * All parameters are optional and map to the class's setters.
029 * </p>
030 * 
031 * @since 2.0.4.0
032 * 
033 * @author Dominik Mayer
034 * 
035 * @see AlertBlock
036 * @see <a
037 *      href="http://getbootstrap.com/2.3.2/components.html#alerts">Bootstrap
038 *      documentation</a>
039 */
040public class Alert extends AlertBase {
041
042        
043        public Alert() {
044                super("");
045        }
046        
047        public Alert(String html) {
048                super(html);
049        }
050
051        /**
052         * @param html
053         * @param type
054         */
055        public Alert(String html, AlertType type) {
056                super(html);
057                setType(type);
058        }
059
060        /**
061         * @param html
062         * @param hasClose
063         */
064        public Alert(String html, AlertType type, boolean hasClose) {
065                super(html, hasClose);
066                setType(type);
067        }
068        
069        /**
070         * Sets the text of an optional heading. It is wrapped in {@code <strong>}
071         * tags and placed before the text.
072         */
073        @Override
074        public void setHeading(String text) {
075                if (text == null || text.isEmpty())
076                        super.setHeading("");
077                else
078                        super.setHeading("<strong>" + text + "</strong> ");
079        }
080}