Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package org.drools.guvnor.client.util;
  
 
 public class PercentageBar extends Composite
         implements
         HasValue<Integer> {
 
     public static final String FAILURE = "#CC0000";
     public static final String COMPLETE_SUCCESS = "GREEN";
     public static final String INCOMPLETE = "YELLOW";
 
     interface PercentageBarBinder
             extends
             UiBinder<WidgetPercentageBar> {
 
     }
 
     private static PercentageBarBinder uiBinder = GWT.create(PercentageBarBinder.class);
 
     @UiField
     Label percentage;
 
     @UiField
     DivElement wrapper;
 
     @UiField
     DivElement text;
 
     @UiField
     DivElement bar;
 
     private int percent = 0;
 
     private String inCompleteBarColor = ;
 
     public PercentageBar() {
         initWidget(.createAndBindUi(this));
     }
 
     public PercentageBar(String color,
             int width,
             float percent) {
         this();
         setColor(color);
         setWidth(width);
         setPercent((intpercent);
     }
 
     public PercentageBar(String color,
             int width,
             int numerator,
             int denominator) {
         this(color,
                 width,
                 PercentageCalculator.calculatePercent(numerator,
                         denominator));
     }
 
     private void setColor(String color) {
         .getStyle().setBackgroundColor(color);
     }
 
     public void setBackgroundColor(String color) {
         .getStyle().setBackgroundColor(color);
     }
 
     public void setWidth(String width) {
         setWidth(Integer.parseInt(width));
     }
 
     public void setWidth(int width) {
         .getStyle().setWidth(width,
                 .);
         .getStyle().setWidth(width,
                 .);
     }
 
     public void setPercent(int percent) {
         setValue(percent);
     }
 
     public void setPercent(int numerator,
             int denominator) {
         setPercent(PercentageCalculator.calculatePercent(numerator,
                 denominator));
     }
 
        return addHandler(handler,
                ValueChangeEvent.getType());
    }
    public Integer getValue() {
        return ;
    }
    public void setValue(Integer value) {
        setValue(value,
                false);
    }
    public void setValue(Integer value,
            boolean fireEvents) {
         = value;
        setColor();
        .setText(Integer.toString(value) + " %");
        .getStyle().setWidth(value,
                .);
        if (fireEvents) {
            ValueChangeEvent.fire(this,
                    value);
        }
    }
    private void setColor() {
        if ( < 100) {
            setColor();
        } else {
            setColor();
        }
    }
    public void setInCompleteBarColor(String color) {
        this. = color;
    }
New to GrepCode? Check out our FAQ X