Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jarek/7824: add stylebar to FloatProgress #7837

Merged
merged 1 commit into from
Nov 5, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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());
}


}