Search in sources :

Example 1 with IFrameElement

use of com.google.gwt.dom.client.IFrameElement in project cuba by cuba-platform.

the class CubaFileDownloaderConnector method downloadFileById.

public void downloadFileById(String resourceId) {
    final String url = getResourceUrl(resourceId);
    if (url != null && !url.isEmpty()) {
        final IFrameElement iframe = Document.get().createIFrameElement();
        Style style = iframe.getStyle();
        style.setVisibility(Style.Visibility.HIDDEN);
        style.setHeight(0, Style.Unit.PX);
        style.setWidth(0, Style.Unit.PX);
        iframe.setFrameBorder(0);
        iframe.setTabIndex(-1);
        iframe.setSrc(url);
        RootPanel.getBodyElement().appendChild(iframe);
        Timer removeTimer = new Timer() {

            @Override
            public void run() {
                iframe.removeFromParent();
            }
        };
        removeTimer.schedule(60 * 1000);
    }
}
Also used : Timer(com.google.gwt.user.client.Timer) IFrameElement(com.google.gwt.dom.client.IFrameElement) Style(com.google.gwt.dom.client.Style)

Example 2 with IFrameElement

use of com.google.gwt.dom.client.IFrameElement in project ovirt-engine by oVirt.

the class PluginManager method defineAndLoadPlugin.

/**
 * Defines a plugin from the given meta-data, and loads it as necessary.
 */
void defineAndLoadPlugin(PluginMetaData pluginMetaData) {
    String pluginName = pluginMetaData.getName();
    String pluginHostPageUrl = pluginMetaData.getHostPageUrl();
    if (pluginName == null || pluginName.trim().isEmpty()) {
        // $NON-NLS-1$
        logger.warning("Plugin name cannot be null or empty");
        return;
    } else if (pluginHostPageUrl == null || pluginHostPageUrl.trim().isEmpty()) {
        // $NON-NLS-1$ //$NON-NLS-2$
        logger.warning("Plugin [" + pluginName + "] has null or empty host page URL");
        return;
    } else if (getPlugin(pluginName) != null) {
        // $NON-NLS-1$ //$NON-NLS-2$
        logger.warning("Plugin [" + pluginName + "] is already defined");
        return;
    }
    // Create an iframe element used to load the plugin host page
    IFrameElement iframe = Document.get().createIFrameElement();
    iframe.setSrc(pluginHostPageUrl);
    iframe.setFrameBorder(0);
    iframe.getStyle().setPosition(Position.ABSOLUTE);
    iframe.getStyle().setWidth(0, Unit.PT);
    iframe.getStyle().setHeight(0, Unit.PT);
    iframe.getStyle().setBorderStyle(BorderStyle.NONE);
    Plugin plugin = new Plugin(pluginMetaData, iframe);
    addPlugin(plugin);
    // $NON-NLS-1$ //$NON-NLS-2$
    logger.fine("Plugin [" + pluginName + "] is defined to be loaded from URL " + pluginHostPageUrl);
    // Load the plugin host page
    if (pluginMetaData.isEnabled()) {
        loadPlugin(plugin);
        if (plugin.shouldPreLoad()) {
            pluginsToPreLoad.put(pluginName, false);
            // $NON-NLS-1$ //$NON-NLS-2$
            logger.fine("Plugin [" + pluginName + "] will be pre-loaded");
        }
    }
}
Also used : IFrameElement(com.google.gwt.dom.client.IFrameElement)

Example 3 with IFrameElement

use of com.google.gwt.dom.client.IFrameElement in project gwt-test-utils by gwt-test-utils.

the class FramePatcher method setUrl.

@PatchMethod
static void setUrl(Frame frame, String url) {
    IFrameElement e = frame.getElement().cast();
    e.setSrc(url);
}
Also used : IFrameElement(com.google.gwt.dom.client.IFrameElement) PatchMethod(com.googlecode.gwt.test.patchers.PatchMethod)

Example 4 with IFrameElement

use of com.google.gwt.dom.client.IFrameElement in project cuba by cuba-platform.

the class CubaFileDownloaderConnector method downloadFileById.

public void downloadFileById(String resourceId) {
    final String url = getResourceUrl(resourceId);
    if (url != null && !url.isEmpty()) {
        final IFrameElement iframe = Document.get().createIFrameElement();
        Style style = iframe.getStyle();
        style.setVisibility(Style.Visibility.HIDDEN);
        style.setHeight(0, Style.Unit.PX);
        style.setWidth(0, Style.Unit.PX);
        iframe.setFrameBorder(0);
        iframe.setTabIndex(-1);
        iframe.setSrc(url);
        RootPanel.getBodyElement().appendChild(iframe);
        Timer removeTimer = new Timer() {

            @Override
            public void run() {
                iframe.removeFromParent();
            }
        };
        removeTimer.schedule(60 * 1000);
    }
}
Also used : Timer(com.google.gwt.user.client.Timer) IFrameElement(com.google.gwt.dom.client.IFrameElement) Style(com.google.gwt.dom.client.Style)

Aggregations

IFrameElement (com.google.gwt.dom.client.IFrameElement)4 Style (com.google.gwt.dom.client.Style)2 Timer (com.google.gwt.user.client.Timer)2 PatchMethod (com.googlecode.gwt.test.patchers.PatchMethod)1