Skip to content

Commit

Permalink
#7824: add stylebar to FloatProgress
Browse files Browse the repository at this point in the history
  • Loading branch information
jaroslawmalekcodete committed Oct 23, 2018
1 parent 0a31fa2 commit dc04c7b
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,13 @@ public class FloatProgress extends BoundedFloatWidget {
public static final String VIEW_NAME_VALUE = "ProgressView";
public static final String MODEL_NAME_VALUE = "FloatProgressModel";
public static final String ORIENTATION = "orientation";
public static final String BAR_STYLE = "bar_style";

private String orientation = "horizontal";

private FloatProgress.BarStyle barStyle = FloatProgress.BarStyle.EMPTY;


public FloatProgress() {
super();
openComm();
Expand Down Expand Up @@ -78,4 +82,27 @@ public String getViewNameValue() {
return VIEW_NAME_VALUE;
}

public void setBarStyle(FloatProgress.BarStyle style) {
this.barStyle = style;
sendUpdate(BAR_STYLE, this.barStyle.getValue());
}

public enum BarStyle {
SUCCESS("success"),
INFO("info"),
WARNING("warning"),
DANGER("danger"),
EMPTY("");

private String value;

BarStyle(String value) {
this.value = value;
}

public String getValue() {
return value;
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
/**
* Progress bar that represents an integer bounded from above and below.
*/
public class IntProgress extends BoundedIntWidget {
public class IntProgress extends BoundedIntWidget{

public static final String VIEW_NAME_VALUE = "ProgressView";
public static final String MODEL_NAME_VALUE = "IntProgressModel";
Expand Down Expand Up @@ -74,7 +74,7 @@ public String getViewNameValue() {
}


enum BarStyle {
public enum BarStyle {
SUCCESS("success"),
INFO("info"),
WARNING("warning"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,15 @@ private FloatProgress floatProgress() throws NoSuchAlgorithmException {
return progress;
}


@Test
public void shouldSendCommMsgWhenBarStyleChange() throws Exception {
//given
FloatProgress floatProgress = floatProgress();
//when
floatProgress.setBarStyle(FloatProgress.BarStyle.SUCCESS);
//then
verifyMsgForProperty(groovyKernel, FloatProgress.BAR_STYLE, FloatProgress.BarStyle.SUCCESS.getValue());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,15 @@ private IntProgress intProgress() throws NoSuchAlgorithmException {
return progress;
}

@Test
public void shouldSendCommMsgWhenBarStyleChange() throws Exception {
//given
IntProgress intProgress = intProgress();
//when
intProgress.setBarStyle(IntProgress.BarStyle.SUCCESS);
//then
verifyMsgForProperty(groovyKernel, IntProgress.BAR_STYLE, IntProgress.BarStyle.SUCCESS.getValue());
}


}

0 comments on commit dc04c7b

Please sign in to comment.