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.HasType;
019import com.github.gwtbootstrap.client.ui.constants.Constants;
020import com.github.gwtbootstrap.client.ui.constants.DismissType;
021import com.google.gwt.user.client.ui.Anchor;
022
023//@formatter:off
024/**
025 * Icon ("×") that indicates that something can be closed.
026 * 
027 * <p>
028 * <h3>UiBinder Usage:</h3>
029 * 
030 * {@code <b:Close />}
031 * </p>
032 * 
033 * @since 2.0.4.0
034 * 
035 * @author Dominik Mayer
036 * 
037 * @see <a href="http://getbootstrap.com/2.3.2/components.html#misc">Bootstrap documentation</a>
038 * @see Alert
039 * @see AlertBlock
040 * @see Modal
041 */
042//@formatter:on
043public class Close extends Anchor implements HasType<DismissType> {
044
045        /**
046         * Creates an icon without behavior.
047         */
048        public Close() {
049                setStyleName(Constants.CLOSE);
050                setHTML(Constants.CLOSE_ICON);
051        }
052
053        /**
054         * Creates an icon that closes an associated widget.
055         * 
056         * @param dismiss
057         *            the type of widget to be closed
058         */
059        public Close(DismissType dismiss) {
060                this();
061                setType(dismiss);
062        }
063
064        /**
065         * Sets the type of widget to be closed.
066         * 
067         * @param type
068         *            the type of widget to be closed
069         */
070        public void setType(DismissType type) {
071                getElement().setAttribute(Constants.DATA_DISMISS, type.get());
072        }
073}