Example usage for com.google.gwt.event.dom.client LoadEvent getType

List of usage examples for com.google.gwt.event.dom.client LoadEvent getType

Introduction

In this page you can find the example usage for com.google.gwt.event.dom.client LoadEvent getType.

Prototype

public static Type<LoadHandler> getType() 

Source Link

Document

Gets the event type associated with load events.

Usage

From source file:at.ait.dme.yuma.client.image.StandardImageComposite.java

License:EUPL

/**
 * @see HasLoadHandlers// w w  w.  ja  v  a 2s .  c  o  m
 */
@Override
public HandlerRegistration addLoadHandler(LoadHandler loadHandler) {
    if (loadHandler == null)
        return null;

    HandlerRegistration hr = addHandler(loadHandler, LoadEvent.getType());

    if (imageRect != null) {
        LoadEvent.fireNativeEvent(Document.get().createLoadEvent(), this);
    }

    return hr;
}

From source file:at.ait.dme.yuma.client.map.TiledImageComposite.java

License:EUPL

@Override
public HandlerRegistration addLoadHandler(LoadHandler loadHandler) {
    if (loadHandler == null)
        return null;
    return addHandler(loadHandler, LoadEvent.getType());
}

From source file:ch.takoyaki.email.html.client.HtmlPreview.java

License:Open Source License

public HtmlPreview(FileService fservice) {
    initWidget(uiBinder.createAndBindUi(this));
    this.fservice = fservice;
    getFrame().getElement().setId(preview_id);

    getFrame().addDomHandler(new LoadHandler() {
        public void onLoad(LoadEvent event) {
            setScrollTop(getScrollTopValue());
        }//from ww w  .  jav a 2  s .  co  m
    }, LoadEvent.getType());
}

From source file:com.eternach.client.RichOptionGroupWidget.java

License:Apache License

@Override
public void buildOptions(final UIDL uidl) {
    panel.clear();/* w w w . jav  a2s .  c om*/
    optionsEnabled.clear();
    for (final Iterator<?> it = uidl.getChildIterator(); it.hasNext();) {
        boolean iconDisplayed = false;
        final UIDL opUidl = (UIDL) it.next();
        CheckBox op;

        String itemHtml = opUidl.getStringAttribute("caption");
        if (!htmlContentAllowed) {
            itemHtml = Util.escapeHTML(itemHtml);
        }

        final String icon = opUidl.getStringAttribute("icon");
        if (icon != null && icon.length() != 0) {
            final String iconUrl = client.translateVaadinUri(icon);
            itemHtml = "<span style=\"white-space: normal;\">" + itemHtml + "</span><br/><img src=\"" + iconUrl
                    + "\" class=\"" + Icon.CLASSNAME + "\" alt=\"\" />";
            iconDisplayed = true;
        }

        if (isMultiselect()) {
            op = new VCheckBox();
        } else {
            op = new RadioButton(paintableId, null, true);
            op.setStyleName("v-radiobutton");
        }

        op.addStyleName(CLASSNAME_OPTION);
        op.setValue(opUidl.getBooleanAttribute("selected"));
        final boolean optionEnabled = !opUidl
                .getBooleanAttribute(OptionGroupConstants.ATTRIBUTE_OPTION_DISABLED);
        final boolean enabled = optionEnabled && !isReadonly() && isEnabled();
        op.setEnabled(enabled);
        optionsEnabled.add(optionEnabled);
        setStyleName(op.getElement(), ApplicationConnection.DISABLED_CLASSNAME,
                !(optionEnabled && isEnabled()));
        op.addClickHandler(this);
        optionsToKeys.put(op, opUidl.getStringAttribute("key"));
        String description = opUidl.getStringAttribute("description-text");
        if (description == null) {
            description = "";
        }
        if (opUidl.getStringAttribute("description-icon") != null) {
            description += "<br/><img src=\""
                    + client.translateVaadinUri(opUidl.getStringAttribute("description-icon")) + "\"\\>";
        }

        final FocusableFlexTable table = new FocusableFlexTable();
        table.setWidget(0, 0, op);
        table.setHTML(0, 1, itemHtml);
        table.setCellPadding(0);
        table.setCellSpacing(0);
        panel.add(table);

        if (description != null && description.length() != 0) {
            elementsToDescription.put(table.getElement(), description);
        }
        if (iconDisplayed) {
            Util.sinkOnloadForImages(table.getElement());
            table.addHandler(iconLoadHandler, LoadEvent.getType());
        }
    }

}

From source file:com.googlecode.gwtmock.client.MockHasLoadHandlers.java

License:Apache License

@Override
public HandlerRegistration addLoadHandler(LoadHandler handler) {
    return eventBus.addHandler(LoadEvent.getType(), handler);
}

From source file:com.risevision.ui.client.common.widgets.text.RichTextEditorWidget.java

License:Open Source License

public HandlerRegistration addLoadHandler(LoadHandler handler) {
    return addHandler(handler, LoadEvent.getType());
}

From source file:com.vaadin.client.ui.image.ImageConnector.java

License:Apache License

@Override
protected void init() {
    super.init();
    getWidget().addHandler(new LoadHandler() {

        @Override/*from w w  w . j  a  v a  2  s  . co  m*/
        public void onLoad(LoadEvent event) {
            getLayoutManager().setNeedsMeasure(ImageConnector.this);
        }

    }, LoadEvent.getType());
}

From source file:com.vaadin.client.ui.VComboBox.java

License:Apache License

/**
 * Sets the icon URI of the selected item. The icon is shown on the left
 * side of the item caption text. Set the URI to null to remove the icon.
 *
 * @param iconUri//  w w w  . ja  v  a2 s  .c  o  m
 *            The URI of the icon, or null to remove icon
 */
