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.ProgressBarBase;
019import com.github.gwtbootstrap.client.ui.constants.Constants;
020
021//@formatter:off
022/**
023 * The progress bar.
024 * 
025 * @since 2.0.4.0
026 * @author Dominik Mayer
027 */
028//@formatter:on
029public class ProgressBar extends ProgressBarBase {
030    
031        private Bar bar = new Bar();
032
033        /**
034         * Create a progressbar.
035         */
036        public ProgressBar() {
037            setStylePrimaryName(Constants.PROGRESS);
038                addStyleName(Constants.PROGRESS);
039                setColor(Color.DEFAULT);
040                add(bar);
041        }
042
043        /**
044         * Create a progressbar with type
045         * @param style ProgressBar type
046         */
047        public ProgressBar(Style style) {
048                this();
049                setType(style);
050        }
051
052    /**
053     * Set bar width as a percent unit
054     * @param percent percent
055     */
056        public void setPercent(double percent) {
057                bar.setPercent(percent);
058        }
059
060    /**
061     * Get bar width as a percent unit
062     * @return percent
063     */
064        public double getPercent() {
065            return bar.getPercent();
066        }
067        
068        /**
069         * Clear bar.
070         */
071        @Override
072        public void clear() {
073            bar.clear();
074            bar.setPercent(0);
075        }
076        
077        /**
078         * Set bar label text
079         * @param text bar label text
080         */
081        public void setText(String text) {
082            bar.setText(text);
083        }
084
085}