Example usage for com.google.gwt.dom.client ImageElement getAlt

List of usage examples for com.google.gwt.dom.client ImageElement getAlt

Introduction

In this page you can find the example usage for com.google.gwt.dom.client ImageElement getAlt.

Prototype

public String getAlt() 

Source Link

Document

Alternate text for user agents not rendering the normal content of this element.

Usage

From source file:org.xwiki.gwt.wysiwyg.client.plugin.embed.EmbedPlugin.java

License:Open Source License

/**
 * Replaces the given embedded object with a static image place-holder of the same size.
 * //from  w  w w  .ja v a2 s .c  o  m
 * @param embed the embedded object to be replaced
 */
private void replaceEmbeddedObject(Element embed) {
    // Create the place-holder.
    ImageElement placeHolder = embed.getOwnerDocument().createImageElement();
    placeHolder.setSrc(GWT.getModuleBaseURL() + "clear.cache.gif");
    placeHolder.setAlt(Strings.INSTANCE.embeddedObject());
    placeHolder.setTitle(placeHolder.getAlt());
    placeHolder.setClassName("xEmbeddedObject");
    // We can't rely on the offsetWidth and offsetHeight because the embedded object is replaced before being
    // displayed (even before it is loaded). Also the embedded object is not redisplayed after it is detached and
    // re-attached (e.g. undo operation). We use the width and height specified on the embedded object.
    setSize(placeHolder, Style.WIDTH, embed.getPropertyString(Style.WIDTH));
    setSize(placeHolder, Style.HEIGHT, embed.getPropertyString(Style.HEIGHT));

    // Replace the embedded object.
    embed.getParentNode().replaceChild(placeHolder, embed);

    // Set the place-holder meta data to ensure the embedded object is restored when the DOM document is serialized.
    DocumentFragment metadata = getTextArea().getDocument().createDocumentFragment();
    metadata.appendChild(embed);
    org.xwiki.gwt.dom.client.Element.as(placeHolder).setMetaData(metadata);
}

From source file:org.xwiki.gwt.wysiwyg.client.plugin.image.ImageConfigDOMReader.java

License:Open Source License

/**
 * {@inheritDoc}//from w ww  . j av  a 2 s  .c om
 * 
 * @see ConfigDOMReader#read(com.google.gwt.dom.client.Element)
 */
public ImageConfig read(ImageElement image) {
    ImageConfig config = new ImageConfig();
    config.setReference(readReference(image));
    config.setUrl(image.getSrc());

    // Image width priority: style attribute > width attribute > width property
    String width = image.getStyle().getWidth();
    if (StringUtils.isEmpty(width)) {
        width = image.getAttribute(Style.WIDTH);
        if (StringUtils.isEmpty(width)) {
            width = String.valueOf(image.getWidth());
        }
    }
    config.setWidth(width);

    // Image height priority: style attribute > height attribute > height property
    String height = image.getStyle().getHeight();
    if (StringUtils.isEmpty(height)) {
        height = image.getAttribute(Style.HEIGHT);
        if (StringUtils.isEmpty(height)) {
            height = String.valueOf(image.getHeight());
        }
    }
    config.setHeight(height);

    config.setAltText(image.getAlt());
    config.setAlignment(readImageAlignment(image));

    return config;
}