Search in sources :

Example 6 with ImageResource

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);
}
Also used : ImageResource(com.google.gwt.resources.client.ImageResource) Image(com.google.gwt.user.client.ui.Image) Test(org.junit.Test)

Example 7 with ImageResource

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);
}
Also used : ImageResource(com.google.gwt.resources.client.ImageResource) GwtTestTest(com.googlecode.gwt.test.GwtTestTest) Test(org.junit.Test)

Example 8 with ImageResource

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"));
            }
        }
    }
}
Also used : ImageResource(com.google.gwt.resources.client.ImageResource)

Example 9 with ImageResource

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>");
}
Also used : ImageResource(com.google.gwt.resources.client.ImageResource) SafeHtml(com.google.gwt.safehtml.shared.SafeHtml) Element(com.google.gwt.dom.client.Element) Image(com.google.gwt.user.client.ui.Image)

Example 10 with ImageResource

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;
}
Also used : ImageResource(com.google.gwt.resources.client.ImageResource)

Aggregations

ImageResource (com.google.gwt.resources.client.ImageResource)34 ImageResource2x (org.rstudio.core.client.resources.ImageResource2x)9 Element (com.google.gwt.dom.client.Element)6 Image (com.google.gwt.user.client.ui.Image)6 SafeHtml (com.google.gwt.safehtml.shared.SafeHtml)5 Column (com.google.gwt.user.cellview.client.Column)5 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)4 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)4 Test (org.junit.Test)4 ImageResourceCell (com.google.gwt.cell.client.ImageResourceCell)3 JavaScriptObject (com.google.gwt.core.client.JavaScriptObject)3 GwtTestTest (com.googlecode.gwt.test.GwtTestTest)3 ArrayList (java.util.ArrayList)3 Context (com.google.gwt.cell.client.Cell.Context)2 JsArray (com.google.gwt.core.client.JsArray)2 JsArrayString (com.google.gwt.core.client.JsArrayString)2 NativeEvent (com.google.gwt.dom.client.NativeEvent)2 SafeHtmlBuilder (com.google.gwt.safehtml.shared.SafeHtmlBuilder)2 ListHandler (com.google.gwt.user.cellview.client.ColumnSortEvent.ListHandler)2 HTML (com.google.gwt.user.client.ui.HTML)2