@Test
  public void imageResource() {
    // Arrange
    ImageResource testImageResource = MyClientBundle.INSTANCE.testImageResource();

    // Act
    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();

    // Assert
    assertEquals("testImageResource", name);
    assertEquals(
        "http://127.0.0.1:8888/gwt_test_utils_module/com/octo/gwt/test/resources/testImageResource.gif",
        url);
    assertEquals(0, heigh);
    assertEquals(0, left);
    assertEquals(0, width);
    assertEquals(0, top);
    assertEquals(
        "com.octo.gwt.test.internal.resources.ImageResourceCallback generated for 'com.octo.gwt.test.resources.MyClientBundle.testImageResource()'",
        toString);
    assertEquals(testImageResource, MyClientBundle.INSTANCE.testImageResource());
  }
Beispiel #2
0
  public static Widget getMessage(ImageResource imageResource, String customMessage) {
    HorizontalPanel hp = new HorizontalPanel();
    hp.setSpacing(5);

    hp.add(new Image(imageResource.getSafeUri()));

    InlineLabel label = new InlineLabel(customMessage);
    label.getElement().getStyle().setFontWeight(Style.FontWeight.NORMAL);
    label.getElement().getStyle().setFloat(Style.Float.LEFT);
    hp.add(label);

    return hp;
  }
    @Override
    public Void apply(Element context, Value jsNode, int index) {
      Value propertyValue = jsNode.getProperty(TYPE);
      String kType = propertyValue.asString();
      ImageResource imageResource = getImage(KomodoType.getKomodoType(kType));

      /*
       * setAttribute will just set the attribute name to xlink:href and not
       * treat it as a ns prefix.
       */
      setElementAttributeNS(
          context, XLINK_NAMESPACE, HTML_HREF, imageResource.getSafeUri().asString());
      context.setAttribute(HTML_WIDTH, Integer.toString(imageResource.getWidth()));
      context.setAttribute(HTML_HEIGHT, Integer.toString(imageResource.getHeight()));
      return null;
    }
Beispiel #4
0
 @Override
 public void show(Detail detail) {
   ImageResource res = detail.imageResource();
   if (res.getWidth() > IMG_MAX_WIDTH || res.getHeight() > IMG_MAX_HEIGHT) {
     setInSlot(
         DetailsPresenter.IMAGE,
         new FitImage(res.getSafeUri().asString(), IMG_MAX_WIDTH, IMG_MAX_HEIGHT));
   } else {
     setInSlot(DetailsPresenter.IMAGE, new Image(res));
   }
   main.clear();
   main.add(detail.main());
   side.clear();
   side.add(detail.side());
   title.setText(detail.title());
 }
  /**
   * Sets the image to use in this menu button.
   *
   * @param image
   */
  public void setImage(ImageResource image) {

    this.image = image;

    Image imageHtml = new Image(image.getSafeUri());
    Style imageStyle = imageHtml.getElement().getStyle();
    imageStyle.setDisplay(Display.BLOCK);
    imageStyle.setProperty("margin", "1.25em auto 0");
    imageStyle.setProperty("maxWidth", "60%");
    imageStyle.setPosition(Position.ABSOLUTE);
    imageStyle.setTop(0, Unit.PX);
    imageStyle.setRight(0, Unit.PX);
    imageStyle.setBottom(0, Unit.PX);
    imageStyle.setLeft(0, Unit.PX);

    panel.add(imageHtml);
  }
Beispiel #6
0
 public ImageElement getInternalImage(ImageResource resource) {
   ImageElement img = Document.get().createImageElement();
   img.setSrc(resource.getSafeUri().asString());
   return img;
 }