public void setSelectedItemIcon(String iconUri) {

    if (selectedItemIcon != null) {
        panel.remove(selectedItemIcon);
    }
    if (iconUri == null || iconUri.length() == 0) {
        if (selectedItemIcon != null) {
            selectedItemIcon = null;
            afterSelectedItemIconChange();
        }
    } else {
        selectedItemIcon = new IconWidget(connector.getConnection().getIcon(iconUri));
        selectedItemIcon.addDomHandler(VComboBox.this, ClickEvent.getType());
        selectedItemIcon.addDomHandler(VComboBox.this, MouseDownEvent.getType());
        iconUpdating = true;
        selectedItemIcon.addDomHandler(new LoadHandler() {
            @Override
            public void onLoad(LoadEvent event) {
                afterSelectedItemIconChange();
                iconUpdating = false;
            }
        }, LoadEvent.getType());
        panel.insert(selectedItemIcon, 0);
        afterSelectedItemIconChange();
    }
}

From source file:com.vaadin.client.ui.VFilterSelect.java

License:Apache License

/**
 * Sets the icon URI of the selected item. The icon is shown on the left
 * side of the item caption text. Set the URI to null to remove the icon.
 * /*from  w  ww  . j a  va 2 s. co  m*/
 * @param iconUri
 *            The URI of the icon
 */
public void setSelectedItemIcon(String iconUri) {

    if (iconUri == null || iconUri.length() == 0) {
        if (selectedItemIcon != null) {
            panel.remove(selectedItemIcon);
            selectedItemIcon = null;
            afterSelectedItemIconChange();
        }
    } else {
        if (selectedItemIcon != null) {
            panel.remove(selectedItemIcon);
        }
        selectedItemIcon = new IconWidget(client.getIcon(iconUri));
        // Older IE versions don't scale icon correctly if DOM
        // contains height and width attributes.
        selectedItemIcon.getElement().removeAttribute("height");
        selectedItemIcon.getElement().removeAttribute("width");
        selectedItemIcon.addDomHandler(new LoadHandler() {
            @Override
            public void onLoad(LoadEvent event) {
                afterSelectedItemIconChange();
            }
        }, LoadEvent.getType());
        panel.insert(selectedItemIcon, 0);
        afterSelectedItemIconChange();
    }
}

From source file:com.vaadin.client.ui.VOptionGroup.java

License:Apache License

@Override
public void buildOptions(UIDL uidl) {
    /*//w  ww.  j  a  v  a  2 s  .c  om
     * In order to retain focus, we need to update values rather than
     * recreate panel from scratch (#10451). However, the panel will be
     * rebuilt (losing focus) if number of elements or their order is
     * changed.
     */
    HashMap<String, CheckBox> keysToOptions = new HashMap<String, CheckBox>();
    for (Map.Entry<CheckBox, String> entry : optionsToKeys.entrySet()) {
        keysToOptions.put(entry.getValue(), entry.getKey());
    }
    ArrayList<Widget> existingwidgets = new ArrayList<Widget>();
    ArrayList<Widget> newwidgets = new ArrayList<Widget>();

    // Get current order of elements
    for (Widget wid : panel) {
        existingwidgets.add(wid);
    }

    optionsEnabled.clear();

    if (isMultiselect()) {
        Roles.getGroupRole().set(getElement());
    } else {
        Roles.getRadiogroupRole().set(getElement());
    }

    for (final Iterator<?> it = uidl.getChildIterator(); it.hasNext();) {
        final UIDL opUidl = (UIDL) it.next();

        String itemHtml = opUidl.getStringAttribute("caption");
        if (!htmlContentAllowed) {
            itemHtml = WidgetUtil.escapeHTML(itemHtml);
        }

        String iconUrl = opUidl.getStringAttribute("icon");
        if (iconUrl != null && iconUrl.length() != 0) {
            Icon icon = client.getIcon(iconUrl);
            itemHtml = icon.getElement().getString() + itemHtml;
        }

        String key = opUidl.getStringAttribute("key");
        CheckBox op = keysToOptions.get(key);

        // Need to recreate object if isMultiselect is changed (#10451)
        // OR if htmlContentAllowed changed due to Safari 5 issue
        if ((op == null) || (htmlContentAllowed != wasHtmlContentAllowed)
                || (isMultiselect() != wasMultiselect)) {
            // Create a new element
            if (isMultiselect()) {
                op = new VCheckBox();
            } else {
                op = new RadioButton(paintableId);
                op.setStyleName("v-radiobutton");
            }
            if (iconUrl != null && iconUrl.length() != 0) {
                WidgetUtil.sinkOnloadForImages(op.getElement());
                op.addHandler(iconLoadHandler, LoadEvent.getType());
            }

            op.addStyleName(CLASSNAME_OPTION);
            op.addClickHandler(this);

            optionsToKeys.put(op, key);
        }

        op.setHTML(itemHtml);
        op.setValue(opUidl.getBooleanAttribute("selected"));
        boolean optionEnabled = !opUidl.getBooleanAttribute(OptionGroupConstants.ATTRIBUTE_OPTION_DISABLED);
        boolean enabled = optionEnabled && !isReadonly() && isEnabled();
        op.setEnabled(enabled);
        optionsEnabled.put(op, optionEnabled);

        setStyleName(op.getElement(), StyleConstants.DISABLED, !(optionEnabled && isEnabled()));

        newwidgets.add(op);
    }

    if (!newwidgets.equals(existingwidgets)) {
        // Rebuild the panel, losing focus
        panel.clear();
        for (Widget wid : newwidgets) {
            panel.add(wid);
        }
    }

    wasHtmlContentAllowed = htmlContentAllowed;
    wasMultiselect = isMultiselect();
}