001package com.github.gwtbootstrap.client.ui.base;
002
003import com.github.gwtbootstrap.client.ui.constants.Constants;
004import com.github.gwtbootstrap.client.ui.resources.Bootstrap;
005
006public class ProgressBarBase extends DivWidget {
007
008    public enum Style implements com.github.gwtbootstrap.client.ui.base.Style {
009
010        DEFAULT(""),
011
012        STRIPED(Bootstrap.progress_striped),
013        
014        ANIMATED(Bootstrap.progress_animated);
015        
016        private final String styleName;
017
018        private Style(String styleName) {
019            this.styleName = styleName;
020            
021        }
022
023        public String get() {
024            return this.styleName;
025        }
026    }
027    
028    public enum Color implements com.github.gwtbootstrap.client.ui.base.Style {
029        DEFAULT(""),
030        INFO("progress-info"),
031        SUCCESS("progress-success"),
032        DANGER("progress-danger"),
033        WARNING("progress-warning")
034        ;
035        
036        private final String styleName;
037
038        private Color(String styleName) {
039            this.styleName = styleName;
040        }
041
042        @Override
043        public String get() {
044            return this.styleName;
045        }
046        
047    }
048
049    public ProgressBarBase() {
050        super();
051    }
052
053    public ProgressBarBase(String styleName) {
054        super(styleName);
055    }
056
057    public void setType(Style style) {
058        StyleHelper.changeStyle(this, style, Style.class);
059        setActive(Style.ANIMATED == style);
060    }
061
062    /**
063     * Set progress bar color
064     * @param color color
065     */
066    public void setColor(Color color) {
067        StyleHelper.changeStyle(this, color, Color.class);
068    }
069
070    /**
071     * Set active style.
072     * <p>
073     * if set type {@link Style#STRIPED} and this set true, bar is animated
074     * @param active true:active false:deactive
075     */
076    public void setActive(boolean active) {
077        setStyleName(Constants.ACTIVE , active);
078    }
079
080}