use of com.google.gwt.resources.client.ImageResource in project gwt-test-utils by gwt-test-utils.
the class ImageTest method constructor.
@Test
public void constructor() {
// Given
ImageResource imageRessource = MyClientBundle.INSTANCE.imageResource();
// When
Image i = new Image(imageRessource);
// Then
assertThat(i.getUrl()).isEqualTo("http://127.0.0.1:8888/gwt_test_utils_module/imageResource.gif");
assertThat(i.getOriginLeft()).isEqualTo(0);
assertThat(i.getOriginTop()).isEqualTo(0);
assertThat(i.getWidth()).isEqualTo(0);
assertThat(i.getHeight()).isEqualTo(0);
}
use of com.google.gwt.resources.client.ImageResource in project gwt-test-utils by gwt-test-utils.
the class ClientBundleTest method imageResource.
@Test
public void imageResource() {
// Given
ImageResource testImageResource = MyClientBundle.INSTANCE.imageResource();
// When
String name = testImageResource.getName();
String url = testImageResource.getSafeUri().asString();
int heigh = testImageResource.getHeight();
int left = testImageResource.getLeft();
int width = testImageResource.getWidth();
int top = testImageResource.getTop();
String toString = testImageResource.toString();
// Then
assertThat(name).isEqualTo("imageResource");
assertThat(url).isEqualTo("http://127.0.0.1:8888/gwt_test_utils_module/imageResource.gif");
assertThat(heigh).isEqualTo(0);
assertThat(left).isEqualTo(0);
assertThat(width).isEqualTo(0);
assertThat(top).isEqualTo(0);
assertThat(toString).isEqualTo("com.googlecode.gwt.test.internal.resources.ImageResourceCallback generated for 'com.googlecode.gwt.test.resources.MyClientBundle.imageResource()'");
assertThat(MyClientBundle.INSTANCE.imageResource()).isEqualTo(testImageResource);
}
use of com.google.gwt.resources.client.ImageResource in project perun by CESNET.
the class CustomClickableInfoCellWithImageResource method render.
@Override
public void render(Context context, RichGroup value, SafeHtmlBuilder sb) {
if (value != null) {
ImageResource resource = SmallIcons.INSTANCE.bulletWhiteIcon();
if (value.isSyncEnabled()) {
// FIXME - remove old way of determining sync state once values for new attribute are generated.
if ((value.getLastSynchronizationState() != null && value.getLastSynchronizationState().equals("OK")) || (value.getLastSynchronizationState() == null && value.getLastSuccessSynchronizationTimestamp() != null)) {
resource = SmallIcons.INSTANCE.bulletGreenIcon();
if (value.getAuthoritativeGroup() != null && value.getAuthoritativeGroup().equals("1")) {
sb.append(renderer.render(resource, "Synchronized - OK / Authoritative sync"));
sb.append(renderer.render(SmallIcons.INSTANCE.bulletStarIcon(), "Synchronized - OK / Authoritative sync"));
} else {
sb.append(renderer.render(resource, "Synchronized - OK"));
}
} else {
resource = SmallIcons.INSTANCE.bulletRedIcon();
if (value.getAuthoritativeGroup() != null && value.getAuthoritativeGroup().equals("1")) {
sb.append(renderer.render(resource, "Synchronized - Error / Authoritative sync"));
sb.append(renderer.render(SmallIcons.INSTANCE.bulletStarIcon(), "Synchronized - Error / Authoritative sync"));
} else {
sb.append(renderer.render(resource, "Synchronized - Error"));
}
}
} else {
if (value.getAuthoritativeGroup() != null && value.getAuthoritativeGroup().equals("1")) {
sb.append(renderer.render(resource, "Not synchronized / Authoritative sync"));
} else {
sb.append(renderer.render(resource, "Not synchronized"));
}
}
}
}
use of com.google.gwt.resources.client.ImageResource in project perun by CESNET.
the class PerunStatusCell method render.
@Override
public void render(com.google.gwt.cell.client.Cell.Context context, String status, SafeHtmlBuilder sb) {
// selects the image according to the status
ImageResource ir = null;
if (status.equalsIgnoreCase("VALID")) {
ir = VALID;
} else if (status.equalsIgnoreCase("INVALID")) {
ir = INVALID;
} else if (status.equalsIgnoreCase("SUSPENDED")) {
ir = SUSPENDED;
} else if (status.equalsIgnoreCase("EXPIRED")) {
ir = EXPIRED;
} else if (status.equalsIgnoreCase("DISABLED")) {
ir = DISABLED;
}
// if status not available
if (ir == null) {
return;
}
// append the image
Element imageElement = new Image(ir).getElement();
imageElement.setTitle(status);
SafeHtml image = SafeHtmlUtils.fromSafeConstant((imageElement.getString()));
sb.appendHtmlConstant("<div class=\"" + "customClickableTextCell" + "\">");
sb.append(image);
sb.appendHtmlConstant("</div>");
}
use of com.google.gwt.resources.client.ImageResource in project perun by CESNET.
the class PerunStatusWidget method getImage.
/**
* Return the widget with image
* @return image
*/
private Widget getImage() {
// Status
String status = object.getStatus();
// selects the image according to the status
ImageResource ir = null;
if (status.equalsIgnoreCase("VALID")) {
ir = VALID;
} else if (status.equalsIgnoreCase("INVALID")) {
ir = INVALID;
} else if (status.equalsIgnoreCase("SUSPENDED")) {
ir = SUSPENDED;
} else if (status.equalsIgnoreCase("EXPIRED")) {
ir = EXPIRED;
} else if (status.equalsIgnoreCase("DISABLED")) {
ir = DISABLED;
}
// if status not available
if (ir == null) {
return new HTML("");
}
// return the image
Image im = new Image(ir);
return im;
}
Aggregations